- // PACKAGE-PRIVATE METHODS
- //
-
- /**
- * Returns whether the given post is known.
- *
- * @param post
- * The post
- * @return {@code true} if the post is known, {@code false} otherwise
- */
- boolean isPostKnown(Post post) {
- lock.readLock().lock();
- try {
- return knownPosts.contains(post.getId());
- } finally {
- lock.readLock().unlock();
- }
- }
-
- /**
- * Sets whether the given post is known.
- *
- * @param post
- * The post
- * @param known
- * {@code true} if the post is known, {@code false} otherwise
- */
- void setPostKnown(Post post, boolean known) {
- lock.writeLock().lock();
- try {
- if (known) {
- knownPosts.add(post.getId());
- } else {
- knownPosts.remove(post.getId());
- }
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- /**
- * Returns whether the given post reply is known.
- *
- * @param postReply
- * The post reply
- * @return {@code true} if the given post reply is known, {@code false}
- * otherwise
- */
- boolean isPostReplyKnown(PostReply postReply) {
- lock.readLock().lock();
- try {
- return knownPostReplies.contains(postReply.getId());
- } finally {
- lock.readLock().unlock();
- }
- }
-
- /**
- * Sets whether the given post reply is known.
- *
- * @param postReply
- * The post reply
- * @param known
- * {@code true} if the post reply is known, {@code false} otherwise
- */
- void setPostReplyKnown(PostReply postReply, boolean known) {
- lock.writeLock().lock();
- try {
- if (known) {
- knownPostReplies.add(postReply.getId());
- } else {
- knownPostReplies.remove(postReply.getId());
- }
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- void moveUp(Album album) {
- lock.writeLock().lock();
- try {
- List<String> albums = albumChildren.get(album.getParent().getId());
- int currentIndex = albums.indexOf(album.getId());
- if (currentIndex == 0) {
- return;
- }
- albums.remove(album.getId());
- albums.add(currentIndex - 1, album.getId());
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- void moveDown(Album album) {
- lock.writeLock().lock();
- try {
- List<String> albums = albumChildren.get(album.getParent().getId());
- int currentIndex = albums.indexOf(album.getId());
- if (currentIndex == (albums.size() - 1)) {
- return;
- }
- albums.remove(album.getId());
- albums.add(currentIndex + 1, album.getId());
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- //