From 1a692590405dd38863d117a48295e9138964a955 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 12 Oct 2010 15:40:27 +0200 Subject: [PATCH] Add friend Sones. --- .../java/net/pterodactylus/sone/data/Sone.java | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) 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; + } + } -- 2.7.4