From: David ‘Bombe’ Roden Date: Mon, 18 Oct 2010 14:00:14 +0000 (+0200) Subject: Store list of blocked Sone IDs in Sone. X-Git-Tag: 0.1-RC1~233 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=68e6a4ba77a6f9fcea28ad73e12cf78817c5f42c;p=Sone.git Store list of blocked Sone IDs in Sone. --- 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