projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'release-0.6.1'
[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
f183b39
..
2dd4bc1
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Sone.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Sone.java
@@
-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.
*
@@
-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
//