X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=836baa19d2bf560783cf305316f4334bdc63d014;hp=b761c7bca81b7b91223de629856450eafcd65804;hb=07d3fa7dac96e8a5eff41487d647974df8c26f8d;hpb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae
diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java
index b761c7b..836baa1 100644
--- a/src/main/java/net/pterodactylus/sone/data/Sone.java
+++ b/src/main/java/net/pterodactylus/sone/data/Sone.java
@@ -1,5 +1,5 @@
/*
- * 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
@@ -18,13 +18,11 @@
package net.pterodactylus.sone.data;
import static com.google.common.collect.FluentIterable.from;
-import static java.util.Arrays.asList;
import static net.pterodactylus.sone.data.Album.FLATTENER;
import static net.pterodactylus.sone.data.Album.IMAGES;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Set;
@@ -32,27 +30,19 @@ import javax.annotation.Nonnull;
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 David âBombeâ Roden
*/
public interface Sone extends Identified, Fingerprintable, Comparable {
/**
* Enumeration for the possible states of a {@link Sone}.
- *
- * @author David âBombeâ Roden
*/
public enum SoneStatus {
@@ -69,84 +59,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
downloading,
}
- /** comparator that sorts Sones by their nice name. */
- public static final Comparator NICE_NAME_COMPARATOR = new Comparator() {
-
- @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 LAST_ACTIVITY_COMPARATOR = new Comparator() {
-
- @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 POST_COUNT_COMPARATOR = new Comparator() {
-
- /**
- * {@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 IMAGE_COUNT_COMPARATOR = new Comparator() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compare(Sone leftSone, Sone rightSone) {
- int rightSoneImageCount = from(asList(rightSone.getRootAlbum())).transformAndConcat(FLATTENER).transformAndConcat(IMAGES).size();
- int leftSoneImageCount = from(asList(leftSone.getRootAlbum())).transformAndConcat(FLATTENER).transformAndConcat(IMAGES).size();
- /* sort descending. */
- return Ints.compare(rightSoneImageCount, leftSoneImageCount);
- }
- };
-
- /** Filter to remove Sones that have not been downloaded. */
- public static final Predicate EMPTY_SONE_FILTER = new Predicate() {
-
- @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 LOCAL_SONE_FILTER = new Predicate() {
-
- @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 HAS_ALBUM_FILTER = new Predicate() {
-
- @Override
- public boolean apply(Sone sone) {
- return (sone != null) && !sone.getRootAlbum().getAlbums().isEmpty();
- }
- };
-
public static final Function> toAllAlbums = new Function>() {
@Override
public List apply(@Nullable Sone sone) {
@@ -196,14 +108,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
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