+ public Sone addLikedPostId(String postId) {
+ likedPostIds.add(postId);
+ return this;
+ }
+
+ /**
+ * Removes the given post ID from the list of posts this Sone likes.
+ *
+ * @param postId
+ * The ID of the post
+ * @return This Sone (for method chaining)
+ */
+ public Sone removeLikedPostId(String postId) {
+ likedPostIds.remove(postId);
+ return this;
+ }
+
+ /**
+ * Returns the IDs of all liked replies.
+ *
+ * @return All liked replies’ IDs
+ */
+ public Set<String> getLikedReplyIds() {
+ return Collections.unmodifiableSet(likedReplyIds);
+ }
+
+ /**
+ * Sets the IDs of all liked replies.
+ *
+ * @param likedReplyIds
+ * All liked replies’ IDs
+ * @return This Sone (for method chaining)
+ */
+ public Sone setLikeReplyIds(Set<String> likedReplyIds) {
+ this.likedReplyIds.clear();
+ this.likedReplyIds.addAll(likedReplyIds);
+ return this;
+ }
+
+ /**
+ * Checks whether the given reply ID is liked by this Sone.
+ *
+ * @param replyId
+ * The ID of the reply
+ * @return {@code true} if this Sone likes the given reply, {@code false}
+ * otherwise
+ */
+ public boolean isLikedReplyId(String replyId) {
+ return likedReplyIds.contains(replyId);
+ }
+
+ /**
+ * Adds the given reply ID to the list of replies this Sone likes.
+ *
+ * @param replyId
+ * The ID of the reply
+ * @return This Sone (for method chaining)
+ */
+ public Sone addLikedReplyId(String replyId) {
+ likedReplyIds.add(replyId);
+ return this;
+ }
+
+ /**
+ * Removes the given post ID from the list of replies this Sone likes.
+ *
+ * @param replyId
+ * The ID of the reply
+ * @return This Sone (for method chaining)
+ */
+ public Sone removeLikedReplyId(String replyId) {
+ likedReplyIds.remove(replyId);
+ return this;
+ }
+
+ /**
+ * Returns the root album that contains all visible albums of this Sone.
+ *
+ * @return The root album of this Sone
+ */
+ public Album getRootAlbum() {
+ return rootAlbum;
+ }
+
+ /**
+ * Returns Sone-specific options.
+ *
+ * @return The options of this Sone
+ */
+ public Options getOptions() {
+ return options;
+ }
+
+ /**
+ * Sets the options of this Sone.
+ *
+ * @param options
+ * The options of this Sone
+ */
+ /* TODO - remove this method again, maybe add an option provider */
+ public void setOptions(Options options) {
+ this.options = options;
+ }
+
+ //
+ // FINGERPRINTABLE METHODS
+ //
+
+ /** {@inheritDoc} */
+ @Override
+ public synchronized String getFingerprint() {
+ Hasher hash = Hashing.sha256().newHasher();
+ hash.putString(profile.getFingerprint());
+
+ hash.putString("Posts(");
+ for (Post post : getPosts()) {
+ hash.putString("Post(").putString(post.getId()).putString(")");
+ }
+ hash.putString(")");
+
+ List<PostReply> replies = new ArrayList<PostReply>(getReplies());
+ Collections.sort(replies, Reply.TIME_COMPARATOR);
+ hash.putString("Replies(");
+ for (PostReply reply : replies) {
+ hash.putString("Reply(").putString(reply.getId()).putString(")");
+ }
+ hash.putString(")");
+
+ List<String> likedPostIds = new ArrayList<String>(getLikedPostIds());
+ Collections.sort(likedPostIds);
+ hash.putString("LikedPosts(");
+ for (String likedPostId : likedPostIds) {
+ hash.putString("Post(").putString(likedPostId).putString(")");
+ }
+ hash.putString(")");
+
+ List<String> likedReplyIds = new ArrayList<String>(getLikedReplyIds());
+ Collections.sort(likedReplyIds);
+ hash.putString("LikedReplies(");
+ for (String likedReplyId : likedReplyIds) {
+ hash.putString("Reply(").putString(likedReplyId).putString(")");
+ }
+ hash.putString(")");
+
+ hash.putString("Albums(");
+ for (Album album : rootAlbum.getAlbums()) {
+ if (!Album.NOT_EMPTY.apply(album)) {
+ continue;
+ }
+ hash.putString(album.getFingerprint());
+ }
+ hash.putString(")");
+
+ return hash.hash().toString();
+ }
+
+ //
+ // INTERFACE Comparable<Sone>
+ //
+
+ /** {@inheritDoc} */
+ @Override
+ public int compareTo(Sone sone) {
+ return NICE_NAME_COMPARATOR.compare(this, sone);