X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=7c96443358b47660b1fd0423d13957474d77a804;hb=d20339ba3ce709ac5c342e1511021aaa392376ee;hp=5efcc067d07a2e5c94e1f6a0f9827ab9f879e0da;hpb=1c3d65453e87eb0ad558c079f9616684caf8e969;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 5efcc06..7c96443 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,62 @@ 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; + } + + // + // OBJECT METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + /* TODO improve */ + return requestUri.hashCode(); + } + }