/*
- * Sone - Sone.java - Copyright © 2010–2016 David Roden
+ * Sone - Sone.java - Copyright © 2010–2020 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
import javax.annotation.Nullable;
import net.pterodactylus.sone.freenet.wot.Identity;
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-import net.pterodactylus.sone.template.SoneAccessor;
import freenet.keys.FreenetURI;
import com.google.common.base.Function;
-import com.google.common.base.Predicate;
import com.google.common.primitives.Ints;
/**
* A Sone defines everything about a user: her profile, her status updates, her
* replies, her likes and dislikes, etc.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
/**
* Enumeration for the possible states of a {@link Sone}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public enum SoneStatus {
downloading,
}
- /** 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>() {
}
};
- /** Filter to remove Sones that have not been downloaded. */
- public static final Predicate<Sone> EMPTY_SONE_FILTER = new Predicate<Sone>() {
-
- @Override
- public boolean apply(Sone sone) {
- return (sone != null) && (sone.getTime() != 0);
- }
- };
-
- /** Filter that matches all {@link Sone#isLocal() local Sones}. */
- public static final Predicate<Sone> LOCAL_SONE_FILTER = new Predicate<Sone>() {
-
- @Override
- public boolean apply(Sone sone) {
- return (sone != null) && (sone.getIdentity() instanceof OwnIdentity);
- }
-
- };
-
- /** Filter that matches Sones that have at least one album. */
- public static final Predicate<Sone> HAS_ALBUM_FILTER = new Predicate<Sone>() {
-
- @Override
- public boolean apply(Sone sone) {
- return (sone != null) && !sone.getRootAlbum().getAlbums().isEmpty();
- }
- };
-
public static final Function<Sone, List<Album>> toAllAlbums = new Function<Sone, List<Album>>() {
@Override
public List<Album> apply(@Nullable Sone sone) {
FreenetURI getRequestUri();
/**
- * Returns the insert URI of this Sone.
- *
- * @return The insert URI of this Sone
- */
- @Nullable
- FreenetURI getInsertUri();
-
- /**
* Returns the latest edition of this Sone.
*
* @return The latest edition of this Sone