DependencyConnection - fix ToString() nullpointer exception, improve reconnecting to store connected node to the other side of the connection too
@@ -97,9 +97,12 @@ public Type getType() {
* Removes current link for both ends of the connection, set's connected node to connectToConnection and gets its data
* @param connectToConnection
*/
- public void reconnectInputConnectionToOutput(DependencyConnection<T> connectToConnection) {
+ public void connectInputToOutput(DependencyConnection<T> connectToConnection) {
+ if (this.connectedConnection != null) {
this.connectedConnection.connectedConnection = null;
+ }
this.connectedConnection = connectToConnection;
+ this.connectedConnection.connectedConnection = this;
this.data = connectToConnection.getData();
}
@@ -118,9 +121,11 @@ public void disconnect() {
@Override
public String toString() {
+ String connectedConnectionString = (connectedConnection == null) ? "no connection" : connectedConnection.getName();
+
return (connectionType == Type.OUTPUT) ?
- String.format("Output:%s([Parent]%s->%s)", connectionName, parentNode, connectedConnection.getName()) :
- String.format("Input:%s([Parent]%s<-%s)", connectionName, parentNode, connectedConnection.getName());
+ String.format("Output:%s([Parent]%s->%s)", connectionName, parentNode, connectedConnectionString) :
+ String.format("Input:%s([Parent]%s<-%s)", connectionName, parentNode, connectedConnectionString);
}
/**
