From 458c4d7e7fe7e7557bfd187f8f20c142347e0257 Mon Sep 17 00:00:00 2001 From: Christian Wulf Date: Sat, 9 May 2015 23:47:52 +0200 Subject: [PATCH] refactored Merger --- .../teetime/stage/basic/merger/Merger.java | 36 ++----------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/main/java/teetime/stage/basic/merger/Merger.java b/src/main/java/teetime/stage/basic/merger/Merger.java index 4bf4ef57..3a4672ca 100644 --- a/src/main/java/teetime/stage/basic/merger/Merger.java +++ b/src/main/java/teetime/stage/basic/merger/Merger.java @@ -40,11 +40,10 @@ public final class Merger extends AbstractStage { private final OutputPort outputPort = this.createOutputPort(); + private final Map, Set>> signalMap = new HashMap, Set>>(); private IMergerStrategy strategy; - private final Map, Set>> signalMap = new HashMap, Set>>(); - public Merger() { this(new RoundRobinStrategy()); } @@ -73,7 +72,6 @@ public void executeStage() { * @param inputPort * The port which the signal was sent to */ - @SuppressWarnings("unchecked") @Override public void onSignal(final ISignal signal, final InputPort inputPort) { if (logger.isTraceEnabled()) { @@ -87,7 +85,7 @@ public void onSignal(final ISignal signal, final InputPort inputPort) { inputPorts = signalMap.get(signalClass); } else { inputPorts = new HashSet>(); - signalMap.put((Class) signalClass, inputPorts); + signalMap.put(signalClass, inputPorts); } if (!inputPorts.add(inputPort)) { @@ -97,38 +95,8 @@ public void onSignal(final ISignal signal, final InputPort inputPort) { if (signal.mayBeTriggered(inputPorts, getInputPorts())) { super.onSignal(signal, inputPort); } - - // if (signalMap.containsKey(signalClass)) { - // Set> set = signalMap.get(signalClass); - // if (!set.add(inputPort)) { - // this.logger.warn("Received more than one signal - " + signal + " - from input port: " + inputPort); - // } - // if (signalMap.get(signalClass).size() == this.getInputPorts().length && signalClass == TerminatingSignal.class) { - // triggerAndPassOn(signal); - // // signalMap.remove(signalClass); - // } - // } else { - // Set> tempSet = new HashSet>(); - // signalMap.put((Class) signalClass, tempSet); - // tempSet.add(inputPort); - // if (signalClass == InitializingSignal.class || signalClass == StartingSignal.class) { - // triggerAndPassOn(signal); - // } - // } - } - // private void triggerAndPassOn(final ISignal signal) { - // signal.trigger(this); - // sendSignalToOutputPorts(signal); - // } - - // private void sendSignalToOutputPorts(final ISignal signal) { - // for (OutputPort outputPort : getOutputPorts()) { - // outputPort.sendSignal(signal); - // } - // } - public IMergerStrategy getMergerStrategy() { return this.strategy; }