summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-06 11:20:21 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-06 11:20:21 +0200
commit8ee379b1ab5341d257637f6761aae852fabb859c (patch)
tree180c0b22313ad028811e312ebd251d24f85fb69b
parent4390c766303610c3a20b158d54d1c5bef64475a6 (diff)
downloadJRummikub-8ee379b1ab5341d257637f6761aae852fabb859c.tar
JRummikub-8ee379b1ab5341d257637f6761aae852fabb859c.zip
Fix formatting and documentation in util package
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@169 72836036-5685-4462-b002-a69064685172
-rw-r--r--src/jrummikub/util/Connection.java6
-rw-r--r--src/jrummikub/util/Event.java44
-rw-r--r--src/jrummikub/util/Event1.java10
-rw-r--r--src/jrummikub/util/Event2.java14
-rw-r--r--src/jrummikub/util/IEvent.java1
-rw-r--r--src/jrummikub/util/IEvent1.java1
-rw-r--r--src/jrummikub/util/IEvent2.java9
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<IListener> listeners = new HashSet<IListener>();
+ private HashSet<IListener> listeners = new HashSet<IListener>();
- @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 <T>
- * type of the event parameter
+ * type of the event parameter
*/
public class Event1<T> implements IEvent1<T> {
private HashSet<IListener1<T>> listeners = new HashSet<IListener1<T>>();
@@ -14,8 +14,8 @@ public class Event1<T> implements IEvent1<T> {
@Override
public Connection add(final IListener1<T> 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<T> implements IEvent1<T> {
* Generate a single event
*
* @param value
- * the event parameter
+ * the event parameter
*/
- public void emit(T value) {
+ public void emit(T value) {
for (IListener1<T> 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 <T1>
- * type of the first event parameter
+ * type of the first event parameter
* @param <T2>
- * type of the second event parameter
+ * type of the second event parameter
*/
public class Event2<T1, T2> implements IEvent2<T1, T2> {
private HashSet<IListener2<T1, T2>> listeners = new HashSet<IListener2<T1, T2>>();
@@ -16,8 +16,8 @@ public class Event2<T1, T2> implements IEvent2<T1, T2> {
@Override
public Connection add(final IListener2<T1, T2> 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<T1, T2> implements IEvent2<T1, T2> {
* 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<T1, T2> 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<T> {
*
* @param listener
* target listener
+ * @return a connection to remove the listener
*/
public Connection add(IListener1<T> 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 <T1>
- * type of the first event parameter
+ * type of the first event parameter
* @param <T2>
- * type of the second event parameter
+ * type of the second event parameter
*/
public interface IEvent2<T1, T2> {
/**
* 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<T1, T2> listener);
@@ -21,7 +22,7 @@ public interface IEvent2<T1, T2> {
* Stop publishing events to a given listener
*
* @param listener
- * target listener
+ * target listener
*/
public void remove(IListener2<T1, T2> listener);
}