X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FPostShell.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FPostShell.java;h=af9598e94d9a20f6fe71b074b24ed04061ea6846;hb=60e05f5839cc3c00610d861a24003781c3040e11;hp=4a4b797e257afeec432e3a5a274d51ebd62c9586;hpb=cd5e2259ab672c714a8fe2b632da670e30dee090;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/PostShell.java b/src/main/java/net/pterodactylus/sone/data/PostShell.java index 4a4b797..af9598e 100644 --- a/src/main/java/net/pterodactylus/sone/data/PostShell.java +++ b/src/main/java/net/pterodactylus/sone/data/PostShell.java @@ -21,6 +21,10 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.Logger; + +import net.pterodactylus.util.logging.Logging; /** * {@link Shell} around a {@link Post} that has not yet been retrieved from @@ -30,12 +34,15 @@ import java.util.UUID; */ public class PostShell extends Post implements Shell { + /** The logger. */ + private static final Logger logger = Logging.getLogger(PostShell.class); + /** The shell creator. */ public static final ShellCreator creator = new ShellCreator() { @Override public Shell createShell(String id) { - return new PostShell().setId(UUID.fromString(id)); + return new PostShell().setId(id); } }; @@ -82,8 +89,13 @@ public class PostShell extends Post implements Shell { * The ID of the post * @return This post shell (for method chaining) */ - public PostShell setId(UUID id) { - this.id = id; + public PostShell setId(String id) { + try { + this.id = UUID.fromString(id); + } catch (IllegalArgumentException iae1) { + logger.log(Level.WARNING, "Invalid ID: “" + id + "”.", iae1); + this.id = UUID.randomUUID(); + } return this; }