Commit b6ce16f4 authored by Simon Barner's avatar Simon Barner
Browse files

Add the following convenience methods

 - AllocationTable.getAllocationTableCollection()
 - AllocationTableCollection.getAllocationTable(Class<T> allocationTableType)
refs 3343
parent c7ad5d2b
......@@ -48,6 +48,21 @@
</eGenericType>
</eParameters>
</eOperations>
<eOperations name="getAllocationTable">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Returns the first {@link org.fortiss.af3.allocation.model.AllocationTable} contained by this {@link org.fortiss.af3.allocation.model.AllocationTableCollection} that is of the given {@link AllocationTable} specialization (or {@code null} in case it does not exist)."/>
<details key="body" value="return AllocationTableCollectionStaticImpl.getAllocationTable(this, allocationTableType);"/>
</eAnnotations>
<eGenericType eTypeParameter="#//AllocationTableCollection/getAllocationTable/T"/>
<eTypeParameters name="T">
<eBounds eClassifier="#//AllocationTable"/>
</eTypeParameters>
<eParameters name="allocationTableType">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//AllocationTableCollection/getAllocationTable/T"/>
</eGenericType>
</eParameters>
</eOperations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="AllocationTable" abstract="true" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/HierarchicElementBase">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
......@@ -273,6 +288,12 @@
<details key="body" value="AllocationTableStaticImpl.clearAllocationEntries(this);"/>
</eAnnotations>
</eOperations>
<eOperations name="getAllocationTableCollection" eType="#//AllocationTableCollection">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Returns the {@link AllocationTableCollection} that owns this {@link AllocationTable}."/>
<details key="body" value="return AllocationTableStaticImpl.getAllocationTableCollection(this);"/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="sourceView" eType="ecore:EClass platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//IProjectRootElement">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Source model for which to define {@link Allocation}."/>
......
......@@ -19,6 +19,10 @@
<genOperations ecoreOperation="allocation.ecore#//AllocationTableCollection/getAllocationTables.2">
<genParameters ecoreParameter="allocation.ecore#//AllocationTableCollection/getAllocationTables.2/allocationTypes"/>
</genOperations>
<genOperations ecoreOperation="allocation.ecore#//AllocationTableCollection/getAllocationTable">
<genParameters ecoreParameter="allocation.ecore#//AllocationTableCollection/getAllocationTable/allocationTableType"/>
<genTypeParameters ecoreTypeParameter="allocation.ecore#//AllocationTableCollection/getAllocationTable/T"/>
</genOperations>
</genClasses>
<genClasses ecoreClass="allocation.ecore#//AllocationTable">
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference allocation.ecore#//AllocationTable/sourceView"/>
......@@ -77,6 +81,7 @@
<genTypeParameters ecoreTypeParameter="allocation.ecore#//AllocationTable/getSourceElements.2/T"/>
</genOperations>
<genOperations ecoreOperation="allocation.ecore#//AllocationTable/clearAllocationEntries"/>
<genOperations ecoreOperation="allocation.ecore#//AllocationTable/getAllocationTableCollection"/>
</genClasses>
<genClasses image="false" ecoreClass="allocation.ecore#//AllocationEntry">
<genOperations ecoreOperation="allocation.ecore#//AllocationEntry/getAllocationTable"/>
......
AF3AllocationFactoryImplCustom.java 46630be40ab1aa52cd8312c2abac7572cef06f41 GREEN
AllocationEntryStaticImpl.java c32ceaafa60123f19e852b63860e62613ed98802 GREEN
AllocationTableCollectionStaticImpl.java c8c413bf4c09cbba4bf1b47a86b693b5417b4062 GREEN
AllocationTableStaticImpl.java 7acbe1b798a25908a23c30602a9929cc6f194663 GREEN
AllocationTableCollectionStaticImpl.java 51aea2faf56a9193e1361b79dfb92d428e0a3370 YELLOW
AllocationTableStaticImpl.java 3e9de4c1cc01c472874e3885bb33260a227efad6 YELLOW
ParameterEntryStaticImpl.java 06582395715b198d2ffbfe0bafb81f10897a3149 GREEN
ParameterTableStaticImpl.java cd90fc207370734ea590bdabc65a30efa8cb6e79 GREEN
......@@ -17,6 +17,7 @@ package org.fortiss.af3.allocation.model.impl;
import static org.eclipse.emf.common.util.ECollections.singletonEList;
import static org.fortiss.tooling.common.util.LambdaUtils.filterByTypes;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import org.eclipse.emf.common.util.BasicEList;
......@@ -93,4 +94,27 @@ public class AllocationTableCollectionStaticImpl {
Class<?>[] types = new Class<?>[allocationTypes.size()];
return new BasicEList<AllocationTable>(filterByTypes(ats, allocationTypes.toArray(types)));
}
/**
* Returns the first {@link org.fortiss.af3.allocation.model.AllocationTable} contained by this
* {@link org.fortiss.af3.allocation.model.AllocationTableCollection} that is of the given
* {@link AllocationTable} specialization (or {@code null} in case it does not exist).
*
* @param allocationTableCollection
* {@link AllocationTableCollection} for which to the return the contained
* {@link AllocationTable}
*
* @param allocationTableType
* Type of desired {@link AllocationTable} specialization.
*
* @return First {@link org.fortiss.af3.allocation.model.AllocationTable} contained by this
* {@link org.fortiss.af3.allocation.model.AllocationTableCollection} that is of the
* given {@link AllocationTable} specialization (or {@code null} in case it does not
* exist).
*/
public static <T extends AllocationTable> T getAllocationTable(
AllocationTableCollection allocationTableCollection, Class<T> allocationTableType) {
return pickFirstInstanceOf(allocationTableType,
allocationTableCollection.getAllocationTables());
}
}
......@@ -27,6 +27,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EOperation;
import org.fortiss.af3.allocation.model.AllocationEntry;
import org.fortiss.af3.allocation.model.AllocationTable;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.allocation.model.IBidirectional;
import org.fortiss.af3.allocation.model.IUnidirectional;
import org.fortiss.af3.allocation.model.ManyToOneAllocationEntry;
......@@ -446,4 +447,11 @@ public class AllocationTableStaticImpl {
// Eliminate duplicates that might arise from overlaps
return toEList(rval);
}
/** Returns the {@link AllocationTableCollection} that owns the given {@link AllocationTable}. */
public static AllocationTableCollection getAllocationTableCollection(
AllocationTable allocationTable) {
return (AllocationTableCollection)allocationTable.getContainer();
}
}
Markdown is supported
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