/** All replies. */
private Map<String, PostReply> replies = new HashMap<String, PostReply>();
- /** All new replies. */
- private Set<String> newReplies = new HashSet<String>();
-
/** All known replies. */
private Set<String> knownReplies = new HashSet<String>();
}
/**
- * Returns whether the reply with the given ID is new.
- *
- * @param replyId
- * The ID of the reply to check
- * @return {@code true} if the reply is considered to be new, {@code false}
- * otherwise
- */
- public boolean isNewReply(String replyId) {
- synchronized (newReplies) {
- return !knownReplies.contains(replyId) && newReplies.contains(replyId);
- }
- }
-
- /**
* Returns all Sones that have liked the given post.
*
* @param post
}
}
Set<PostReply> storedReplies = storedSone.getReplies();
- synchronized (newReplies) {
+ synchronized (knownReplies) {
for (PostReply reply : sone.getReplies()) {
reply.setSone(storedSone);
if (!storedReplies.contains(reply)) {
if (reply.getTime() < getSoneFollowingTime(sone)) {
+ reply.setKnown(true);
knownReplies.add(reply.getId());
} else if (!knownReplies.contains(reply.getId())) {
- newReplies.add(reply.getId());
coreListenerManager.fireNewReplyFound(reply);
+ } else {
+ reply.setKnown(true);
}
}
replies.put(reply.getId(), reply);
knownPosts.add(post.getId());
}
}
- synchronized (newReplies) {
+ synchronized (knownReplies) {
for (PostReply reply : replies) {
knownReplies.add(reply.getId());
}
synchronized (replies) {
replies.put(reply.getId(), reply);
}
- synchronized (newReplies) {
- newReplies.add(reply.getId());
+ synchronized (knownReplies) {
coreListenerManager.fireNewReplyFound(reply);
}
sone.addReply(reply);
synchronized (replies) {
replies.remove(reply.getId());
}
- synchronized (newReplies) {
+ synchronized (knownReplies) {
markReplyKnown(reply);
knownReplies.remove(reply.getId());
}
* The reply to mark as known
*/
public void markReplyKnown(PostReply reply) {
- synchronized (newReplies) {
- newReplies.remove(reply.getId());
+ reply.setKnown(true);
+ synchronized (knownReplies) {
if (knownReplies.add(reply.getId())) {
coreListenerManager.fireMarkReplyKnown(reply);
touchConfiguration();
/* save known replies. */
int replyCounter = 0;
- synchronized (newReplies) {
+ synchronized (knownReplies) {
for (String knownReplyId : knownReplies) {
configuration.getStringValue("KnownReplies/" + replyCounter++ + "/ID").setValue(knownReplyId);
}
if (knownReplyId == null) {
break;
}
- synchronized (newReplies) {
+ synchronized (knownReplies) {
knownReplies.add(knownReplyId);
}
}
}
}
synchronized (replies) {
- synchronized (newReplies) {
+ synchronized (knownReplies) {
for (PostReply reply : sone.getReplies()) {
replies.remove(reply.getId());
- newReplies.remove(reply.getId());
coreListenerManager.fireReplyRemoved(reply);
}
}
/** The text of the reply. */
private volatile String text;
+ /** Whether the reply is known. */
+ private volatile boolean known;
+
/**
* Creates a new reply with the given ID.
*
return (T) this;
}
+ /**
+ * Returns whether this reply is known.
+ *
+ * @return {@code true} if this reply is known, {@code false} otherwise
+ */
+ public boolean isKnown() {
+ return known;
+ }
+
+ /**
+ * Sets whether this reply is known.
+ *
+ * @param known
+ * {@code true} if this reply is known, {@code false} otherwise
+ * @return This reply
+ */
+ @SuppressWarnings("unchecked")
+ public T setKnown(boolean known) {
+ this.known = known;
+ return (T) this;
+ }
+
//
// OBJECT METHODS
//