Merge commit 'fcabe38e9b3abacc0d580bf0513600858aee2eca' into less-critical
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 24 Jan 2013 05:10:32 +0000 (06:10 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 24 Jan 2013 05:10:32 +0000 (06:10 +0100)
Conflicts:
src/main/java/net/pterodactylus/sone/core/Core.java

1  2 
src/main/java/net/pterodactylus/sone/core/Core.java

@@@ -584,26 -584,21 +587,23 @@@ public class Core extends AbstractServi
        }
  
        /**
-        * Returns all replies for the given post, order ascending by time.
-        *
-        * @param post
-        *            The post to get all replies for
-        * @return All replies for the given post
+        * {@inheritDoc}
         */
 -      public List<PostReply> getReplies(Post post) {
 -              Set<Sone> sones = getSones();
 -              List<PostReply> replies = new ArrayList<PostReply>();
 -              for (Sone sone : sones) {
 -                      for (PostReply reply : sone.getReplies()) {
 -                              if (reply.getPost().equals(post)) {
 -                                      replies.add(reply);
 -                              }
+       @Override
 +      public List<PostReply> getReplies(final Post post) {
 +              return Ordering.from(Reply.TIME_COMPARATOR).sortedCopy(FluentIterable.from(getSones()).transformAndConcat(new Function<Sone, Iterable<PostReply>>() {
 +
 +                      @Override
 +                      public Iterable<PostReply> apply(Sone sone) {
 +                              return sone.getReplies();
                        }
 -              }
 -              Collections.sort(replies, Reply.TIME_COMPARATOR);
 -              return replies;
 +              }).filter(new Predicate<PostReply>() {
 +
 +                      @Override
 +                      public boolean apply(PostReply reply) {
 +                              return post.equals(reply.getPost());
 +                      }
 +              }));
        }
  
        /**