From b001ba1e23a469561e4e313d77dd18a5c284732b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 5 Apr 2011 09:49:59 +0200 Subject: [PATCH] Add method to get all posts that have a certain Sone as recipient. --- src/main/java/net/pterodactylus/sone/core/Core.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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. * -- 2.7.4