Package org.eclipse.epsilon.emc.yaml
Class YamlModel
- java.lang.Object
-
- org.eclipse.epsilon.eol.models.Model
-
- org.eclipse.epsilon.eol.models.CachedModel<Map.Entry>
-
- org.eclipse.epsilon.emc.yaml.YamlModel
-
- All Implemented Interfaces:
AutoCloseable
,IOperationContributorProvider
,IModel
public class YamlModel extends CachedModel<Map.Entry> implements IOperationContributorProvider
-
-
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 List<Map.Entry>
createdNodes
protected File
file
protected Object
yamlContent
protected YamlModelOperationContributor
yamlModelOperationContributor
-
Fields inherited from class org.eclipse.epsilon.eol.models.CachedModel
allContentsCache, kindCache, PROPERTY_CACHED, PROPERTY_CONCURRENT, typeCache
-
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 YamlModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Collection<Map.Entry>
allContentsFromModel()
void
clear()
Map.Entry
createInstance(String type, Collection<Object> parameters)
protected Map.Entry
createInstanceInModel(String type)
protected boolean
deleteElementInModel(Object instance)
Returns true iff the given instance was deleted from the model.protected void
disposeModel()
protected Collection<Map.Entry>
getAllOfKindFromModel(String kind)
protected Collection<Map.Entry>
getAllOfTypeFromModel(String type)
protected Collection<String>
getAllTypeNamesOf(Object instance)
Returns the fully qualified names of every type to which the given object conforms.protected Object
getCacheKeyForType(String type)
Returns an identity for the given type, which will be used byCachedModel
as a key for the memoization of model elements by type.Object
getElementById(String id)
String
getElementId(Object instance)
Object
getEnumerationValue(String enumeration, String label)
File
getFile()
OperationContributor
getOperationContributor()
Object
getRoot()
String
getTypeNameOf(Object instance)
Returns a string representing the type of the instance object.Object
getTypeOf(Object instance)
Object
getYamlContent()
boolean
hasType(String type)
boolean
isInstantiable(String type)
boolean
isLoaded()
Convenience method for determining when a model has been loaded.boolean
isModelElement(Object instance)
Used to test whether a Java object can be contained by this model.void
load(StringProperties properties, IRelativePathResolver resolver)
protected void
loadModel()
boolean
owns(Object instance)
Used to test whether an object is contained in this model.void
setElementId(Object instance, String newId)
void
setFile(File file)
void
setRootAsList()
void
setRootAsMap()
void
setYamlContent(Object yamlContent)
void
setYamlContent(String yamlContent)
boolean
store()
boolean
store(String location)
-
Methods inherited from class org.eclipse.epsilon.eol.models.CachedModel
addToCache, allContents, clearCache, createInstance, deleteElement, dispose, getAllOfKind, getAllOfKindOrType, getAllOfType, initCaches, isCachingEnabled, isConcurrent, load, removeFromCache, setCachingEnabled, setConcurrent, wrap
-
Methods inherited from class org.eclipse.epsilon.eol.models.Model
allInstances, getAliases, getFullyQualifiedTypeNameOf, getMetamodel, getName, getPropertyGetter, getPropertySetter, getTransactionSupport, isOfKind, isOfType, isPropertySet, isReadOnLoad, isStoredOnDisposal, knowsAboutProperty, 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
-
-
-
-
Field Detail
-
file
protected File file
-
yamlContent
protected Object yamlContent
-
yamlModelOperationContributor
protected YamlModelOperationContributor yamlModelOperationContributor
-
-
Method Detail
-
clear
public void clear()
-
getYamlContent
public Object getYamlContent()
-
setYamlContent
public void setYamlContent(Object yamlContent)
-
setYamlContent
public void setYamlContent(String yamlContent)
-
getRoot
public Object getRoot()
-
setRootAsList
public void setRootAsList()
-
setRootAsMap
public void setRootAsMap()
-
getFile
public File getFile()
-
setFile
public void setFile(File file)
-
isLoaded
public boolean isLoaded()
Description copied from class:CachedModel
Convenience method for determining when a model has been loaded.- Overrides:
isLoaded
in classCachedModel<Map.Entry>
- Returns:
- Whether the cache has been populated.
-
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.
-
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
-
owns
public boolean owns(Object instance)
Description copied from interface:IModel
Used to test whether an object is contained in this model.
-
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
- Overrides:
isModelElement
in classModel
- Parameters:
instance
- the Java object to test.- Returns:
- true if and only if instance can be contained by this model.
-
allContentsFromModel
protected Collection<Map.Entry> allContentsFromModel()
- Specified by:
allContentsFromModel
in classCachedModel<Map.Entry>
-
getAllOfTypeFromModel
protected Collection<Map.Entry> getAllOfTypeFromModel(String type) throws EolModelElementTypeNotFoundException
- Specified by:
getAllOfTypeFromModel
in classCachedModel<Map.Entry>
- Throws:
EolModelElementTypeNotFoundException
-
getAllOfKindFromModel
protected Collection<Map.Entry> getAllOfKindFromModel(String kind) throws EolModelElementTypeNotFoundException
- Specified by:
getAllOfKindFromModel
in classCachedModel<Map.Entry>
- Throws:
EolModelElementTypeNotFoundException
-
createInstanceInModel
protected Map.Entry createInstanceInModel(String type) throws EolModelElementTypeNotFoundException
- Specified by:
createInstanceInModel
in classCachedModel<Map.Entry>
- Throws:
EolModelElementTypeNotFoundException
-
createInstance
public Map.Entry createInstance(String type, Collection<Object> parameters) throws EolModelElementTypeNotFoundException
- Specified by:
createInstance
in interfaceIModel
- Overrides:
createInstance
in classModel
- Throws:
EolModelElementTypeNotFoundException
-
disposeModel
protected void disposeModel()
- Specified by:
disposeModel
in classCachedModel<Map.Entry>
-
deleteElementInModel
protected boolean deleteElementInModel(Object instance) throws EolRuntimeException
Description copied from class:CachedModel
Returns true iff the given instance was deleted from the model.- Specified by:
deleteElementInModel
in classCachedModel<Map.Entry>
- Throws:
EolRuntimeException
-
getCacheKeyForType
protected Object getCacheKeyForType(String type) throws EolModelElementTypeNotFoundException
Description copied from class:CachedModel
Returns an identity for the given type, which will be used byCachedModel
as a key for the memoization of model elements by type.- Specified by:
getCacheKeyForType
in classCachedModel<Map.Entry>
- Throws:
EolModelElementTypeNotFoundException
-
getAllTypeNamesOf
protected Collection<String> getAllTypeNamesOf(Object instance)
Description copied from class:CachedModel
Returns the fully qualified names of every type to which the given object conforms. The values are used by byCachedModel
for the memoization of model elements by their kind (CachedModel.getAllOfKind(String)
).- Specified by:
getAllTypeNamesOf
in classCachedModel<Map.Entry>
-
loadModel
protected void loadModel() throws EolModelLoadingException
- Specified by:
loadModel
in classCachedModel<Map.Entry>
- Throws:
EolModelLoadingException
-
load
public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException
- Specified by:
load
in interfaceIModel
- Overrides:
load
in classCachedModel<Map.Entry>
- Throws:
EolModelLoadingException
-
getOperationContributor
public OperationContributor getOperationContributor()
- Specified by:
getOperationContributor
in interfaceIOperationContributorProvider
-
-