public abstract class IndexHostManipulations<ModelObject> extends AbstractEcoreManipulations<java.lang.Void,ModelObject> implements IEcoreReadOperations<java.lang.Void,ModelObject>
EcoreIndexHost
.
The ModelObject type parameter may be specialized to any surrogate key type in use, such as String
or Long
.
Implementors must provide their respective facility for creating and deleting objects (surrogate keys),
therefore the methods doCreate(Void, EClass)
and doCreate(Object, EReference, EClass)
are not implemented.
To implement, use helpers registerInstance(EClassifier, Object, ITableWriterUnary.Table)
and addInternal(Object, EStructuralFeature, Object, ITableWriterBinary.Table, ITableWriterUnary.Table)
,
as well as initializeNewlyCreatedObject(Object, EClass)
.
Limitations:
Modifier and Type | Class and Description |
---|---|
protected static class |
IndexHostManipulations.FeatureKind |
protected static interface |
IndexHostManipulations.Initializer<ModelObject> |
Modifier and Type | Field and Description |
---|---|
protected static TupleMask |
BIND_SOURCE |
protected static TupleMask |
BIND_TARGET |
protected java.util.Map<org.eclipse.emf.ecore.EClass,IndexHostManipulations.Initializer<ModelObject>> |
initializerActions |
Constructor and Description |
---|
IndexHostManipulations(EcoreIndexHost host) |
Modifier and Type | Method and Description |
---|---|
void |
addAllTo(ModelObject 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.
|
protected void |
addInternal(ModelObject container,
org.eclipse.emf.ecore.EStructuralFeature feature,
java.lang.Object newValue,
ITableWriterBinary.Table<java.lang.Object,java.lang.Object> featureTable,
ITableWriterUnary.Table<java.lang.Object> instanceTable)
PRE: Previous containments are erased at this point, if adding to a containment feature.
|
void |
addTo(ModelObject container,
org.eclipse.emf.ecore.EStructuralFeature feature,
java.lang.Object element)
Adds an existing element to a selected EStructuralFeature.
|
void |
addTo(ModelObject 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.
|
void |
changeIndex(ModelObject 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.
|
protected java.util.List<org.eclipse.emf.ecore.EClass> |
computeSubtypes(org.eclipse.emf.ecore.EClass superClass) |
int |
count(ModelObject container,
org.eclipse.emf.ecore.EStructuralFeature feature)
Retrieves the number of values in a given feature slot of a given container model element.
|
ModelObject |
create(java.lang.Void res,
org.eclipse.emf.ecore.EClass clazz)
Creates a model object and puts it as the root of the selected root container.
|
ModelObject |
createChild(ModelObject 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 java.util.Optional<org.eclipse.emf.ecore.EObject> |
createTemplateInstance(org.eclipse.emf.ecore.EClass clazz)
Creates an (optional) vanila instance of the class to learn about the default values.
|
protected void |
deleteWithAllDangling(ModelObject element)
Removes a model element from the model.
|
protected void |
deleteWithOutgoing(ModelObject element)
Removes a model element from the model.
|
protected void |
deleteWithOutgoingInternal(ModelObject element,
org.eclipse.emf.ecore.EClass eClass) |
protected java.util.Map<org.eclipse.emf.ecore.EAttribute,java.lang.Object> |
determineDefaultValues(org.eclipse.emf.ecore.EClass clazz)
Called for each exact type at most once.
|
protected IndexHostManipulations.Initializer<ModelObject> |
determineInitializationSequence(org.eclipse.emf.ecore.EClass clazz)
Called for each exact type at most once.
|
protected abstract ModelObject |
doCreate(ModelObject container,
org.eclipse.emf.ecore.EReference reference,
org.eclipse.emf.ecore.EClass clazz) |
protected abstract ModelObject |
doCreate(java.lang.Void res,
org.eclipse.emf.ecore.EClass clazz) |
org.eclipse.emf.ecore.EClass |
eClass(ModelObject element)
Queries the exact type of the given object.
|
protected org.eclipse.emf.ecore.EClass |
findExactType(ModelObject element)
Implementors may override this with a more efficient lookup.
|
protected java.lang.Iterable<org.eclipse.emf.ecore.EClass> |
getAllClassTypes() |
protected java.util.List<org.eclipse.emf.ecore.EClass> |
getAllClassTypesThatExtend(org.eclipse.emf.ecore.EClass superClass)
PRE: superClass is not EObject
|
protected java.lang.Iterable<java.util.Map.Entry<org.eclipse.emf.ecore.EStructuralFeature,ITableWriterBinary.Table<java.lang.Object,java.lang.Object>>> |
getAllCrossrefsPossiblyIncoming(org.eclipse.emf.ecore.EClass eClass) |
protected java.lang.Iterable<org.eclipse.emf.ecore.EStructuralFeature> |
getAllPossibleFeatures(org.eclipse.emf.ecore.EClass exactType) |
protected java.lang.Iterable<java.util.Map.Entry<org.eclipse.emf.ecore.EStructuralFeature,ITableWriterBinary.Table<java.lang.Object,java.lang.Object>>> |
getAllRefsPossiblyContaining(org.eclipse.emf.ecore.EClass eClass) |
protected void |
initializeNewlyCreatedObject(ModelObject instance,
org.eclipse.emf.ecore.EClass clazz)
Initializes a newly created object to its default state.
|
protected boolean |
isAssignableFrom(org.eclipse.emf.ecore.EClassifier classifier,
java.lang.Object element) |
protected boolean |
isAssignableFrom(org.eclipse.emf.ecore.EClass superClass,
ModelObject element) |
boolean |
isSetTo(ModelObject 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.
|
protected IndexHostManipulations.Initializer<ModelObject> |
makeInitializer(java.util.Map<org.eclipse.emf.ecore.EAttribute,java.lang.Object> defaultValues)
Constructs an initializer that sets attributes of the model object to the given default values.
|
protected void |
moveAllInternal(java.util.Collection<ModelObject> what,
ModelObject newContainer,
org.eclipse.emf.ecore.EReference reference) |
void |
moveAllTo(java.util.Collection<ModelObject> what,
ModelObject newContainer,
org.eclipse.emf.ecore.EReference reference)
Moves a collection of existing elements into the selected containment reference of the selected model object.
|
protected void |
moveInternal(ModelObject what,
ModelObject newContainer,
org.eclipse.emf.ecore.EReference reference) |
void |
moveTo(ModelObject what,
ModelObject newContainer,
org.eclipse.emf.ecore.EReference reference)
Moves an existing element into the selected containment reference of the selected model object.
|
void |
moveTo(ModelObject what,
ModelObject 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.
|
void |
moveTo(ModelObject what,
java.lang.Void newContainer)
Moves an existing element into the root of the selected root container.
|
void |
moveTo(ModelObject what,
java.lang.Void newContainer,
int index)
Moves an existing element into the root of the selected root container at the specified index.
|
protected void |
registerInstance(org.eclipse.emf.ecore.EClassifier type,
java.lang.Object newValue,
ITableWriterUnary.Table<java.lang.Object> instanceTableOptional)
Registers an instance of a classifier.
|
void |
remove(ModelObject object)
Removes an object from the model, along with all contained objects, and any incoming or outgoing references.
|
void |
remove(ModelObject 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).
|
void |
remove(ModelObject 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).
|
void |
remove(ModelObject 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).
|
protected void |
removeAllOfInternal(ModelObject container,
org.eclipse.emf.ecore.EStructuralFeature feature) |
protected void |
removeFromCurrentContainer(ModelObject value)
The implementation must:
remove the containment reference pointing to this element, if it exists.
|
protected void |
removeFromCurrentContainer(ModelObject value,
org.eclipse.emf.ecore.EClass eClass) |
protected void |
removeInternal(ModelObject container,
org.eclipse.emf.ecore.EStructuralFeature feature,
java.lang.Object oldValue,
ITableWriterBinary.Table<java.lang.Object,java.lang.Object> featureTable,
ITableWriterUnary.Table<java.lang.Object> instanceTable) |
void |
set(ModelObject 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.
|
protected void |
setInternal(ModelObject container,
org.eclipse.emf.ecore.EStructuralFeature feature,
java.lang.Object value) |
java.util.stream.Stream<? extends java.lang.Object> |
stream(ModelObject container,
org.eclipse.emf.ecore.EStructuralFeature feature)
Retrieves all values in a given feature slot of a given container model element.
|
protected void |
unregisterInstance(org.eclipse.emf.ecore.EClassifier type,
java.lang.Object oldValue,
ITableWriterUnary.Table<java.lang.Object> instanceTableOptional)
Unregisters an instance of a classifier.
|
isEObjectClass
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
add, add, addAll
protected static final TupleMask BIND_SOURCE
protected static final TupleMask BIND_TARGET
protected java.util.Map<org.eclipse.emf.ecore.EClass,IndexHostManipulations.Initializer<ModelObject>> initializerActions
public IndexHostManipulations(EcoreIndexHost host)
public org.eclipse.emf.ecore.EClass eClass(ModelObject element) throws ModelManipulationException
IEcoreReadOperations
eClass
in interface IEcoreReadOperations<java.lang.Void,ModelObject>
ModelManipulationException
protected org.eclipse.emf.ecore.EClass findExactType(ModelObject element) throws ModelManipulationException
ModelManipulationException
protected boolean isAssignableFrom(org.eclipse.emf.ecore.EClass superClass, ModelObject element)
protected boolean isAssignableFrom(org.eclipse.emf.ecore.EClassifier classifier, java.lang.Object element)
protected java.lang.Iterable<org.eclipse.emf.ecore.EClass> getAllClassTypes()
protected java.util.List<org.eclipse.emf.ecore.EClass> getAllClassTypesThatExtend(org.eclipse.emf.ecore.EClass superClass)
protected java.util.List<org.eclipse.emf.ecore.EClass> computeSubtypes(org.eclipse.emf.ecore.EClass superClass)
public int count(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationException
IEcoreReadOperations
count
in interface IEcoreReadOperations<java.lang.Void,ModelObject>
ModelManipulationException
public java.util.stream.Stream<? extends java.lang.Object> stream(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationException
IEcoreReadOperations
stream
in interface IEcoreReadOperations<java.lang.Void,ModelObject>
ModelManipulationException
public boolean isSetTo(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value) throws ModelManipulationException
IEcoreReadOperations
isSetTo
in interface IEcoreReadOperations<java.lang.Void,ModelObject>
ModelManipulationException
public ModelObject create(java.lang.Void res, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationException
IEcoreManipulations
create
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
protected abstract ModelObject doCreate(java.lang.Void res, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationException
ModelManipulationException
public ModelObject createChild(ModelObject container, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationException
IEcoreManipulations
createChild
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
protected abstract ModelObject doCreate(ModelObject container, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationException
ModelManipulationException
protected void deleteWithOutgoing(ModelObject element) throws ModelManipulationException
An efficient implementation shall:
unregisterInstance(EClassifier, Object, ITableWriterUnary.Table)
),
element
- the model element to delete from the modelModelManipulationException
protected void deleteWithOutgoingInternal(ModelObject element, org.eclipse.emf.ecore.EClass eClass) throws ModelManipulationException
ModelManipulationException
protected void deleteWithAllDangling(ModelObject element) throws ModelManipulationException
The implementation must:
deleteWithOutgoing(Object)
does, as well as
element
- the model element to delete from the modelModelManipulationException
protected void removeFromCurrentContainer(ModelObject value) throws ModelManipulationException
The implementation must:
ModelManipulationException
protected void removeFromCurrentContainer(ModelObject value, org.eclipse.emf.ecore.EClass eClass)
protected java.lang.Iterable<java.util.Map.Entry<org.eclipse.emf.ecore.EStructuralFeature,ITableWriterBinary.Table<java.lang.Object,java.lang.Object>>> getAllRefsPossiblyContaining(org.eclipse.emf.ecore.EClass eClass)
protected java.lang.Iterable<java.util.Map.Entry<org.eclipse.emf.ecore.EStructuralFeature,ITableWriterBinary.Table<java.lang.Object,java.lang.Object>>> getAllCrossrefsPossiblyIncoming(org.eclipse.emf.ecore.EClass eClass)
protected java.lang.Iterable<org.eclipse.emf.ecore.EStructuralFeature> getAllPossibleFeatures(org.eclipse.emf.ecore.EClass exactType)
protected void unregisterInstance(org.eclipse.emf.ecore.EClassifier type, java.lang.Object oldValue, ITableWriterUnary.Table<java.lang.Object> instanceTableOptional)
feature
- oldValue
- instanceTableOptional
- can be null, in which case the table is looked up based on the typeprotected void registerInstance(org.eclipse.emf.ecore.EClassifier type, java.lang.Object newValue, ITableWriterUnary.Table<java.lang.Object> instanceTableOptional)
feature
- newValue
- instanceTableOptional
- can be null, in which case the table is looked up based on the typeprotected void initializeNewlyCreatedObject(ModelObject instance, org.eclipse.emf.ecore.EClass clazz) throws ModelManipulationException
determineInitializationSequence(EClass)
or determineDefaultValues(EClass)
.ModelManipulationException
protected IndexHostManipulations.Initializer<ModelObject> determineInitializationSequence(org.eclipse.emf.ecore.EClass clazz)
The default implementation derives the necessary steps from the default values of attributes. Feel free to override with domain-specific initialization steps, such as setting key attributes to uniquely generated values.
protected java.util.Map<org.eclipse.emf.ecore.EAttribute,java.lang.Object> determineDefaultValues(org.eclipse.emf.ecore.EClass clazz)
The default implementation derives the defaults from a template instance initialized by the EFactory
..
Feel free to override with domain-specific initialization steps,
or override determineInitializationSequence(EClass)
for larger flexibility.
protected java.util.Optional<org.eclipse.emf.ecore.EObject> createTemplateInstance(org.eclipse.emf.ecore.EClass clazz)
protected IndexHostManipulations.Initializer<ModelObject> makeInitializer(java.util.Map<org.eclipse.emf.ecore.EAttribute,java.lang.Object> defaultValues)
protected void removeInternal(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object oldValue, ITableWriterBinary.Table<java.lang.Object,java.lang.Object> featureTable, ITableWriterUnary.Table<java.lang.Object> instanceTable) throws ModelManipulationException
featureTable
- optional, can be supplied if known; will be looked up based on feature if null is suppliedinstanceTable
- optional, can be supplied if known; will be looked up based on feature if null is suppliedModelManipulationException
protected void addInternal(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object newValue, ITableWriterBinary.Table<java.lang.Object,java.lang.Object> featureTable, ITableWriterUnary.Table<java.lang.Object> instanceTable)
featureTable
- optional, can be supplied if known; will be looked up based on feature if null is suppliedinstanceTable
- optional, can be supplied if known; will be looked up based on feature if null is suppliedpublic void addTo(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element) throws ModelManipulationException
IEcoreManipulations
addTo
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void addTo(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element, int index) throws ModelManipulationException
IEcoreManipulations
addTo
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void addAllTo(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.util.Collection<? extends java.lang.Object> elements) throws ModelManipulationException
IEcoreManipulations
addAllTo
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void set(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value) throws ModelManipulationException
IEcoreManipulations
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.
set
in interface IEcoreManipulations<java.lang.Void,ModelObject>
value
- the new value to be set, or null
TODO restrict to non-containment?
ModelManipulationException
protected void setInternal(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value) throws ModelManipulationException
ModelManipulationException
public void remove(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element) throws ModelManipulationException
IEcoreManipulations
remove
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void remove(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int index) throws ModelManipulationException
IEcoreManipulations
remove
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void remove(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationException
IEcoreManipulations
remove
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
protected void removeAllOfInternal(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature) throws ModelManipulationException
ModelManipulationException
public void remove(ModelObject object) throws ModelManipulationException
IEcoreManipulations
remove
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void moveTo(ModelObject what, java.lang.Void newContainer) throws ModelManipulationException
IEcoreManipulations
moveTo
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void moveTo(ModelObject what, java.lang.Void newContainer, int index) throws ModelManipulationException
IEcoreManipulations
moveTo
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void moveTo(ModelObject what, ModelObject newContainer, org.eclipse.emf.ecore.EReference reference) throws ModelManipulationException
IEcoreManipulations
moveTo
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
protected void moveInternal(ModelObject what, ModelObject newContainer, org.eclipse.emf.ecore.EReference reference) throws ModelManipulationException
ModelManipulationException
public void moveTo(ModelObject what, ModelObject newContainer, org.eclipse.emf.ecore.EReference reference, int index) throws ModelManipulationException
IEcoreManipulations
moveTo
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
public void moveAllTo(java.util.Collection<ModelObject> what, ModelObject newContainer, org.eclipse.emf.ecore.EReference reference) throws ModelManipulationException
IEcoreManipulations
moveAllTo
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException
protected void moveAllInternal(java.util.Collection<ModelObject> what, ModelObject newContainer, org.eclipse.emf.ecore.EReference reference) throws ModelManipulationException
ModelManipulationException
public void changeIndex(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int oldIndex, int newIndex) throws ModelManipulationException
IEcoreManipulations
changeIndex
in interface IEcoreManipulations<java.lang.Void,ModelObject>
ModelManipulationException