From: David ‘Bombe’ Roden Date: Wed, 12 Nov 2008 23:43:13 +0000 (+0100) Subject: Split ListenerSupport into two classes. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f79ff58f9d4adc684cb9c54d975636f5cb35db2f;p=jSite2.git Split ListenerSupport into two classes. Extend InsertListenerSupport from new basic ListenerSupport (because there are no fixes sources). --- diff --git a/src/net/pterodactylus/jsite/core/InsertListenerSupport.java b/src/net/pterodactylus/jsite/core/InsertListenerSupport.java index 52ce219..3a6ce69 100644 --- a/src/net/pterodactylus/jsite/core/InsertListenerSupport.java +++ b/src/net/pterodactylus/jsite/core/InsertListenerSupport.java @@ -26,26 +26,18 @@ import net.pterodactylus.util.event.ListenerSupport; * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ -public class InsertListenerSupport extends ListenerSupport { - - /** - * Creates a new insert listener support. - * - * @param insert - * The source insert - */ - public InsertListenerSupport(Insert insert) { - super(insert); - } +public class InsertListenerSupport extends ListenerSupport { /** * Notifies all listeners that the insert was added. * * @see InsertListener#insertAdded(Insert) + * @param insert + * The insert that was added */ - public void fireInsertAdded() { + public void fireInsertAdded(Insert insert) { for (InsertListener insertListener : getListeners()) { - insertListener.insertAdded(getSource()); + insertListener.insertAdded(insert); } } @@ -53,10 +45,12 @@ public class InsertListenerSupport extends ListenerSupport + * The type of the source + * @param + * The type of the listeners + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + */ +public class FixedSourceListenerSupport extends ListenerSupport { + + /** The source of the events. */ + private final S source; + + /** + * Creates a new listener support. + * + * @param source + * The source of all events + */ + public FixedSourceListenerSupport(S source) { + this.source = source; + } + + /** + * Returns the source of all events. + * + * @return The source of all events + */ + protected S getSource() { + return source; + } + +} diff --git a/src/net/pterodactylus/util/event/ListenerSupport.java b/src/net/pterodactylus/util/event/ListenerSupport.java index 1b11296..a339d27 100644 --- a/src/net/pterodactylus/util/event/ListenerSupport.java +++ b/src/net/pterodactylus/util/event/ListenerSupport.java @@ -20,36 +20,22 @@ package net.pterodactylus.util.event; import java.util.ArrayList; +import java.util.EventListener; import java.util.List; /** - * Helper class to ease listener management. + * Helper class for {@link EventListener} management. * - * @param - * The type of the source * @param - * The type of the listeners - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + * The type of the event listener + * @author David Roden <droden@gmail.com> */ -public class ListenerSupport { - - /** The source of the events. */ - private final S source; +public class ListenerSupport { /** The list of registered listeners. */ private final List listeners = new ArrayList(); /** - * Creates a new listener support. - * - * @param source - * The source of all events - */ - public ListenerSupport(S source) { - this.source = source; - } - - /** * Adds a listener to the list of registered listeners. * * @param listener @@ -73,23 +59,11 @@ public class ListenerSupport { } } - // - // PROTECTED METHODS - // - - /** - * Returns the source of all events. - * - * @return The source of all events - */ - protected S getSource() { - return source; - } - /** * Returns a list of all listeners. This list is a copy of the internally * kept list and as thus will not be modified by calls to - * {@link #addListener(Object)} or {@link #removeListener(Object)}. + * {@link #addListener(EventListener)} or + * {@link #removeListener(EventListener)}. * * @return The list of all listeners */ @@ -99,4 +73,6 @@ public class ListenerSupport { } } + /* TODO */ + }