package net.pterodactylus.sone.data;
+import java.net.MalformedURLException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import freenet.keys.FreenetURI;
+import static java.lang.String.format;
+import static net.pterodactylus.sone.data.SoneKt.niceNameComparator;
+
/**
* A Sone defines everything about a user: her profile, her status updates, her
* replies, her likes and dislikes, etc.
* @return The request URI of this Sone
*/
@Nonnull
- FreenetURI getRequestUri();
+ default FreenetURI getRequestUri() {
+ try {
+ return new FreenetURI(getIdentity().getRequestUri())
+ .setKeyType("USK")
+ .setDocName("Sone")
+ .setMetaString(new String[0])
+ .setSuggestedEdition(getLatestEdition());
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException(
+ format("Identity %s's request URI is incorrect.",
+ getIdentity()), e);
+ }
+ }
/**
* Returns the latest edition of this Sone.
/* TODO - remove this method again, maybe add an option provider */
void setOptions(@Nonnull SoneOptions options);
+ @Override
+ default int compareTo(@Nonnull Sone sone) {
+ return niceNameComparator().compare(this, sone);
+ }
+
}
import net.pterodactylus.sone.data.SoneOptions;
import net.pterodactylus.sone.freenet.wot.Identity;
-import freenet.keys.FreenetURI;
-
import com.google.common.base.Objects;
/**
}
@Override
- public FreenetURI getRequestUri() {
- return null;
- }
-
- @Override
public long getLatestEdition() {
return 0;
}
}
@Override
- public int compareTo(Sone o) {
- return 0;
- }
-
- @Override
public String getFingerprint() {
return null;
}
package net.pterodactylus.sone.data.impl;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.logging.Logger.getLogger;
import static net.pterodactylus.sone.data.PostKt.newestPostFirst;
import static net.pterodactylus.sone.data.ReplyKt.newestReplyFirst;
-import static net.pterodactylus.sone.data.SoneKt.*;
-import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import net.pterodactylus.sone.database.Database;
import net.pterodactylus.sone.freenet.wot.Identity;
-import freenet.keys.FreenetURI;
-
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
}
/**
- * Returns the request URI of this Sone.
- *
- * @return The request URI of this Sone
- */
- @Nonnull
- public FreenetURI getRequestUri() {
- try {
- return new FreenetURI(getIdentity().getRequestUri())
- .setKeyType("USK")
- .setDocName("Sone")
- .setMetaString(new String[0])
- .setSuggestedEdition(latestEdition);
- } catch (MalformedURLException e) {
- throw new IllegalStateException(
- format("Identity %s's request URI is incorrect.",
- getIdentity()), e);
- }
- }
-
- /**
* Returns the latest edition of this Sone.
*
* @return The latest edition of this Sone
}
//
- // INTERFACE Comparable<Sone>
- //
-
- /** {@inheritDoc} */
- @Override
- public int compareTo(Sone sone) {
- return niceNameComparator().compare(this, sone);
- }
-
- //
// OBJECT METHODS
//