X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FListNotification.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FListNotification.java;h=2217b70f75939f2782784336841d8b49d0e87a55;hb=5dfc6973e3f089ddc33327ad42fe25142150c206;hp=2f43c582c41231d16ec318e88a5ccc0de5898a70;hpb=b001ba1e23a469561e4e313d77dd18a5c284732b;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotification.java b/src/main/java/net/pterodactylus/sone/notify/ListNotification.java index 2f43c58..2217b70 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotification.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotification.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.notify; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -33,6 +34,9 @@ import net.pterodactylus.util.template.Template; */ public class ListNotification extends TemplateNotification { + /** The key under which to store the elements in the template. */ + private final String key; + /** The list of new elements. */ private final List elements = new CopyOnWriteArrayList(); @@ -48,9 +52,24 @@ public class ListNotification extends TemplateNotification { */ public ListNotification(String id, String key, Template template) { super(id, template); + this.key = key; template.getInitialContext().set(key, elements); } + /** + * Creates a new list notification that copies its ID and the template from + * the given list notification. + * + * @param listNotification + * The list notification to copy + */ + public ListNotification(ListNotification listNotification) { + super(listNotification.getId(), new Template()); + this.key = listNotification.key; + getTemplate().add(listNotification.getTemplate()); + getTemplate().getInitialContext().set(key, elements); + } + // // ACTIONS //