Package com._1c.g5.v8.dt.lcore.util
Class Mapper
java.lang.Object
com._1c.g5.v8.dt.lcore.util.Mapper
- Direct Known Subclasses:
QlMapper
A useful superclass for mapper implementations. Can be used to implement
a many-to-many mapping between EObjects based on EMF Adapter mechanism.
Subclasses must implement the newMapping(Class) method
to instantiate the language-specific Mapper.Mappings. Subclasses
should also provide a language-specific API for working with mappings.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAn abstract superclass of the mappings based on EMF Adapter mechanism. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Set<org.eclipse.emf.ecore.EObject>getMappedObjects(org.eclipse.emf.ecore.EObject eObject, Class<? extends Mapper.Mapping> mappingType) Returns the set of mapped objects for the given object and the given type of mapping.protected <T extends Mapper.Mapping>
TgetMapping(org.eclipse.emf.ecore.EObject eObject, Class<T> mappingType, boolean createOnDemand) Returns a mapping object of the given type associated with the given object.protected org.eclipse.emf.ecore.EObjectgetPrimaryMappedObject(org.eclipse.emf.ecore.EObject eObject, Class<? extends Mapper.Mapping> mappingType) Returns the primary mapped object for the given object and the given type of mapping.protected abstract <T extends Mapper.Mapping>
TnewMapping(Class<T> mappingType) Returns a new mapping object of the given type.protected voidunsetMapping(org.eclipse.emf.ecore.EObject eObject, Class<? extends Mapper.Mapping> mappingType) Disassociates the mapping object of the given type from the given object.
-
Constructor Details
-
Mapper
public Mapper()
-
-
Method Details
-
newMapping
Returns a new mapping object of the given type.- Parameters:
mappingType- the type of the mapping (notnull)- Returns:
- a new mapping object of the given type (never
null) - Throws:
IllegalArgumentException- if the mapper does not support mappings of the given type
-
getMapping
protected <T extends Mapper.Mapping> T getMapping(org.eclipse.emf.ecore.EObject eObject, Class<T> mappingType, boolean createOnDemand) Returns a mapping object of the given type associated with the given object. UsesnewMapping(Class)if mapping creation is necessary.- Parameters:
eObject- the object (notnull)mappingType- the type of the mapping (notnull)createOnDemand- whether the mapping object should be created if not found- Returns:
- the requested mapping object, or
nullif it is not found andcreateOnDemandisfalse
-
getMappedObjects
protected Set<org.eclipse.emf.ecore.EObject> getMappedObjects(org.eclipse.emf.ecore.EObject eObject, Class<? extends Mapper.Mapping> mappingType) Returns the set of mapped objects for the given object and the given type of mapping. The result is a copy of the actual list of mapped objects stored in the mapping and can be modified safely by the client. The set has the same iteration order as the original list. The first element of the set is the primary mapped object at the time of the invocation.- Parameters:
eObject- the object (notnull)mappingType- the type of the mapping (notnull)- Returns:
- the set of mapped objects (never
null)
-
getPrimaryMappedObject
protected org.eclipse.emf.ecore.EObject getPrimaryMappedObject(org.eclipse.emf.ecore.EObject eObject, Class<? extends Mapper.Mapping> mappingType) Returns the primary mapped object for the given object and the given type of mapping. The primary mapped object is the first element of the list of mapped objects stored in the mapping.- Parameters:
eObject- the object (notnull)mappingType- the type of the mapping (notnull)- Returns:
- the primary mapped object, or
nullif no mapping is found or the list of mapped objects is empty.
-
unsetMapping
protected void unsetMapping(org.eclipse.emf.ecore.EObject eObject, Class<? extends Mapper.Mapping> mappingType) Disassociates the mapping object of the given type from the given object. Does nothing if such a mapping object is not found.- Parameters:
eObject- the object (notnull)mappingType- the type of the mapping (notnull)
-