Package org.eclipse.m2m.atl.core.emf

# Class EMFModel

java.lang.Object
org.eclipse.m2m.atl.core.emf.EMFModel

All Implemented Interfaces:
  `IModel`

Direct Known Subclasses:
  `AtlResourceImpl.EMFModelWrapper`, `EMFReferenceModel`

public class EMFModel extends Object implements IModel
The EMF implementation of `IModel`.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Map<org.eclipse.emf.ecore.EClass,Set<org.eclipse.emf.ecore.EObject>>`
`elementsByType`
`protected EMFReferenceModel`
`referenceModel`
The metamodel.

## Constructor Summary

Constructors
Constructor
Description
`EMFModel(EMFReferenceModel referenceModel, EMFModelFactory mf)`
Creates a new `EMFModel` conforming to the given `EMFReferenceModel`.

## Method Summary

Modifier and Type
Method
Description
`void`
`commitToResource()`
Finalizes the model.
`protected void`
`finalize()`
`Set<org.eclipse.emf.ecore.EObject>`
`getElementsByType(Object metaElement)`
Returns a `Set` of the elements matching the given type.
`EMFModelFactory`
`getModelFactory()`
Returns the ModelFactory used to create the current model.
`EMFReferenceModel`
`getReferenceModel()`
Returns the `IReferenceModel` (i.e.
`org.eclipse.emf.ecore.resource.Resource`
`getResource()`
Returns the resource.
`boolean`
`isModelOf(Object object)`
Returns true if the given object is contained in this model's resource or a referenced resource.
`boolean`
`isTarget()`
Defines if the model is readonly or not.
`Object`
`newElement(Object metaElement)`
Creates a new element in the model.
`void`
`setIsTarget(boolean value)`
Sets if the model is readonly or not.
`protected void`
`setResource(org.eclipse.emf.ecore.resource.Resource resource)`
Sets the resource with the resource value.

### Methods inherited from class java.lang.Object

`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### referenceModel

protected EMFReferenceModel referenceModel
The metamodel.

### elementsByType

protected Map<org.eclipse.emf.ecore.EClass,Set<org.eclipse.emf.ecore.EObject>> elementsByType

## Constructor Details

### EMFModel

public EMFModel(EMFReferenceModel referenceModel, EMFModelFactory mf)
Creates a new `EMFModel` conforming to the given `EMFReferenceModel`.

Parameters:
  `referenceModel` - the metamodel.
  `mf` - the model factory that is creating this model.

## Method Details

### newElement

public Object newElement(Object metaElement)
Creates a new element in the model.

Specified by:
  `newElement` in interface `IModel`
Parameters:
  `metaElement` - the new element metatype
Returns:
  the newly created element
See Also:
  - `IModel.newElement(java.lang.Object)`

### getReferenceModel

public EMFReferenceModel getReferenceModel()
Returns the `IReferenceModel` (i.e. the metamodel).

Specified by:
  `getReferenceModel` in interface `IModel`
Returns:
  the `IReferenceModel`
See Also:
  - `IModel.getReferenceModel()`

### getElementsByType

public Set<org.eclipse.emf.ecore.EObject> getElementsByType(Object metaElement)
Returns a `Set` of the elements matching the given type.

Specified by:
  `getElementsByType` in interface `IModel`
Parameters:
  `metaElement` - a metatype
Returns:
  a `Set` of the elements matching the given type
See Also:
  - `IModel.getElementsByType(java.lang.Object)`

### isTarget

public boolean isTarget()
Defines if the model is readonly or not.

Specified by:
  `isTarget` in interface `IModel`
Returns:
  true if the model allows writing
See Also:
  - `IModel.isTarget()`

### setIsTarget

public void setIsTarget(boolean value)
Sets if the model is readonly or not.

Specified by:
  `setIsTarget` in interface `IModel`
Parameters:
  `value` - true if the model allows writing
See Also:
  - `IModel.setIsTarget(boolean)`

### getResource

public org.eclipse.emf.ecore.resource.Resource getResource()
Returns the resource.

Returns:
  the resource

### setResource

protected void setResource(org.eclipse.emf.ecore.resource.Resource resource)
Sets the resource with the resource value.

Parameters:
  `resource` - the resource to set

### getModelFactory

public EMFModelFactory getModelFactory()
Returns the ModelFactory used to create the current model.

Specified by:
  `getModelFactory` in interface `IModel`
Returns:
  true if the model allows writing
See Also:
  - `IModel.getModelFactory()`

### commitToResource

public void commitToResource()
Finalizes the model.

### isModelOf

public boolean isModelOf(Object object)
Returns true if the given object is contained in this model's resource or a referenced resource.

Specified by:
  `isModelOf` in interface `IModel`
Parameters:
  `object` - the model element
Returns:
  true if object is contained in this model's resource or a referenced resource
See Also:
  - `IModel.isModelOf(java.lang.Object)`

### finalize

protected void finalize() throws Throwable

Overrides:
  `finalize` in class `Object`
Throws:
  `Throwable`
See Also:
  - `Object.finalize()`