From 68e6a4ba77a6f9fcea28ad73e12cf78817c5f42c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 18 Oct 2010 16:00:14 +0200 Subject: [PATCH] Store list of blocked Sone IDs in Sone. --- .../java/net/pterodactylus/sone/data/Sone.java | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index a387545..f83ab82 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -72,6 +72,9 @@ public class Sone { /** All replies. */ private final Set replies = new HashSet(); + /** The IDs of all blocked Sones. */ + private final Set blockedSoneIds = new HashSet(); + /** Modification count. */ private volatile long modificationCounter = 0; @@ -377,6 +380,48 @@ public class Sone { } /** + * Returns the IDs of all blocked Sones. These Sones will not propagated + * using the “known Sones” mechanism. + * + * @return The IDs of all blocked Sones + */ + public Set getBlockedSoneIds() { + return Collections.unmodifiableSet(blockedSoneIds); + } + + /** + * Returns whether the given Sone ID is blocked. + * + * @param soneId + * The Sone ID to check + * @return {@code true} if the given Sone ID is blocked, {@code false} + * otherwise + */ + public boolean isSoneBlocked(String soneId) { + return blockedSoneIds.contains(soneId); + } + + /** + * Adds the given ID to the list of blocked IDs. + * + * @param soneId + * The Sone ID to block + */ + public void addBlockedSoneId(String soneId) { + blockedSoneIds.add(soneId); + } + + /** + * Removes the given ID from the list of blocked IDs. + * + * @param soneId + * The Sone ID to unblock + */ + public void removeBlockedSoneIds(String soneId) { + blockedSoneIds.remove(soneId); + } + + /** * Returns the modification counter. * * @return The modification counter -- 2.7.4