From 5917f88a029c16c907616a991327d2e16ed5020b Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Thu, 5 May 2011 19:56:46 +0200 Subject: Fixed MockEvents git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@152 72836036-5685-4462-b002-a69064685172 --- mock/jrummikub/util/MockEvent.java | 9 ++++++++- mock/jrummikub/util/MockEvent1.java | 9 ++++++++- mock/jrummikub/util/MockEvent2.java | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'mock') diff --git a/mock/jrummikub/util/MockEvent.java b/mock/jrummikub/util/MockEvent.java index 2f0efe5..65aec9d 100644 --- a/mock/jrummikub/util/MockEvent.java +++ b/mock/jrummikub/util/MockEvent.java @@ -6,8 +6,15 @@ public class MockEvent implements IEvent { public HashSet listeners = new HashSet(); @Override - public void add(IListener listener) { + public Connection add(final IListener listener) { listeners.add(listener); + return new Connection() { + + @Override + public void remove() { + MockEvent.this.remove(listener); + } + }; } @Override diff --git a/mock/jrummikub/util/MockEvent1.java b/mock/jrummikub/util/MockEvent1.java index 74cae0f..94b0257 100644 --- a/mock/jrummikub/util/MockEvent1.java +++ b/mock/jrummikub/util/MockEvent1.java @@ -6,8 +6,15 @@ public class MockEvent1 implements IEvent1 { public HashSet> listeners = new HashSet>(); @Override - public void add(IListener1 listener) { + public Connection add(final IListener1 listener) { listeners.add(listener); + return new Connection() { + + @Override + public void remove() { + MockEvent1.this.remove(listener); + } + }; } @Override diff --git a/mock/jrummikub/util/MockEvent2.java b/mock/jrummikub/util/MockEvent2.java index 93e8228..5aa7b59 100644 --- a/mock/jrummikub/util/MockEvent2.java +++ b/mock/jrummikub/util/MockEvent2.java @@ -6,8 +6,15 @@ public class MockEvent2 implements IEvent2 { public HashSet> listeners = new HashSet>(); @Override - public void add(IListener2 listener) { + public Connection add(final IListener2 listener) { listeners.add(listener); + return new Connection() { + + @Override + public void remove() { + MockEvent2.this.remove(listener); + } + }; } @Override -- cgit v1.2.3