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 java.lang.Object
    implements IModel

The EMF implementation of `IModel`.

### Field Summary

Fields
`protected java.util.Map<org.eclipse.emf.ecore.EClass,​java.util.Set<org.eclipse.emf.ecore.EObject>>` `elementsByType`
`protected EMFReferenceModel` `referenceModel` The metamodel.

### Constructor Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `commitToResource()` Finalizes the model.
`protected void` `finalize()`
`java.util.Set<org.eclipse.emf.ecore.EObject>` `getElementsByType​(java.lang.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​(java.lang.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.
`java.lang.Object` `newElement​(java.lang.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 Detail

#### referenceModel

    protected EMFReferenceModel referenceModel

The metamodel.

#### elementsByType

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

### Constructor Detail

#### 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 Detail

#### newElement

    public java.lang.Object newElement​(java.lang.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 java.util.Set<org.eclipse.emf.ecore.EObject> getElementsByType​(java.lang.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​(java.lang.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 java.lang.Throwable

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