/*
- * Sone - SoneImpl.java - Copyright © 2010–2016 David Roden
+ * Sone - SoneImpl.java - Copyright © 2010–2019 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
* {@link Sone} implementation.
* <p/>
* Operations that modify the Sone need to synchronize on the Sone in question.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class SoneImpl implements Sone {
private volatile boolean known;
/** All posts. */
- private final Set<Post> posts = new CopyOnWriteArraySet<Post>();
+ private final Set<Post> posts = new CopyOnWriteArraySet<>();
/** All replies. */
- private final Set<PostReply> replies = new CopyOnWriteArraySet<PostReply>();
+ private final Set<PostReply> replies = new CopyOnWriteArraySet<>();
/** The IDs of all liked posts. */
- private final Set<String> likedPostIds = new CopyOnWriteArraySet<String>();
+ private final Set<String> likedPostIds = new CopyOnWriteArraySet<>();
/** The IDs of all liked replies. */
- private final Set<String> likedReplyIds = new CopyOnWriteArraySet<String>();
+ private final Set<String> likedReplyIds = new CopyOnWriteArraySet<>();
/** The root album containing all albums. */
private final Album rootAlbum = new AlbumImpl(this);
public List<Post> getPosts() {
List<Post> sortedPosts;
synchronized (this) {
- sortedPosts = new ArrayList<Post>(posts);
+ sortedPosts = new ArrayList<>(posts);
}
Collections.sort(sortedPosts, Post.NEWEST_FIRST);
return sortedPosts;
*
* @param postId
* The ID of the post
- * @return This Sone (for method chaining)
*/
- @Nonnull
- public Sone removeLikedPostId(@Nonnull String postId) {
+ public void removeLikedPostId(@Nonnull String postId) {
likedPostIds.remove(postId);
- return this;
}
/**
*
* @param replyId
* The ID of the reply
- * @return This Sone (for method chaining)
*/
- @Nonnull
- public Sone removeLikedReplyId(@Nonnull String replyId) {
+ public void removeLikedReplyId(@Nonnull String replyId) {
likedReplyIds.remove(replyId);
- return this;
}
/**
}
hash.putString(")");
- List<PostReply> replies = new ArrayList<PostReply>(getReplies());
+ List<PostReply> replies = new ArrayList<>(getReplies());
Collections.sort(replies, Reply.TIME_COMPARATOR);
hash.putString("Replies(");
for (PostReply reply : replies) {
}
hash.putString(")");
- List<String> likedPostIds = new ArrayList<String>(getLikedPostIds());
+ List<String> likedPostIds = new ArrayList<>(getLikedPostIds());
Collections.sort(likedPostIds);
hash.putString("LikedPosts(");
for (String likedPostId : likedPostIds) {
}
hash.putString(")");
- List<String> likedReplyIds = new ArrayList<String>(getLikedReplyIds());
+ List<String> likedReplyIds = new ArrayList<>(getLikedReplyIds());
Collections.sort(likedReplyIds);
hash.putString("LikedReplies(");
for (String likedReplyId : likedReplyIds) {