X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FNewReplyNotification.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FNewReplyNotification.java;h=1b33245b405a1cb29861b293235ad25d88fef8a8;hb=06ed021f1232830b8617efdb4c2d26684a18b643;hp=0000000000000000000000000000000000000000;hpb=e02217de335935a40c4d41df7fdc162d5222c718;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/notify/NewReplyNotification.java b/src/main/java/net/pterodactylus/sone/notify/NewReplyNotification.java
new file mode 100644
index 0000000..1b33245
--- /dev/null
+++ b/src/main/java/net/pterodactylus/sone/notify/NewReplyNotification.java
@@ -0,0 +1,98 @@
+/*
+ * Sone - NewReplyNotification.java - Copyright © 2010 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.pterodactylus.sone.notify;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.pterodactylus.sone.data.Reply;
+import net.pterodactylus.util.notify.TemplateNotification;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * Notification that signals that new {@link Reply}s have been discovered.
+ *
+ * @author David âBombeâ Roden
+ */
+public class NewReplyNotification extends TemplateNotification {
+
+ /** The new replies. */
+ private final List newReplies = Collections.synchronizedList(new ArrayList());
+
+ /**
+ * Creates a ânew replyâ notification.
+ *
+ * @param template
+ * The template to render
+ */
+ public NewReplyNotification(Template template) {
+ super(template);
+ template.set("replies", newReplies);
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns whether there are any new replies.
+ *
+ * @return {@code true} if there are no new replies, {@code false} if there
+ * are new replies
+ */
+ public boolean isEmpty() {
+ return newReplies.isEmpty();
+ }
+
+ /**
+ * Adds a discovered reply.
+ *
+ * @param reply
+ * The new reply
+ */
+ public void addReply(Reply reply) {
+ newReplies.add(reply);
+ touch();
+ }
+
+ /**
+ * Removes the given reply from the list of new replies.
+ *
+ * @param reply
+ * The reply to remove
+ */
+ public void removeReply(Reply reply) {
+ newReplies.remove(reply);
+ touch();
+ }
+
+ //
+ // ABSTRACTNOTIFICATION METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void dismiss() {
+ super.dismiss();
+ newReplies.clear();
+ }
+
+}