From 73c43f12a20655b901f85dad081ed257e5aad259 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Sun, 12 Jul 2015 13:47:59 +0200
Subject: [PATCH] fixed compilation problem

---
 .../dynamic/PortActionListener.java           | 15 +++++++
 .../distributor/dynamic/RemovePortAction.java |  7 +---
 .../teetime/util/framework/port/PortList.java | 15 +++++++
 .../framework/port/PortRemovedListener.java   | 15 +++++++
 .../dynamic/DynamicDistributorTest.java       |  6 +--
 .../distributor/dynamic/PortContainer.java    | 26 ++++++++----
 .../dynamic/RemovePortActionDelegation.java   | 42 +++++++++++++++++++
 7 files changed, 108 insertions(+), 18 deletions(-)
 create mode 100644 src/test/java/teetime/stage/basic/distributor/dynamic/RemovePortActionDelegation.java

diff --git a/src/main/java/teetime/stage/basic/distributor/dynamic/PortActionListener.java b/src/main/java/teetime/stage/basic/distributor/dynamic/PortActionListener.java
index 10cd6c47..875db7e7 100644
--- a/src/main/java/teetime/stage/basic/distributor/dynamic/PortActionListener.java
+++ b/src/main/java/teetime/stage/basic/distributor/dynamic/PortActionListener.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package teetime.stage.basic.distributor.dynamic;
 
 import teetime.framework.DynamicOutputPort;
diff --git a/src/main/java/teetime/stage/basic/distributor/dynamic/RemovePortAction.java b/src/main/java/teetime/stage/basic/distributor/dynamic/RemovePortAction.java
index c9785f48..461d3fdb 100644
--- a/src/main/java/teetime/stage/basic/distributor/dynamic/RemovePortAction.java
+++ b/src/main/java/teetime/stage/basic/distributor/dynamic/RemovePortAction.java
@@ -31,11 +31,6 @@ public class RemovePortAction<T> implements PortAction<DynamicDistributor<T>> {
 
 	@Override
 	public void execute(final DynamicDistributor<T> dynamicDistributor) {
-		DynamicOutputPort<T> realOutputPort = outputPort;
-		if (outputPort instanceof PortContainer) { // BETTER replace test-specific code and abstract appropriately
-			realOutputPort = ((PortContainer<T>) outputPort).getPort();
-		}
-
-		dynamicDistributor.removeDynamicPort(realOutputPort);
+		dynamicDistributor.removeDynamicPort(outputPort);
 	}
 }
diff --git a/src/main/java/teetime/util/framework/port/PortList.java b/src/main/java/teetime/util/framework/port/PortList.java
index 0c0f1fd6..b5e48bc9 100644
--- a/src/main/java/teetime/util/framework/port/PortList.java
+++ b/src/main/java/teetime/util/framework/port/PortList.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package teetime.util.framework.port;
 
 import java.util.ArrayList;
diff --git a/src/main/java/teetime/util/framework/port/PortRemovedListener.java b/src/main/java/teetime/util/framework/port/PortRemovedListener.java
index e716f459..643b6ebd 100644
--- a/src/main/java/teetime/util/framework/port/PortRemovedListener.java
+++ b/src/main/java/teetime/util/framework/port/PortRemovedListener.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package teetime.util.framework.port;
 
 import teetime.framework.AbstractPort;
diff --git a/src/test/java/teetime/stage/basic/distributor/dynamic/DynamicDistributorTest.java b/src/test/java/teetime/stage/basic/distributor/dynamic/DynamicDistributorTest.java
index a8e569c1..5aa70849 100644
--- a/src/test/java/teetime/stage/basic/distributor/dynamic/DynamicDistributorTest.java
+++ b/src/test/java/teetime/stage/basic/distributor/dynamic/DynamicDistributorTest.java
@@ -87,11 +87,11 @@ public class DynamicDistributorTest {
 		final PortContainer<Integer> portContainer2 = new PortContainer<Integer>();
 
 		inputActions[0] = createPortCreateAction(portContainer0);
-		inputActions[1] = new RemovePortAction<Integer>(portContainer0);
+		inputActions[1] = new RemovePortActionDelegation<Integer>(portContainer0);
 		inputActions[2] = createPortCreateAction(portContainer1);
 		inputActions[3] = createPortCreateAction(portContainer2);
-		inputActions[4] = new RemovePortAction<Integer>(portContainer1);
-		inputActions[5] = new RemovePortAction<Integer>(portContainer2);
+		inputActions[4] = new RemovePortActionDelegation<Integer>(portContainer1);
+		inputActions[5] = new RemovePortActionDelegation<Integer>(portContainer2);
 
 		DynamicDistributorTestConfig<Integer> config = new DynamicDistributorTestConfig<Integer>(inputNumbers, Arrays.asList(inputActions));
 		Execution<DynamicDistributorTestConfig<Integer>> analysis = new Execution<DynamicDistributorTestConfig<Integer>>(config);
diff --git a/src/test/java/teetime/stage/basic/distributor/dynamic/PortContainer.java b/src/test/java/teetime/stage/basic/distributor/dynamic/PortContainer.java
index 2bf43f5d..114c59ed 100644
--- a/src/test/java/teetime/stage/basic/distributor/dynamic/PortContainer.java
+++ b/src/test/java/teetime/stage/basic/distributor/dynamic/PortContainer.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package teetime.stage.basic.distributor.dynamic;
 
 import teetime.framework.DynamicOutputPort;
@@ -9,18 +24,11 @@ import teetime.framework.DynamicOutputPort;
  *
  * @param <T>
  */
-class PortContainer<T> extends DynamicOutputPort<T> {
+final class PortContainer<T> {
 
 	private DynamicOutputPort<T> port;
 
-	PortContainer() {
-		super(null, null, -1);
-	}
-
-	@Override
-	public int getIndex() {
-		return port.getIndex();
-	}
+	PortContainer() {}
 
 	public void setPort(final DynamicOutputPort<T> port) {
 		this.port = port;
diff --git a/src/test/java/teetime/stage/basic/distributor/dynamic/RemovePortActionDelegation.java b/src/test/java/teetime/stage/basic/distributor/dynamic/RemovePortActionDelegation.java
new file mode 100644
index 00000000..89cd2329
--- /dev/null
+++ b/src/test/java/teetime/stage/basic/distributor/dynamic/RemovePortActionDelegation.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package teetime.stage.basic.distributor.dynamic;
+
+import teetime.framework.DynamicOutputPort;
+import teetime.util.framework.port.PortAction;
+
+/**
+ * Simulates a {@link RemovePortAction} by means of a {@link PortContainer} instead of an {@link DynamicOutputPort}.
+ *
+ * @author Christian Wulf
+ *
+ * @param <T>
+ */
+public class RemovePortActionDelegation<T> implements PortAction<DynamicDistributor<T>> {
+
+	private final PortContainer<T> portContainer;
+
+	public RemovePortActionDelegation(final PortContainer<T> portContainer) {
+		this.portContainer = portContainer;
+	}
+
+	@Override
+	public void execute(final DynamicDistributor<T> dynamicDistributor) {
+		DynamicOutputPort<?> dynamicOutputPort = portContainer.getPort();
+		dynamicDistributor.removeDynamicPort(dynamicOutputPort);
+	}
+
+}
-- 
GitLab