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

Remove dependency of org.fortiss.af3.component.ui to org.fortiss.af3.mira by

generalize RequirementSpecificationUtils.removeRequirementSpecifications() to 
BaseModelElementUtils.removeModelElementReferenceSpecifications()
  
refs 2240
parent d2c4cafc
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
......@@ -24,6 +25,8 @@ import java.util.List;
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;
import org.fortiss.tooling.base.model.element.IModelElementReference;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
/**
......@@ -34,7 +37,7 @@ import org.fortiss.tooling.base.model.element.IModelElementSpecification;
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: 2BEBFE8DEC071DDDD0A4604E579E8C8B
* @ConQAT.Rating YELLOW Hash: 7965F91B651358DF88F4429359C5EB59
*/
public class BaseModelElementUtils {
......@@ -70,4 +73,43 @@ public class BaseModelElementUtils {
}
return -1;
}
/**
* Removes {@link IModelElementSpecification}s of a {@link IModelElement} that represent a
* {@link IModelElementReference}s to another model element.
*
* @param modelElement
* the {@link IModelElement} of which to remove the
* {@link IModelElementSpecification}s
* representing {@link IModelElementReference}s.
*
* @return Whether the {@link IModelElementSpecification}s representing
* {@link IModelElementReference} have been removed, i.e. if the model has been
* modified.
*/
public static boolean removeModelElementReferenceSpecifications(IModelElement modelElement) {
List<IModelElementSpecification> modelElementReferenceSpecifications =
findModelElementReferenceSpecifications((modelElement).getSpecifications());
boolean modelElementReferenceSpecificationsRemoved =
!modelElement.getSpecifications().isEmpty();
modelElement.getSpecifications().removeAll(modelElementReferenceSpecifications);
return modelElementReferenceSpecificationsRemoved;
}
/**
* Finds all {@link IModelElementSpecification}s of a {@link IModelElement} that represent a
* {@link IModelElementReference}s to another model element.
*/
private static List<IModelElementSpecification> findModelElementReferenceSpecifications(
Collection<IModelElementSpecification> specifications) {
List<IModelElementSpecification> result = new ArrayList<IModelElementSpecification>();
for(IModelElementSpecification specification : specifications) {
if(specification instanceof IModelElementReference)
result.add(specification);
}
return result;
}
}
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