Add method to get all posts of a Sone to post provider interface.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index b2188e0..9ccaa79 100644 (file)
@@ -347,12 +347,13 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
        }
 
        /**
-        * Returns all Sones, remote and local.
-        *
-        * @return All Sones
+        * {@inheritDocs}
         */
-       public Set<Sone> getSones() {
-               return new HashSet<Sone>(sones.values());
+       @Override
+       public Collection<Sone> getSones() {
+               synchronized (sones) {
+                       return Collections.unmodifiableCollection(sones.values());
+               }
        }
 
        /**
@@ -372,24 +373,9 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
        }
 
        /**
-        * Checks whether the core knows a Sone with the given ID.
-        *
-        * @param id
-        *            The ID of the Sone
-        * @return {@code true} if there is a Sone with the given ID, {@code false}
-        *         otherwise
-        */
-       public boolean hasSone(String id) {
-               synchronized (sones) {
-                       return sones.containsKey(id);
-               }
-       }
-
-       /**
-        * Returns all local Sones.
-        *
-        * @return All local Sones
+        * {@inheritDocs}
         */
+       @Override
        public Collection<Sone> getLocalSones() {
                synchronized (sones) {
                        return Collections2.filter(sones.values(), new Predicate<Sone>() {
@@ -428,10 +414,9 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
        }
 
        /**
-        * Returns all remote Sones.
-        *
-        * @return All remote Sones
+        * {@inheritDocs}
         */
+       @Override
        public Collection<Sone> getRemoteSones() {
                synchronized (sones) {
                        return Collections2.filter(sones.values(), new Predicate<Sone>() {
@@ -527,6 +512,14 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
        }
 
        /**
+        * {@inheritDocs}
+        */
+       @Override
+       public Collection<Post> getPosts(String soneId) {
+               return postDatabase.getPosts(soneId);
+       }
+
+       /**
         * {@inheritDoc}
         */
        @Override
@@ -1106,6 +1099,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                                }
                        }
                        synchronized (sones) {
+                               sone.setOptions(storedSone.get().getOptions());
                                sones.put(sone.getId(), sone);
                        }
                }