X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=bd2416608dc8199450c500a1ac50b067785a0391;hb=a4cd99055d3814bc087efb8fa77ae861dff4e0fd;hp=f83ab821fc238013f4400af3e7903bccf14d1b36;hpb=68e6a4ba77a6f9fcea28ad73e12cf78817c5f42c;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 f83ab82..bd24166 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -28,6 +28,7 @@ import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; +import net.pterodactylus.sone.template.SoneAccessor; import net.pterodactylus.util.logging.Logging; import freenet.keys.FreenetURI; @@ -214,8 +215,20 @@ public class Sone { * * @return The friend Sones of this Sone */ - public Set getFriends() { - return Collections.unmodifiableSet(friendSones); + public List getFriends() { + List friends = new ArrayList(friendSones); + Collections.sort(friends, new Comparator() { + + @Override + public int compare(Sone leftSone, Sone rightSone) { + int diff = SoneAccessor.getNiceName(leftSone).compareTo(SoneAccessor.getNiceName(rightSone)); + if (diff != 0) { + return diff; + } + return (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, rightSone.getTime() - leftSone.getTime())); + } + }); + return friends; } /** @@ -407,8 +420,10 @@ public class Sone { * @param soneId * The Sone ID to block */ - public void addBlockedSoneId(String soneId) { - blockedSoneIds.add(soneId); + public synchronized void addBlockedSoneId(String soneId) { + if (blockedSoneIds.add(soneId)) { + modificationCounter++; + } } /** @@ -417,8 +432,10 @@ public class Sone { * @param soneId * The Sone ID to unblock */ - public void removeBlockedSoneIds(String soneId) { - blockedSoneIds.remove(soneId); + public synchronized void removeBlockedSoneId(String soneId) { + if (blockedSoneIds.remove(soneId)) { + modificationCounter++; + } } /**