projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'fcp-interface' into next
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
data
/
Sone.java
diff --git
a/src/main/java/net/pterodactylus/sone/data/Sone.java
b/src/main/java/net/pterodactylus/sone/data/Sone.java
index
03dff75
..
715d95b
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Sone.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Sone.java
@@
-1,5
+1,5
@@
/*
/*
- *
Freenet
Sone - Sone.java - Copyright © 2010 David Roden
+ * Sone - Sone.java - Copyright © 2010 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-27,8
+27,10
@@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.pterodactylus.sone.core.Options;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.template.SoneAccessor;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.template.SoneAccessor;
+import net.pterodactylus.util.filter.Filter;
import net.pterodactylus.util.logging.Logging;
import freenet.keys.FreenetURI;
import net.pterodactylus.util.logging.Logging;
import freenet.keys.FreenetURI;
@@
-40,7
+42,7
@@
import freenet.keys.FreenetURI;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class Sone implements Fingerprintable {
+public class Sone implements Fingerprintable
, Comparable<Sone>
{
/** comparator that sorts Sones by their nice name. */
public static final Comparator<Sone> NICE_NAME_COMPARATOR = new Comparator<Sone>() {
/** comparator that sorts Sones by their nice name. */
public static final Comparator<Sone> NICE_NAME_COMPARATOR = new Comparator<Sone>() {
@@
-56,6
+58,15
@@
public class Sone implements Fingerprintable {
};
};
+ /** Filter to remove Sones that have not been downloaded. */
+ public static final Filter<Sone> EMPTY_SONE_FILTER = new Filter<Sone>() {
+
+ @Override
+ public boolean filterObject(Sone sone) {
+ return sone.getTime() != 0;
+ }
+ };
+
/** The logger. */
private static final Logger logger = Logging.getLogger(Sone.class);
/** The logger. */
private static final Logger logger = Logging.getLogger(Sone.class);
@@
-99,6
+110,9
@@
public class Sone implements Fingerprintable {
/** The IDs of all liked replies. */
private final Set<String> likedReplyIds = Collections.synchronizedSet(new HashSet<String>());
/** The IDs of all liked replies. */
private final Set<String> likedReplyIds = Collections.synchronizedSet(new HashSet<String>());
+ /** Sone-specific options. */
+ private final Options options = new Options();
+
/**
* Creates a new Sone.
*
/**
* Creates a new Sone.
*
@@
-176,7
+190,7
@@
public class Sone implements Fingerprintable {
*/
public Sone setRequestUri(FreenetURI requestUri) {
if (this.requestUri == null) {
*/
public Sone setRequestUri(FreenetURI requestUri) {
if (this.requestUri == null) {
- this.requestUri = requestUri.setDocName("Sone").setMetaString(new String[0]);
+ this.requestUri = requestUri.set
KeyType("USK").set
DocName("Sone").setMetaString(new String[0]);
return this;
}
if (!this.requestUri.equalsKeypair(requestUri)) {
return this;
}
if (!this.requestUri.equalsKeypair(requestUri)) {
@@
-204,7
+218,7
@@
public class Sone implements Fingerprintable {
*/
public Sone setInsertUri(FreenetURI insertUri) {
if (this.insertUri == null) {
*/
public Sone setInsertUri(FreenetURI insertUri) {
if (this.insertUri == null) {
- this.insertUri = insertUri.setDocName("Sone").setMetaString(new String[0]);
+ this.insertUri = insertUri.set
KeyType("USK").set
DocName("Sone").setMetaString(new String[0]);
return this;
}
if (!this.insertUri.equalsKeypair(insertUri)) {
return this;
}
if (!this.insertUri.equalsKeypair(insertUri)) {
@@
-387,8
+401,10
@@
public class Sone implements Fingerprintable {
* @return This Sone (for method chaining)
*/
public synchronized Sone setPosts(Collection<Post> posts) {
* @return This Sone (for method chaining)
*/
public synchronized Sone setPosts(Collection<Post> posts) {
- this.posts.clear();
- this.posts.addAll(posts);
+ synchronized (this) {
+ this.posts.clear();
+ this.posts.addAll(posts);
+ }
return this;
}
return this;
}
@@
-580,6
+596,15
@@
public class Sone implements Fingerprintable {
return this;
}
return this;
}
+ /**
+ * Returns Sone-specific options.
+ *
+ * @return The options of this Sone
+ */
+ public Options getOptions() {
+ return options;
+ }
+
//
// FINGERPRINTABLE METHODS
//
//
// FINGERPRINTABLE METHODS
//
@@
-626,6
+651,18
@@
public class Sone implements Fingerprintable {
}
//
}
//
+ // INTERFACE Comparable<Sone>
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(Sone sone) {
+ return NICE_NAME_COMPARATOR.compare(this, sone);
+ }
+
+ //
// OBJECT METHODS
//
// OBJECT METHODS
//