Always create Shells with IDs.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Oct 2010 12:59:59 +0000 (14:59 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Oct 2010 12:59:59 +0000 (14:59 +0200)
src/main/java/net/pterodactylus/sone/data/PostShell.java
src/main/java/net/pterodactylus/sone/data/ReplyShell.java
src/main/java/net/pterodactylus/sone/data/ShellCache.java
src/main/java/net/pterodactylus/sone/data/ShellCreator.java
src/main/java/net/pterodactylus/sone/data/SoneShell.java

index b0cb8e6..4a4b797 100644 (file)
@@ -34,8 +34,8 @@ public class PostShell extends Post implements Shell<Post> {
        public static final ShellCreator<Post> creator = new ShellCreator<Post>() {
 
                @Override
-               public Shell<Post> createShell() {
-                       return new PostShell();
+               public Shell<Post> createShell(String id) {
+                       return new PostShell().setId(UUID.fromString(id));
                }
        };
 
index afcf295..6886a9d 100644 (file)
@@ -31,8 +31,8 @@ public class ReplyShell extends Reply implements Shell<Reply> {
        public static final ShellCreator<Reply> creator = new ShellCreator<Reply>() {
 
                @Override
-               public Shell<Reply> createShell() {
-                       return new ReplyShell();
+               public Shell<Reply> createShell(String id) {
+                       return new ReplyShell().setId(UUID.fromString(id));
                }
        };
 
index 0b19429..fd3d6bc 100644 (file)
@@ -84,7 +84,7 @@ public class ShellCache<T> {
         */
        public T get(String id) {
                if (!objectCache.containsKey(id)) {
-                       Shell<T> shell = shellCreator.createShell();
+                       Shell<T> shell = shellCreator.createShell(id);
                        shellCache.put(id, shell);
                        return shell.getShelled();
                }
index 3c5a89a..6835b00 100644 (file)
@@ -29,8 +29,10 @@ public interface ShellCreator<T> {
        /**
         * Creates a new shell.
         *
+        * @param id
+        *            The ID of the shell object
         * @return The new shell
         */
-       public Shell<T> createShell();
+       public Shell<T> createShell(String id);
 
 }
index 49059c7..cced1e5 100644 (file)
@@ -37,8 +37,8 @@ public class SoneShell extends Sone implements Shell<Sone> {
        public static final ShellCreator<Sone> creator = new ShellCreator<Sone>() {
 
                @Override
-               public Shell<Sone> createShell() {
-                       return new SoneShell();
+               public Shell<Sone> createShell(String id) {
+                       return new SoneShell().setId(UUID.fromString(id));
                }
        };