Package org.eclipse.epsilon.eol.models
Class ModelReference
- java.lang.Object
-
- org.eclipse.epsilon.eol.models.ModelReference
-
- All Implemented Interfaces:
AutoCloseable
,IOperationContributorProvider
,IWrapper
,IAdaptableModel
,IModel
- Direct Known Subclasses:
ReflectiveModelReference
public class ModelReference extends Object implements IAdaptableModel, IWrapper, IOperationContributorProvider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.epsilon.eol.models.IModel
IModel.AmbiguityCheckResult
-
-
Constructor Summary
Constructors Constructor Description ModelReference(IModel target)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
adaptTo(Class<T> modelType)
Tries to adapt the model to a different type.Collection<?>
allContents()
Returns a collection containing all of the objects contained in this model.Object
createInstance(String type)
Object
createInstance(String type, Collection<Object> parameters)
void
deleteElement(Object instance)
void
dispose()
List<String>
getAliases()
Collection<?>
getAllOfKind(String type)
Collection<?>
getAllOfType(String type)
Object
getElementById(String id)
String
getElementId(Object instance)
Object
getEnumerationValue(String enumeration, String label)
String
getFullyQualifiedTypeNameOf(Object instance)
Returns a string representing the fully-qualified type of the instance object.Metamodel
getMetamodel(StringProperties properties, IRelativePathResolver resolver)
String
getName()
OperationContributor
getOperationContributor()
IPropertyGetter
getPropertyGetter()
IPropertySetter
getPropertySetter()
IModel
getTarget()
IModelTransactionSupport
getTransactionSupport()
String
getTypeNameOf(Object instance)
Returns a string representing the type of the instance object.Object
getTypeOf(Object instance)
Object
getWrapped()
boolean
hasType(String type)
boolean
isInstantiable(String type)
boolean
isModelElement(Object instance)
Used to test whether a Java object can be contained by this model.boolean
isOfKind(Object instance, String type)
boolean
isOfType(Object instance, String type)
boolean
isPropertySet(Object instance, String property)
Returnstrue
if this instance has an explicit value for this property.boolean
isReadOnLoad()
boolean
isStoredOnDisposal()
boolean
knowsAboutProperty(Object instance, String property)
Returnstrue
if this instance could have this property at some point.void
load()
void
load(StringProperties properties)
void
load(StringProperties properties, String basePath)
void
load(StringProperties properties, IRelativePathResolver resolver)
boolean
owns(Object instance)
Used to test whether an object is contained in this model.void
setElementId(Object instance, String newId)
void
setName(String name)
void
setReadOnLoad(boolean readOnLoad)
void
setStoredOnDisposal(boolean storedOnDisposal)
boolean
store()
boolean
store(String fileName)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.epsilon.eol.models.IModel
checkAmbiguity, close
-
-
-
-
Constructor Detail
-
ModelReference
public ModelReference(IModel target)
-
-
Method Detail
-
getTarget
public IModel getTarget()
-
getAliases
public List<String> getAliases()
- Specified by:
getAliases
in interfaceIModel
-
allContents
public Collection<?> allContents()
Description copied from interface:IModel
Returns a collection containing all of the objects contained in this model.- Specified by:
allContents
in interfaceIModel
- Returns:
- all of the objects contained in this model.
-
createInstance
public Object createInstance(String type) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException
- Specified by:
createInstance
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
EolNotInstantiableModelElementTypeException
-
deleteElement
public void deleteElement(Object instance) throws EolRuntimeException
- Specified by:
deleteElement
in interfaceIModel
- Throws:
EolRuntimeException
-
getAllOfKind
public Collection<?> getAllOfKind(String type) throws EolModelElementTypeNotFoundException
- Specified by:
getAllOfKind
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
-
getAllOfType
public Collection<?> getAllOfType(String type) throws EolModelElementTypeNotFoundException
- Specified by:
getAllOfType
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
-
getEnumerationValue
public Object getEnumerationValue(String enumeration, String label) throws EolEnumerationValueNotFoundException
- Specified by:
getEnumerationValue
in interfaceIModel
- Throws:
EolEnumerationValueNotFoundException
-
getElementById
public Object getElementById(String id)
- Specified by:
getElementById
in interfaceIModel
-
getElementId
public String getElementId(Object instance)
- Specified by:
getElementId
in interfaceIModel
-
setElementId
public void setElementId(Object instance, String newId)
- Specified by:
setElementId
in interfaceIModel
-
getPropertyGetter
public IPropertyGetter getPropertyGetter()
- Specified by:
getPropertyGetter
in interfaceIModel
-
getPropertySetter
public IPropertySetter getPropertySetter()
- Specified by:
getPropertySetter
in interfaceIModel
-
getTypeNameOf
public String getTypeNameOf(Object instance)
Description copied from interface:IModel
Returns a string representing the type of the instance object. The value returned by this function can be passed to createInstance to instantiate another object of the same type as instance.- Specified by:
getTypeNameOf
in interfaceIModel
- Parameters:
instance
- The model object whose type is to be determined.- Returns:
- the name of the type of the model object, instance.
-
getFullyQualifiedTypeNameOf
public String getFullyQualifiedTypeNameOf(Object instance)
Description copied from interface:IModel
Returns a string representing the fully-qualified type of the instance object. The value returned by this function can be passed to createInstance to instantiate another object of the same type as instance.- Specified by:
getFullyQualifiedTypeNameOf
in interfaceIModel
- Parameters:
instance
- The model object whose type is to be determined.- Returns:
- the name of the type of the model object, instance.
-
isInstantiable
public boolean isInstantiable(String type)
- Specified by:
isInstantiable
in interfaceIModel
-
isModelElement
public boolean isModelElement(Object instance)
Description copied from interface:IModel
Used to test whether a Java object can be contained by this model. For example, EMF models can contain instances of EObject, but not instances of just Object.- Specified by:
isModelElement
in interfaceIModel
- Parameters:
instance
- the Java object to test.- Returns:
- true if and only if instance can be contained by this model.
-
isOfKind
public boolean isOfKind(Object instance, String type) throws EolModelElementTypeNotFoundException
- Specified by:
isOfKind
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
-
isOfType
public boolean isOfType(Object instance, String type) throws EolModelElementTypeNotFoundException
- Specified by:
isOfType
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
-
isReadOnLoad
public boolean isReadOnLoad()
- Specified by:
isReadOnLoad
in interfaceIModel
-
isStoredOnDisposal
public boolean isStoredOnDisposal()
- Specified by:
isStoredOnDisposal
in interfaceIModel
-
load
public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException
- Specified by:
load
in interfaceIModel
- Throws:
EolModelLoadingException
-
load
public void load() throws EolModelLoadingException
- Specified by:
load
in interfaceIModel
- Throws:
EolModelLoadingException
-
owns
public boolean owns(Object instance)
Description copied from interface:IModel
Used to test whether an object is contained in this model.
-
setReadOnLoad
public void setReadOnLoad(boolean readOnLoad)
- Specified by:
setReadOnLoad
in interfaceIModel
-
setStoredOnDisposal
public void setStoredOnDisposal(boolean storedOnDisposal)
- Specified by:
setStoredOnDisposal
in interfaceIModel
-
getTransactionSupport
public IModelTransactionSupport getTransactionSupport()
- Specified by:
getTransactionSupport
in interfaceIModel
-
knowsAboutProperty
public boolean knowsAboutProperty(Object instance, String property)
Description copied from interface:IModel
Returnstrue
if this instance could have this property at some point.- Specified by:
knowsAboutProperty
in interfaceIModel
-
isPropertySet
public boolean isPropertySet(Object instance, String property) throws EolRuntimeException
Description copied from interface:IModel
Returnstrue
if this instance has an explicit value for this property. This would be equivalent to eIsSet in EMF.- Specified by:
isPropertySet
in interfaceIModel
- Throws:
EolRuntimeException
-
createInstance
public Object createInstance(String type, Collection<Object> parameters) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException
- Specified by:
createInstance
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
EolNotInstantiableModelElementTypeException
-
getWrapped
public Object getWrapped()
- Specified by:
getWrapped
in interfaceIWrapper
-
adaptTo
public <T> T adaptTo(Class<T> modelType)
Description copied from interface:IAdaptableModel
Tries to adapt the model to a different type. If it is not possible, this method should returnnull
.- Specified by:
adaptTo
in interfaceIAdaptableModel
- Parameters:
modelType
- Type to which this model should be adapted.- Returns:
- Non-null value if the model could be adapted,
null
otherwise.
-
getOperationContributor
public OperationContributor getOperationContributor()
- Specified by:
getOperationContributor
in interfaceIOperationContributorProvider
-
load
public void load(StringProperties properties, String basePath) throws EolModelLoadingException
- Specified by:
load
in interfaceIModel
- Throws:
EolModelLoadingException
-
load
public void load(StringProperties properties) throws EolModelLoadingException
- Specified by:
load
in interfaceIModel
- Throws:
EolModelLoadingException
-
getMetamodel
public Metamodel getMetamodel(StringProperties properties, IRelativePathResolver resolver)
- Specified by:
getMetamodel
in interfaceIModel
-
-