From: David ‘Bombe’ Roden Date: Tue, 12 Oct 2010 13:40:27 +0000 (+0200) Subject: Add friend Sones. X-Git-Tag: 0.1-RC1~537 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=1a692590405dd38863d117a48295e9138964a955 Add friend Sones. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 5efcc06..8416a05 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -17,6 +17,10 @@ package net.pterodactylus.sone.data; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + import freenet.keys.FreenetURI; /** @@ -34,6 +38,9 @@ public class Sone { /* This will be null for remote Sones! */ private final FreenetURI insertUri; + /** All friend Sones. */ + private final Set friendSones = new HashSet(); + /** * Creates a new Sone. * @@ -79,4 +86,49 @@ public class Sone { return insertUri; } + /** + * Returns all friend Sones of this Sone. + * + * @return The friend Sones of this Sone + */ + public Set getFriendSones() { + return Collections.unmodifiableSet(friendSones); + } + + /** + * Returns whether this Sone has the given Sone as a friend Sone. + * + * @param friendSone + * The friend Sone to check for + * @return {@code true} if this Sone has the given Sone as a friend, + * {@code false} otherwise + */ + public boolean hasFriendSone(Sone friendSone) { + return friendSones.contains(friendSone); + } + + /** + * Adds the given Sone as a friend Sone. + * + * @param friendSone + * The friend Sone to add + * @return This Sone (for method chaining) + */ + public Sone addFriendSone(Sone friendSone) { + friendSones.add(friendSone); + return this; + } + + /** + * Removes the given Sone as a friend Sone. + * + * @param friendSone + * The friend Sone to remove + * @return This Sone (for method chaining) + */ + public Sone removeFriendSone(Sone friendSone) { + friendSones.remove(friendSone); + return this; + } + }