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 {
private final ConfigurationContext context;
public AbstractCompositeStage(final ConfigurationContext context) {
if (null == context) {
throw new IllegalArgumentException("Context may not be null.");
}
this.context = context;
}
......
......@@ -202,9 +202,9 @@ public abstract class ConfigurationContext extends Configuration {
if (sourcePort.getOwningStage().getInputPorts().length == 0 && !threadableStages.contains(sourcePort.getOwningStage())) {
addThreadableStage(sourcePort.getOwningStage());
}
if (sourcePort.pipe != null) {
LOGGER.warn("Overwritting existing pipe while connecting stages " + sourcePort.getOwningStage().getId() + " and " + targetPort.getOwningStage().getId()
+ ".");
if (sourcePort.getPipe() != null || targetPort.getPipe() != null) {
LOGGER.warn("Overwriting existing pipe while connecting stages " +
sourcePort.getOwningStage().getId() + " and " + targetPort.getOwningStage().getId() + ".");
}
new InstantiationPipe(sourcePort, targetPort, capacity);
}
......
......@@ -21,13 +21,16 @@ import teetime.framework.signal.ISignal;
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;
public <T> InstantiationPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
this.target = targetPort;
this.targetPort = targetPort;
this.capacity = capacity;
sourcePort.setPipe(this);
targetPort.setPipe(this);
}
public int getCapacity() {
......@@ -36,67 +39,67 @@ public class InstantiationPipe implements IPipe {
@Override
public InputPort<?> getTargetPort() {
return this.target;
return this.targetPort;
}
@Override
public boolean add(final Object element) {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public boolean addNonBlocking(final Object element) {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public boolean isEmpty() {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public int size() {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public Object removeLast() {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public void sendSignal(final ISignal signal) {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public void reportNewElement() {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public boolean isClosed() {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public boolean hasMore() {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public void waitForStartSignal() throws InterruptedException {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
public void waitForInitializingSignal() throws InterruptedException {
throw new IllegalStateException("This must not be called while executing the configuration");
throw new IllegalStateException(ERROR_MESSAGE);
}
@Override
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