Skip to content
Snippets Groups Projects
Commit 28d00d4b authored by Christian Wulf's avatar Christian Wulf
Browse files

minor refactorings;

added null checks
parent e553e9da
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,9 @@ public abstract class AbstractCompositeStage extends Configuration { ...@@ -28,6 +28,9 @@ public abstract class AbstractCompositeStage extends Configuration {
private final ConfigurationContext context; private final ConfigurationContext context;
public AbstractCompositeStage(final ConfigurationContext context) { public AbstractCompositeStage(final ConfigurationContext context) {
if (null == context) {
throw new IllegalArgumentException("Context may not be null.");
}
this.context = context; this.context = context;
} }
......
...@@ -202,9 +202,9 @@ public abstract class ConfigurationContext extends Configuration { ...@@ -202,9 +202,9 @@ public abstract class ConfigurationContext extends Configuration {
if (sourcePort.getOwningStage().getInputPorts().length == 0 && !threadableStages.contains(sourcePort.getOwningStage())) { if (sourcePort.getOwningStage().getInputPorts().length == 0 && !threadableStages.contains(sourcePort.getOwningStage())) {
addThreadableStage(sourcePort.getOwningStage()); addThreadableStage(sourcePort.getOwningStage());
} }
if (sourcePort.pipe != null) { if (sourcePort.getPipe() != null || targetPort.getPipe() != null) {
LOGGER.warn("Overwritting existing pipe while connecting stages " + sourcePort.getOwningStage().getId() + " and " + targetPort.getOwningStage().getId() LOGGER.warn("Overwriting existing pipe while connecting stages " +
+ "."); sourcePort.getOwningStage().getId() + " and " + targetPort.getOwningStage().getId() + ".");
} }
new InstantiationPipe(sourcePort, targetPort, capacity); new InstantiationPipe(sourcePort, targetPort, capacity);
} }
......
...@@ -21,13 +21,16 @@ import teetime.framework.signal.ISignal; ...@@ -21,13 +21,16 @@ import teetime.framework.signal.ISignal;
public class InstantiationPipe implements IPipe { public class InstantiationPipe implements IPipe {
private final InputPort<?> target; private static final String ERROR_MESSAGE = "This must not be called while executing the configuration";
private final InputPort<?> targetPort;
private final int capacity; private final int capacity;
public <T> InstantiationPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) { public <T> InstantiationPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
this.target = targetPort; this.targetPort = targetPort;
this.capacity = capacity; this.capacity = capacity;
sourcePort.setPipe(this); sourcePort.setPipe(this);
targetPort.setPipe(this);
} }
public int getCapacity() { public int getCapacity() {
...@@ -36,67 +39,67 @@ public class InstantiationPipe implements IPipe { ...@@ -36,67 +39,67 @@ public class InstantiationPipe implements IPipe {
@Override @Override
public InputPort<?> getTargetPort() { public InputPort<?> getTargetPort() {
return this.target; return this.targetPort;
} }
@Override @Override
public boolean add(final Object element) { public boolean add(final Object element) {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public boolean addNonBlocking(final Object element) { public boolean addNonBlocking(final Object element) {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public int size() { public int size() {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public Object removeLast() { public Object removeLast() {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public void sendSignal(final ISignal signal) { public void sendSignal(final ISignal signal) {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public void reportNewElement() { public void reportNewElement() {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public boolean isClosed() { public boolean isClosed() {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public boolean hasMore() { public boolean hasMore() {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public void waitForStartSignal() throws InterruptedException { public void waitForStartSignal() throws InterruptedException {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public void waitForInitializingSignal() throws InterruptedException { public void waitForInitializingSignal() throws InterruptedException {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
@Override @Override
public void close() { public void close() {
throw new IllegalStateException("This must not be called while executing the configuration"); throw new IllegalStateException(ERROR_MESSAGE);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment