From 8ee379b1ab5341d257637f6761aae852fabb859c Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 6 May 2011 11:20:21 +0200 Subject: Fix formatting and documentation in util package git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@169 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/util/Connection.java | 6 ++++++ src/jrummikub/util/Event.java | 44 +++++++++++++++++++------------------- src/jrummikub/util/Event1.java | 10 ++++----- src/jrummikub/util/Event2.java | 14 ++++++------ src/jrummikub/util/IEvent.java | 1 + src/jrummikub/util/IEvent1.java | 1 + src/jrummikub/util/IEvent2.java | 9 ++++---- 7 files changed, 47 insertions(+), 38 deletions(-) diff --git a/src/jrummikub/util/Connection.java b/src/jrummikub/util/Connection.java index b6a5a07..a14e747 100644 --- a/src/jrummikub/util/Connection.java +++ b/src/jrummikub/util/Connection.java @@ -1,5 +1,11 @@ package jrummikub.util; +/** + * A Connection object can be used to remove a listener from a event + */ public interface Connection { + /** + * Removes the listener + */ public void remove(); } diff --git a/src/jrummikub/util/Event.java b/src/jrummikub/util/Event.java index 491e10f..aa491da 100644 --- a/src/jrummikub/util/Event.java +++ b/src/jrummikub/util/Event.java @@ -4,29 +4,29 @@ import java.util.HashSet; /** Simple parameterless event generator */ public class Event implements IEvent { - private HashSet listeners = new HashSet(); + private HashSet listeners = new HashSet(); - @Override - public Connection add(final IListener listener) { - listeners.add(listener); - return new Connection() { - - @Override - public void remove() { - Event.this.remove(listener); - } - }; - } + @Override + public Connection add(final IListener listener) { + listeners.add(listener); + return new Connection() { + + @Override + public void remove() { + Event.this.remove(listener); + } + }; + } - @Override - public void remove(IListener listener) { - listeners.remove(listener); - } + @Override + public void remove(IListener listener) { + listeners.remove(listener); + } - /** Generate a single event */ - public void emit() { - for (IListener listener : listeners) { - listener.handle(); - } - } + /** Generate a single event */ + public void emit() { + for (IListener listener : listeners) { + listener.handle(); + } + } } diff --git a/src/jrummikub/util/Event1.java b/src/jrummikub/util/Event1.java index d721a7e..5e3391c 100644 --- a/src/jrummikub/util/Event1.java +++ b/src/jrummikub/util/Event1.java @@ -6,7 +6,7 @@ import java.util.HashSet; * Simple single parameter event generator * * @param - * type of the event parameter + * type of the event parameter */ public class Event1 implements IEvent1 { private HashSet> listeners = new HashSet>(); @@ -14,8 +14,8 @@ public class Event1 implements IEvent1 { @Override public Connection add(final IListener1 listener) { listeners.add(listener); - return new Connection() { - + return new Connection() { + @Override public void remove() { Event1.this.remove(listener); @@ -32,9 +32,9 @@ public class Event1 implements IEvent1 { * Generate a single event * * @param value - * the event parameter + * the event parameter */ - public void emit(T value) { + public void emit(T value) { for (IListener1 listener : listeners) { listener.handle(value); } diff --git a/src/jrummikub/util/Event2.java b/src/jrummikub/util/Event2.java index 7087975..9bcee43 100644 --- a/src/jrummikub/util/Event2.java +++ b/src/jrummikub/util/Event2.java @@ -6,9 +6,9 @@ import java.util.HashSet; * Simple single parameter event generator * * @param - * type of the first event parameter + * type of the first event parameter * @param - * type of the second event parameter + * type of the second event parameter */ public class Event2 implements IEvent2 { private HashSet> listeners = new HashSet>(); @@ -16,8 +16,8 @@ public class Event2 implements IEvent2 { @Override public Connection add(final IListener2 listener) { listeners.add(listener); - return new Connection() { - + return new Connection() { + @Override public void remove() { Event2.this.remove(listener); @@ -34,11 +34,11 @@ public class Event2 implements IEvent2 { * Generate a single event * * @param value1 - * the first event parameter + * the first event parameter * @param value2 - * the second event parameter + * the second event parameter */ - public void emit(T1 value1, T2 value2) { + public void emit(T1 value1, T2 value2) { for (IListener2 listener : listeners) { listener.handle(value1, value2); } diff --git a/src/jrummikub/util/IEvent.java b/src/jrummikub/util/IEvent.java index 52893f2..b8d418c 100644 --- a/src/jrummikub/util/IEvent.java +++ b/src/jrummikub/util/IEvent.java @@ -7,6 +7,7 @@ public interface IEvent { * * @param listener * target listener + * @return a connection to remove the listener */ public Connection add(IListener listener); diff --git a/src/jrummikub/util/IEvent1.java b/src/jrummikub/util/IEvent1.java index fa031b8..9508d05 100644 --- a/src/jrummikub/util/IEvent1.java +++ b/src/jrummikub/util/IEvent1.java @@ -12,6 +12,7 @@ public interface IEvent1 { * * @param listener * target listener + * @return a connection to remove the listener */ public Connection add(IListener1 listener); diff --git a/src/jrummikub/util/IEvent2.java b/src/jrummikub/util/IEvent2.java index 70bb3e6..8958cfa 100644 --- a/src/jrummikub/util/IEvent2.java +++ b/src/jrummikub/util/IEvent2.java @@ -4,16 +4,17 @@ package jrummikub.util; * Interface for classes that can generate events having a two parameters * * @param - * type of the first event parameter + * type of the first event parameter * @param - * type of the second event parameter + * type of the second event parameter */ public interface IEvent2 { /** * Start to publish all events to a given listener * * @param listener - * target listener + * target listener + * @return a connection to remove the listener */ public Connection add(IListener2 listener); @@ -21,7 +22,7 @@ public interface IEvent2 { * Stop publishing events to a given listener * * @param listener - * target listener + * target listener */ public void remove(IListener2 listener); } -- cgit v1.2.3