Class AbstractModelManipulations
- java.lang.Object
-
- org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.AbstractEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>
-
- org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.AbstractModelManipulations
-
- All Implemented Interfaces:
IEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>,IEcoreReadOperations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>,IModelManipulations,IModelReadOperations
- Direct Known Subclasses:
ModelManipulationWithEditingDomain,SimpleModelManipulations
public abstract class AbstractModelManipulations extends AbstractEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject> implements IModelManipulations, IModelReadOperations
Abstract base class for model manipulation implementation. It checks for the preconditions of the operations, and the subclasses should override the do* methods.- Since:
- 2.1
- No Extend:
- API may be extended in the future.
-
-
Field Summary
Fields Modifier and Type Field Description protected ViatraQueryEngineengine
-
Constructor Summary
Constructors Constructor Description AbstractModelManipulations(ViatraQueryEngine engine)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element)Adds an existing element to a selected EStructuralFeature.voidaddTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element, int index)Adds an existing element to a selected EStructuralFeature at the specified index.voidaddTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.util.Collection<? extends java.lang.Object> elements)Adds a collection of existing elements to a selected EStructuralFeature.voidchangeIndex(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int oldIndex, int newIndex)Changes the position of an existing element in the selected feature of the selected model object.intcount(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature)Retrieves the number of values in a given feature slot of a given container model element.org.eclipse.emf.ecore.EObjectcreate(org.eclipse.emf.ecore.resource.Resource res, org.eclipse.emf.ecore.EClass clazz)Creates a model object and puts it as the root of the selected root container.org.eclipse.emf.ecore.EObjectcreateChild(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass clazz)Creates a model object and puts it into the selected reference of a container.protected abstract voiddoAdd(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature reference, java.lang.Object object, int index)protected abstract voiddoAdd(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature reference, java.util.Collection<? extends java.lang.Object> element)protected abstract voiddoChangeIndex(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int oldIndex, int newIndex)protected abstract intdoCount(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature)protected abstract org.eclipse.emf.ecore.EObjectdoCreate(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass clazz)protected abstract org.eclipse.emf.ecore.EObjectdoCreate(org.eclipse.emf.ecore.resource.Resource res, org.eclipse.emf.ecore.EClass clazz)protected abstract booleandoIsSetTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)protected voiddoMoveTo(java.util.Collection<org.eclipse.emf.ecore.EObject> what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference)protected abstract voiddoMoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference)protected abstract voiddoMoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference, int index)protected abstract voiddoMoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.resource.Resource newContainer)protected abstract voiddoMoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.resource.Resource newContainer, int index)protected abstract voiddoRemove(org.eclipse.emf.ecore.EObject object)Removes an element from the containment hierarchyprotected abstract voiddoRemove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature reference)protected abstract voiddoRemove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int index)protected abstract voiddoRemove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element)Remove a non-containment reference valueprotected abstract voiddoSet(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)protected abstract java.util.stream.Stream<? extends java.lang.Object>doStream(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature)org.eclipse.emf.ecore.EClasseClass(org.eclipse.emf.ecore.EObject element)Queries the exact type of the given object.protected NavigationHelpergetBaseEMFIndex()protected static java.util.Collection<java.lang.Object>getSlotValuesInternal(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature)booleanisSetTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)Returns whether the given value is listed among the values in a given feature slot of a given container model element.voidmoveTo(java.util.Collection<org.eclipse.emf.ecore.EObject> what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference)Moves a collection of existing elements into the selected containment reference of the selected model object.voidmoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference)Moves an existing element into the selected containment reference of the selected model object.voidmoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference, int index)Moves an existing element into the selected containment reference of the selected model object at the specified index.voidmoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.resource.Resource newContainer)Moves an existing element into the root of the selected root container.voidmoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.resource.Resource newContainer, int index)Moves an existing element into the root of the selected root container at the specified index.voidremove(org.eclipse.emf.ecore.EObject object)Removes an object from the model, along with all contained objects, and any incoming or outgoing references.voidremove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature)Removes all elements from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).voidremove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int index)Removes the element at the specified index from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).voidremove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element)Removes an element from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).voidset(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)Sets a 'single'-valued EStructuralFeature of a given container model element to the given value.java.util.stream.Stream<? extends java.lang.Object>stream(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature)Retrieves all values in a given feature slot of a given container model element.-
Methods inherited from class org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.AbstractEcoreManipulations
isEObjectClass
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IEcoreManipulations
add, add, addAll
-
Methods inherited from interface org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IModelManipulations
add, addAllTo, moveAllTo
-
-
-
-
Field Detail
-
engine
protected final ViatraQueryEngine engine
-
-
Constructor Detail
-
AbstractModelManipulations
public AbstractModelManipulations(ViatraQueryEngine engine)
-
-
Method Detail
-
getBaseEMFIndex
protected NavigationHelper getBaseEMFIndex()
- Throws:
ViatraQueryRuntimeException
-
doMoveTo
protected void doMoveTo(java.util.Collection<org.eclipse.emf.ecore.EObject> what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference) throws ModelManipulationException- Throws:
ModelManipulationException
-
doMoveTo
protected abstract void doMoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.resource.Resource newContainer) throws ModelManipulationException- Throws:
ModelManipulationException
-
doMoveTo
protected abstract void doMoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.resource.Resource newContainer, int index) throws ModelManipulationException- Throws:
ModelManipulationException
-
doMoveTo
protected abstract void doMoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference) throws ModelManipulationException- Throws:
ModelManipulationException
-
doMoveTo
protected abstract void doMoveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference, int index) throws ModelManipulationException- Throws:
ModelManipulationException
-
doRemove
protected abstract void doRemove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element) throws ModelManipulationExceptionRemove a non-containment reference value- Throws:
ModelManipulationException
-
doRemove
protected abstract void doRemove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int index) throws ModelManipulationException- Throws:
ModelManipulationException
-
doRemove
protected abstract void doRemove(org.eclipse.emf.ecore.EObject object) throws ModelManipulationExceptionRemoves an element from the containment hierarchy- Throws:
ModelManipulationException
-
doRemove
protected abstract void doRemove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature reference) throws ModelManipulationException- Throws:
ModelManipulationException
-
doAdd
protected abstract void doAdd(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature reference, java.util.Collection<? extends java.lang.Object> element) throws ModelManipulationException- Throws:
ModelManipulationException
-
doAdd
protected abstract void doAdd(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature reference, java.lang.Object object, int index) throws ModelManipulationException- Throws:
ModelManipulationException
-
doSet
protected abstract void doSet(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value) throws ModelManipulationException- Throws:
ModelManipulationException
-
doCreate
protected abstract org.eclipse.emf.ecore.EObject doCreate(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationException- Throws:
ModelManipulationException
-
doCreate
protected abstract org.eclipse.emf.ecore.EObject doCreate(org.eclipse.emf.ecore.resource.Resource res, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationException- Throws:
ModelManipulationException
-
doChangeIndex
protected abstract void doChangeIndex(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int oldIndex, int newIndex) throws ModelManipulationException- Throws:
ModelManipulationException
-
doCount
protected abstract int doCount(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationException- Throws:
ModelManipulationException- Since:
- 2.1
-
doStream
protected abstract java.util.stream.Stream<? extends java.lang.Object> doStream(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationException- Throws:
ModelManipulationException- Since:
- 2.1
-
doIsSetTo
protected abstract boolean doIsSetTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value) throws ModelManipulationException- Throws:
ModelManipulationException- Since:
- 2.1
-
eClass
public org.eclipse.emf.ecore.EClass eClass(org.eclipse.emf.ecore.EObject element) throws ModelManipulationExceptionDescription copied from interface:IEcoreReadOperationsQueries the exact type of the given object.- Specified by:
eClassin interfaceIEcoreReadOperations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException- Since:
- 2.1
-
count
public int count(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationExceptionDescription copied from interface:IEcoreReadOperationsRetrieves the number of values in a given feature slot of a given container model element.- Specified by:
countin interfaceIEcoreReadOperations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException- Since:
- 2.1
-
stream
public java.util.stream.Stream<? extends java.lang.Object> stream(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationExceptionDescription copied from interface:IEcoreReadOperationsRetrieves all values in a given feature slot of a given container model element.- Specified by:
streamin interfaceIEcoreReadOperations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException- Since:
- 2.1
-
isSetTo
public boolean isSetTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value) throws ModelManipulationExceptionDescription copied from interface:IEcoreReadOperationsReturns whether the given value is listed among the values in a given feature slot of a given container model element.- Specified by:
isSetToin interfaceIEcoreReadOperations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException- Since:
- 2.1
-
create
public org.eclipse.emf.ecore.EObject create(org.eclipse.emf.ecore.resource.Resource res, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsCreates a model object and puts it as the root of the selected root container.- Specified by:
createin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
createChild
public org.eclipse.emf.ecore.EObject createChild(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsCreates a model object and puts it into the selected reference of a container. The container reference must be a containment reference.- Specified by:
createChildin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
addTo
public void addTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsAdds an existing element to a selected EStructuralFeature. If the feature is an EReference, it must not be a containment reference.- Specified by:
addToin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
addTo
public void addTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element, int index) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsAdds an existing element to a selected EStructuralFeature at the specified index. If the feature is an EReference, it must not be a containment reference.- Specified by:
addToin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
addTo
public void addTo(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.util.Collection<? extends java.lang.Object> elements) throws ModelManipulationExceptionDescription copied from interface:IModelManipulationsAdds a collection of existing elements to a selected EStructuralFeature. If the feature is an EReference, it must not be a containment reference.- Specified by:
addToin interfaceIModelManipulations- Throws:
ModelManipulationException
-
set
public void set(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsSets a 'single'-valued EStructuralFeature of a given container model element to the given value.The previous value of the feature, if any, is removed. If the provided new value is null, then the invocation acts as 'unset', and no new value is stored.
- Specified by:
setin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>value- the new value to be set, or nullTODO restrict to non-containment?
- Throws:
ModelManipulationException
-
remove
public void remove(org.eclipse.emf.ecore.EObject object) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsRemoves an object from the model, along with all contained objects, and any incoming or outgoing references.- Specified by:
removein interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
remove
public void remove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsRemoves an element from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).- Specified by:
removein interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
remove
public void remove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int index) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsRemoves the element at the specified index from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).- Specified by:
removein interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
remove
public void remove(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsRemoves all elements from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).- Specified by:
removein interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
moveTo
public void moveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.resource.Resource newContainer) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsMoves an existing element into the root of the selected root container.- Specified by:
moveToin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
moveTo
public void moveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.resource.Resource newContainer, int index) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsMoves an existing element into the root of the selected root container at the specified index.- Specified by:
moveToin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
moveTo
public void moveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsMoves an existing element into the selected containment reference of the selected model object.- Specified by:
moveToin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
moveTo
public void moveTo(org.eclipse.emf.ecore.EObject what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference, int index) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsMoves an existing element into the selected containment reference of the selected model object at the specified index.- Specified by:
moveToin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
moveTo
public void moveTo(java.util.Collection<org.eclipse.emf.ecore.EObject> what, org.eclipse.emf.ecore.EObject newContainer, org.eclipse.emf.ecore.EReference reference) throws ModelManipulationExceptionDescription copied from interface:IModelManipulationsMoves a collection of existing elements into the selected containment reference of the selected model object.- Specified by:
moveToin interfaceIModelManipulations- Throws:
ModelManipulationException
-
changeIndex
public void changeIndex(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int oldIndex, int newIndex) throws ModelManipulationExceptionDescription copied from interface:IEcoreManipulationsChanges the position of an existing element in the selected feature of the selected model object.- Specified by:
changeIndexin interfaceIEcoreManipulations<org.eclipse.emf.ecore.resource.Resource,org.eclipse.emf.ecore.EObject>- Throws:
ModelManipulationException
-
getSlotValuesInternal
protected static java.util.Collection<java.lang.Object> getSlotValuesInternal(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature feature)- Since:
- 2.1
-
-