From: David ‘Bombe’ Roden Date: Tue, 5 Apr 2011 07:49:59 +0000 (+0200) Subject: Add method to get all posts that have a certain Sone as recipient. X-Git-Tag: 0.6.1^2~43 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b001ba1e23a469561e4e313d77dd18a5c284732b;p=Sone.git Add method to get all posts that have a certain Sone as recipient. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 005524e..731fcbd 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -576,6 +576,27 @@ public class Core implements IdentityListener, UpdateListener { } /** + * Returns all posts that have the given Sone as recipient. + * + * @see Post#getRecipient() + * @param recipient + * The recipient of the posts + * @return All posts that have the given Sone as recipient + */ + public Set getDirectedPosts(Sone recipient) { + Validation.begin().isNotNull("Recipient", recipient).check(); + Set directedPosts = new HashSet(); + synchronized (posts) { + for (Post post : posts.values()) { + if (recipient.equals(post.getRecipient())) { + directedPosts.add(post); + } + } + } + return directedPosts; + } + + /** * Returns the reply with the given ID. If there is no reply with the given * ID yet, a new one is created. *