Class JavaModel
- java.lang.Object
-
- org.eclipse.epsilon.eol.models.Model
-
- org.eclipse.epsilon.eol.models.java.JavaModel
-
- All Implemented Interfaces:
AutoCloseable
,IModel
,IReflectiveModel
public class JavaModel extends Model implements IReflectiveModel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.epsilon.eol.models.IModel
IModel.AmbiguityCheckResult
-
-
Field Summary
Fields Modifier and Type Field Description protected Collection<Class<?>>
classes
protected Collection<Object>
objects
-
Fields inherited from class org.eclipse.epsilon.eol.models.Model
aliases, ENV_PREFIX, name, PROPERTY_ALIASES, PROPERTY_NAME, PROPERTY_READONLOAD, PROPERTY_READONLY, PROPERTY_STOREONDISPOSAL, propertyGetter, propertySetter, readOnLoad, storeOnDisposal
-
-
Constructor Summary
Constructors Constructor Description JavaModel(String name, Collection<? extends Object> objects, Collection<? extends Class<?>> classes)
JavaModel(Collection<? extends Object> objects, Collection<? extends Class<?>> classes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<Object>
allContents()
Returns a collection containing all of the objects contained in this model.Class<?>
classForName(String name)
Object
createInstance(String type)
void
deleteElement(Object instance)
void
dispose()
Collection<?>
getAllOfKind(String type)
Collection<?>
getAllOfType(String type)
Object
getContainerOf(Object object)
Returns the model element that contains the given model element, or null if the given model element is top-level.Object
getElementById(String id)
String
getElementId(Object instance)
String
getEnumerationLabelOf(Object literal)
Returns the enumeration label of the literal parameter.String
getEnumerationTypeOf(Object literal)
Returns the name of the enumeration type of the literal parameter.Object
getEnumerationValue(String enumeration, String label)
Collection<String>
getPropertiesOf(String type)
Returns a collection containing all of the properties that instances of type know about.IReflectivePropertySetter
getPropertySetter()
String
getTypeNameOf(Object instance)
Returns a string representing the type of the instance object.Object
getTypeOf(Object instance)
boolean
hasPackage(String packageName)
Returns true iff this model contains a package with the given name.boolean
hasProperty(String type, String property)
boolean
hasType(String type)
boolean
isEnumerationValue(Object object)
Returns true iff object is an enumeration value.boolean
isInstantiable(Class<?> c)
boolean
isInstantiable(String type)
boolean
isLoaded()
boolean
isModelElement(Object instance)
Used to test whether a Java object can be contained by this model.boolean
isOfKind(Object instance, String metaClass)
boolean
isOfType(Object instance, String metaClass)
void
load()
boolean
owns(Object instance)
Used to test whether an object is contained in this model.boolean
preventLoadingOfExternalModelElements()
Prevents the loading of model elements that are referenced by this model but are not contained in this model.void
setElementId(Object instance, String newId)
boolean
store()
boolean
store(String location)
-
Methods inherited from class org.eclipse.epsilon.eol.models.Model
allInstances, createInstance, getAliases, getFullyQualifiedTypeNameOf, getMetamodel, getName, getPropertyGetter, getTransactionSupport, isPropertySet, isReadOnLoad, isStoredOnDisposal, knowsAboutProperty, load, load, load, setName, setReadOnLoad, setStoredOnDisposal
-
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, createInstance, getAliases, getFullyQualifiedTypeNameOf, getMetamodel, getName, getPropertyGetter, getTransactionSupport, isPropertySet, isReadOnLoad, isStoredOnDisposal, knowsAboutProperty, load, load, load, setName, setReadOnLoad, setStoredOnDisposal
-
-
-
-
Field Detail
-
objects
protected Collection<Object> objects
-
classes
protected Collection<Class<?>> classes
-
-
Constructor Detail
-
JavaModel
public JavaModel(String name, Collection<? extends Object> objects, Collection<? extends Class<?>> classes)
-
JavaModel
public JavaModel(Collection<? extends Object> objects, Collection<? extends Class<?>> classes)
-
-
Method Detail
-
allContents
public Collection<Object> 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
-
isInstantiable
public boolean isInstantiable(Class<?> c)
-
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
-
isOfKind
public boolean isOfKind(Object instance, String metaClass) throws EolModelElementTypeNotFoundException
- Specified by:
isOfKind
in interfaceIModel
- Overrides:
isOfKind
in classModel
- Throws:
EolModelElementTypeNotFoundException
-
isOfType
public boolean isOfType(Object instance, String metaClass) throws EolModelElementTypeNotFoundException
- Specified by:
isOfType
in interfaceIModel
- Overrides:
isOfType
in classModel
- Throws:
EolModelElementTypeNotFoundException
-
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
-
getEnumerationValue
public Object getEnumerationValue(String enumeration, String label) throws EolEnumerationValueNotFoundException
- Specified by:
getEnumerationValue
in interfaceIModel
- Throws:
EolEnumerationValueNotFoundException
-
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.
-
hasPackage
public boolean hasPackage(String packageName)
Description copied from interface:IReflectiveModel
Returns true iff this model contains a package with the given name. In general, a "package" is a group of types (and potentially other packages) and a namespace for the grouped elements. The precise semantics of "package" is specific to the implementation. For example, an Ecore implementation might use EPackage. An XML implementation might use XML namespaces. A CSV implementation might not support any notion of packages (and hence always return false).- Specified by:
hasPackage
in interfaceIReflectiveModel
-
getContainerOf
public Object getContainerOf(Object object)
Description copied from interface:IReflectiveModel
Returns the model element that contains the given model element, or null if the given model element is top-level.- Specified by:
getContainerOf
in interfaceIReflectiveModel
- Parameters:
object
- The model element whose container is to be found.- Returns:
- the model element that contains object, or null if object is not contained in any other model element.
-
isInstantiable
public boolean isInstantiable(String type)
- Specified by:
isInstantiable
in interfaceIModel
-
getPropertiesOf
public Collection<String> getPropertiesOf(String type) throws EolModelElementTypeNotFoundException
Description copied from interface:IReflectiveModel
Returns a collection containing all of the properties that instances of type know about.- Specified by:
getPropertiesOf
in interfaceIReflectiveModel
- Parameters:
type
- The type of model object whose properties are to be determined.- Returns:
- all of the properties that instances of type knows about.
- Throws:
EolModelElementTypeNotFoundException
- when this model has no such type
-
hasProperty
public boolean hasProperty(String type, String property) throws EolModelElementTypeNotFoundException
- Specified by:
hasProperty
in interfaceIReflectiveModel
- Throws:
EolModelElementTypeNotFoundException
-
getPropertySetter
public IReflectivePropertySetter getPropertySetter()
- Specified by:
getPropertySetter
in interfaceIModel
- Specified by:
getPropertySetter
in interfaceIReflectiveModel
- Overrides:
getPropertySetter
in classModel
-
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
- Overrides:
isModelElement
in classModel
- Parameters:
instance
- the Java object to test.- Returns:
- true if and only if instance can be contained by this model.
-
isEnumerationValue
public boolean isEnumerationValue(Object object)
Description copied from interface:IReflectiveModel
Returns true iff object is an enumeration value.- Specified by:
isEnumerationValue
in interfaceIReflectiveModel
-
getEnumerationTypeOf
public String getEnumerationTypeOf(Object literal) throws EolNotAnEnumerationValueException
Description copied from interface:IReflectiveModel
Returns the name of the enumeration type of the literal parameter.- Specified by:
getEnumerationTypeOf
in interfaceIReflectiveModel
- Throws:
EolNotAnEnumerationValueException
- when literal is not an enumeration value
-
getEnumerationLabelOf
public String getEnumerationLabelOf(Object literal) throws EolNotAnEnumerationValueException
Description copied from interface:IReflectiveModel
Returns the enumeration label of the literal parameter.- Specified by:
getEnumerationLabelOf
in interfaceIReflectiveModel
- Throws:
EolNotAnEnumerationValueException
- when literal is not an enumeration value
-
preventLoadingOfExternalModelElements
public boolean preventLoadingOfExternalModelElements()
Description copied from interface:IReflectiveModel
Prevents the loading of model elements that are referenced by this model but are not contained in this model. This is useful for clients, such as Epsilon Flock, which create a clone or conservative copy of this model.- Specified by:
preventLoadingOfExternalModelElements
in interfaceIReflectiveModel
- Returns:
- true iff this method had an effect (i.e. when this model supports external references, was configured to load external references and is no longer configured to load external references).
-
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.
-
dispose
public void dispose()
-
isLoaded
public boolean isLoaded()
- Since:
- 1.6
-
-