Skip to content
Snippets Groups Projects
Commit 2dc5e700 authored by Simon Barner's avatar Simon Barner
Browse files

- Add getSuccessorConnector() that for a given {@link IConnector}, returns the...

- Add getSuccessorConnector() that for a given {@link IConnector}, returns the successor {@link IConnector} of a given {@code successorType}.
parent 3048bf9d
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHiddenSpecification;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
......@@ -37,7 +39,7 @@ import org.fortiss.tooling.base.model.element.IModelElementSpecification;
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: 90B5C092B1AAA88D270B48FB0B236A74
* @ConQAT.Rating YELLOW Hash: 58521C469226B471D914409DD11925CD
*/
public class BaseModelElementUtils {
......@@ -118,4 +120,32 @@ public class BaseModelElementUtils {
}
return result;
}
/**
* For a given {@link IConnector}, returns the successor {@link IConnector} of a given
* {@code successorType}.
*
* @param connector
* {@link IConnector} for which to determine the successor.
* @param successorType
* Type of successor {@link IConnector}.
* @return The successor {@link IConnector} in case it exists and is unique (i.e., the given
* {@link IConnector} contains exactly one {@link IConnection} that points to a
* successor {@link IConnector} of the desired type.
*/
@SuppressWarnings("unchecked")
public static <T extends IConnector> T getSuccessorConnector(IConnector connector,
Class<T> successorType) {
T rval = null;
for(IConnection connection : connector.getOutgoing()) {
if(successorType.isAssignableFrom(connection.getTarget().getClass())) {
if(rval == null) {
rval = (T)connection.getTarget();
} else {
return null;
}
}
}
return null;
}
}
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