Commit 5a3e33d0 authored by Simon Barner's avatar Simon Barner
Browse files

YELLOW

Remove further unused methods in BaseModelElementUtils
 - nonHiddenSpecifications()
 - getConnectedElements()
refs 2490
parent 0f43aa37
......@@ -17,15 +17,10 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.utils;
import static org.fortiss.tooling.common.util.LambdaUtils.mapInOut;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
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;
import org.fortiss.tooling.base.model.element.IModelElement;
......@@ -40,31 +35,10 @@ import org.fortiss.tooling.base.model.element.IModelElementSpecification;
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 46F473DE149533261065AC7FC7292ED5
* @ConQAT.Rating YELLOW Hash: B86DD1BFD939AFCA5E78DC605AF437F4
*/
public class BaseModelElementUtils {
/**
* Returns a list of specifications from {@code specifications} that are not
* subclass of {@link IHiddenSpecification}.
*
* @param specifications
* the list of specification to be filtered
*
* @return {@link List} of {@link IModelElementSpecification} from {@code specifications} that
* are not subclass of {@link IHiddenSpecification}.
*/
public static List<IModelElementSpecification> nonHiddenSpecifications(
Collection<IModelElementSpecification> specifications) {
List<IModelElementSpecification> res = new LinkedList<IModelElementSpecification>();
for(IModelElementSpecification s : specifications) {
if(!(s instanceof IHiddenSpecification)) {
res.add(s);
}
}
return res;
}
/**
* Return the index of the given {@link IHierarchicElement} in its parent
* {@link IHierarchicElementContainer}.
......@@ -121,36 +95,4 @@ public class BaseModelElementUtils {
}
return result;
}
/**
* Returns the <i>directly</i> connected {@link IHierarchicElement}s of the given
* {@code element} which have the given type.
*
* @param element
* {@link IHierarchicElement} for which to determine the connected elements.
* @param connectedElementType
* Type of the connected elements (filter).
* @return List of connected {@link IHierarchicElement}s of the given type.
*/
public static <T extends IHierarchicElement> List<T> getConnectedElements(
IHierarchicElement element, Class<T> connectedElementType) {
List<IConnector> elementConnectors = element.getConnectors();
List<IConnector> targetConnectors = new ArrayList<>();
for(IConnector elementConnector : elementConnectors) {
targetConnectors.addAll(mapInOut(elementConnector.getIncoming(), in -> in.getSource(),
ArrayList::new));
targetConnectors.addAll(mapInOut(elementConnector.getOutgoing(),
out -> out.getTarget(), ArrayList::new));
}
List<T> targetElements = new ArrayList<>();
for(IConnector targetConnector : targetConnectors) {
if(connectedElementType.isAssignableFrom(targetConnector.getOwner().getClass())) {
@SuppressWarnings("unchecked") T targetElement = (T)targetConnector.getOwner();
targetElements.add(targetElement);
}
}
return targetElements;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment