X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=3923f667d2e2b1ebebf987488d3cbf2cef271a82;hb=a88e930a23b550dae75116d7759924d760941776;hp=c3287c8835a476e97bb112e746a7b1bc3e0796e0;hpb=a47643aed43d118ca68044f95451bb5374cdb332;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 c3287c8..3923f66 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -33,7 +33,7 @@ import net.pterodactylus.sone.core.Options; import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.sone.template.SoneAccessor; -import net.pterodactylus.util.filter.Filter; +import net.pterodactylus.util.collection.filter.Filter; import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.validation.Validation; import freenet.keys.FreenetURI; @@ -175,6 +175,9 @@ public class Sone implements Fingerprintable, Comparable { /** The ID of this Sone. */ private final String id; + /** Whether the Sone is local. */ + private final boolean local; + /** The identity of this Sone. */ private Identity identity; @@ -229,9 +232,13 @@ public class Sone implements Fingerprintable, Comparable { * * @param id * The ID of the Sone + * @param local + * {@code true} if the Sone is a local Sone, {@code false} + * otherwise */ - public Sone(String id) { + public Sone(String id, boolean local) { this.id = id; + this.local = local; } // @@ -284,6 +291,16 @@ public class Sone implements Fingerprintable, Comparable { } /** + * Returns whether this Sone is a local Sone. + * + * @return {@code true} if this Sone is a local Sone, {@code false} + * otherwise + */ + public boolean isLocal() { + return local; + } + + /** * Returns the request URI of this Sone. * * @return The request URI of this Sone @@ -305,7 +322,7 @@ public class Sone implements Fingerprintable, Comparable { return this; } if (!this.requestUri.equalsKeypair(requestUri)) { - logger.log(Level.WARNING, "Request URI %s tried to overwrite %s!", new Object[] { requestUri, this.requestUri }); + logger.log(Level.WARNING, String.format("Request URI %s tried to overwrite %s!", requestUri, this.requestUri)); return this; } return this; @@ -333,7 +350,7 @@ public class Sone implements Fingerprintable, Comparable { return this; } if (!this.insertUri.equalsKeypair(insertUri)) { - logger.log(Level.WARNING, "Request URI %s tried to overwrite %s!", new Object[] { insertUri, this.insertUri }); + logger.log(Level.WARNING, String.format("Request URI %s tried to overwrite %s!", insertUri, this.insertUri)); return this; } return this; @@ -358,7 +375,7 @@ public class Sone implements Fingerprintable, Comparable { */ public void setLatestEdition(long latestEdition) { if (!(latestEdition > this.latestEdition)) { - logger.log(Level.FINE, "New latest edition %d is not greater than current latest edition %d!", new Object[] { latestEdition, this.latestEdition }); + logger.log(Level.FINE, String.format("New latest edition %d is not greater than current latest edition %d!", latestEdition, this.latestEdition)); return; } this.latestEdition = latestEdition; @@ -560,7 +577,7 @@ public class Sone implements Fingerprintable, Comparable { */ public void addPost(Post post) { if (post.getSone().equals(this) && posts.add(post)) { - logger.log(Level.FINEST, "Adding %s to “%s”.", new Object[] { post, getName() }); + logger.log(Level.FINEST, String.format("Adding %s to “%s”.", post, getName())); } } @@ -791,7 +808,9 @@ public class Sone implements Fingerprintable, Comparable { */ public void addAlbum(Album album) { Validation.begin().isNotNull("Album", album).check().isEqual("Album Owner", album.getSone(), this).check(); - albums.add(album); + if (!albums.contains(album)) { + albums.add(album); + } } /**