- * The possible values for the āshow custom avatarsā option.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David āBombeā Roden</a>
- */
- public static enum ShowCustomAvatars {
-
- /** Never show custom avatars. */
- NEVER,
-
- /** Only show custom avatars of followed Sones. */
- FOLLOWED,
-
- /** Only show custom avatars of Sones you manually trust. */
- MANUALLY_TRUSTED,
-
- /** Only show custom avatars of automatically trusted Sones. */
- TRUSTED,
-
- /** Always show custom avatars. */
- ALWAYS,
-
- }
-
- /** comparator that sorts Sones by their nice name. */
- public static final Comparator<Sone> NICE_NAME_COMPARATOR = new Comparator<Sone>() {
-
- @Override
- public int compare(Sone leftSone, Sone rightSone) {
- int diff = SoneAccessor.getNiceName(leftSone).compareToIgnoreCase(SoneAccessor.getNiceName(rightSone));
- if (diff != 0) {
- return diff;
- }
- return leftSone.getId().compareToIgnoreCase(rightSone.getId());
- }
-
- };
-
- /**
- * Comparator that sorts Sones by last activity (least recent active first).
- */
- public static final Comparator<Sone> LAST_ACTIVITY_COMPARATOR = new Comparator<Sone>() {
-
- @Override
- public int compare(Sone firstSone, Sone secondSone) {
- return (int) Math.min(Integer.MAX_VALUE, Math.max(Integer.MIN_VALUE, secondSone.getTime() - firstSone.getTime()));
- }
- };
-
- /** Comparator that sorts Sones by numbers of posts (descending). */
- public static final Comparator<Sone> POST_COUNT_COMPARATOR = new Comparator<Sone>() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compare(Sone leftSone, Sone rightSone) {
- return (leftSone.getPosts().size() != rightSone.getPosts().size()) ? (rightSone.getPosts().size() - leftSone.getPosts().size()) : (rightSone.getReplies().size() - leftSone.getReplies().size());
- }
- };
-
- /** Comparator that sorts Sones by number of images (descending). */
- public static final Comparator<Sone> IMAGE_COUNT_COMPARATOR = new Comparator<Sone>() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compare(Sone leftSone, Sone rightSone) {
- return rightSone.getAllImages().size() - leftSone.getAllImages().size();
- }
- };
-
- /** 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;
- }
- };
-
- /** Filter that matches all {@link Core#isLocalSone(Sone) local Sones}. */
- public static final Filter<Sone> LOCAL_SONE_FILTER = new Filter<Sone>() {
-
- @Override
- public boolean filterObject(Sone sone) {
- return sone.getIdentity() instanceof OwnIdentity;
- }
-
- };
-
- /** Filter that matches Sones that have at least one album. */
- public static final Filter<Sone> HAS_ALBUM_FILTER = new Filter<Sone>() {
-
- @Override
- public boolean filterObject(Sone sone) {
- return !sone.getAlbums().isEmpty();
- }
- };
-
- /** The logger. */
- private static final Logger logger = Logging.getLogger(Sone.class);
-
- /** The ID of this Sone. */
- private final String id;
-
- /** The identity of this Sone. */
- private Identity identity;
-
- /** The URI under which the Sone is stored in Freenet. */
- private volatile FreenetURI requestUri;
-
- /** The URI used to insert a new version of this Sone. */
- /* This will be null for remote Sones! */
- private volatile FreenetURI insertUri;
-
- /** The latest edition of the Sone. */
- private volatile long latestEdition;
-
- /** The time of the last inserted update. */
- private volatile long time;
-
- /** The status of this Sone. */
- private volatile SoneStatus status = SoneStatus.unknown;
-
- /** The profile of this Sone. */
- private volatile Profile profile = new Profile(this);
-
- /** The client used by the Sone. */
- private volatile Client client;
-
- /** Whether this Sone is known. */
- private volatile boolean known;
-
- /** All friend Sones. */
- private final Set<String> friendSones = new CopyOnWriteArraySet<String>();
-
- /** All posts. */
- private final Set<Post> posts = new CopyOnWriteArraySet<Post>();
-
- /** All replies. */
- private final Set<PostReply> replies = new CopyOnWriteArraySet<PostReply>();
-
- /** The IDs of all liked posts. */
- private final Set<String> likedPostIds = new CopyOnWriteArraySet<String>();
-
- /** The IDs of all liked replies. */
- private final Set<String> likedReplyIds = new CopyOnWriteArraySet<String>();
-
- /** The albums of this Sone. */
- private final List<Album> albums = new CopyOnWriteArrayList<Album>();
-
- /** Sone-specific options. */
- private final Options options = new Options();
-
- /**
- * Creates a new Sone.
- *
- * @param id
- * The ID of the Sone
- */
- public Sone(String id) {
- this.id = id;
- }
-
- //
- // ACCESSORS
- //
-
- /**
- * Returns the identity of this Sone.
- *
- * @return The identity of this Sone
- */
- public String getId() {
- return id;
- }
-
- /**