Every time a Sone is fetched, see if it can be unshelled.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 4a75a03..211a76e 100644 (file)
@@ -33,6 +33,7 @@ import net.pterodactylus.sone.data.PostShell;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.ReplyShell;
+import net.pterodactylus.sone.data.Shell;
 import net.pterodactylus.sone.data.ShellCache;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.data.SoneShell;
@@ -119,6 +120,21 @@ public class Core extends AbstractService {
                return Collections.unmodifiableSet(localSones);
        }
 
+       /**
+        * Returns a Sone or a {@link Shell} around one for the given ID.
+        *
+        * @param soneId
+        *            The ID of the Sone
+        * @return The Sone, or a {@link Shell} around one
+        */
+       public Sone getSone(String soneId) {
+               Sone sone = soneCache.get(soneId);
+               if (sone instanceof SoneShell) {
+                       soneCache.put(soneId, sone = ((SoneShell) sone).getShelled());
+               }
+               return sone;
+       }
+
        //
        // ACTIONS
        //