## org.eclipse.emf.codegen.ecore.genmodel.generator
Class GenModelGeneratorAdapterFactory

    java.lang.Object
      org.eclipse.emf.common.notify.impl.AdapterFactoryImpl
          org.eclipse.emf.codegen.ecore.genmodel.util.GenModelAdapterFactory
              org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapterFactory

All Implemented Interfaces:
  GeneratorAdapterFactory, AdapterFactory

    public class GenModelGeneratorAdapterFactory

extends GenModelAdapterFactory
implements GeneratorAdapterFactory

A generator adapter factory for the `GenModel package`. This implementation creates the adapters that perform default EMF code generation. It can also be subclassed to create derived adapters that remove from or change the default code generation, or to create separate adapters that augment the default code generation.

The factory implements a singleton adapter pattern, where one adapter is cached and reused for all objects of a given type.

This implementation also initializes its generator's options based on the `GenModel`.

Since:
  2.2.0

Nested Class Summary

Nested classes/interfaces inherited from interface org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory
`GeneratorAdapterFactory.Descriptor`

Field Summary
`static GeneratorAdapterFactory.Descriptor` `DESCRIPTOR` A descriptor for this adapter factory, which can be used to programatically `register` it.
`protected GenBaseGeneratorAdapter` `genClassGeneratorAdapter`
`protected GenBaseGeneratorAdapter` `genEnumGeneratorAdapter`
`protected Generator` `generator`
`protected GenBaseGeneratorAdapter` `genModelGeneratorAdapter`
`protected GenBaseGeneratorAdapter` `genPackageGeneratorAdapter`
`protected static java.lang.String` `MERGE_RULES_PATH_NAME` The default JMerge rules file for EMF.

Fields inherited from class org.eclipse.emf.codegen.ecore.genmodel.util.GenModelAdapterFactory
`modelPackage, modelSwitch`

Constructor Summary
`GenModelGeneratorAdapterFactory()`

Method Summary
`Adapter` `adapt(Notifier target, java.lang.Object type)` Does an `adapt(Notifier, Object)`, substituting `this` for the given `type`.
`Adapter` `createGenClassAdapter()` Returns a singleton `GenClassGeneratorAdapter`.
`Adapter` `createGenEnumAdapter()` Returns a singleton `GenEnumGeneratorAdapter`.
`Adapter` `createGenModelAdapter()` Returns a singleton `GenModelGeneratorAdapter`.
`Adapter` `createGenPackageAdapter()` Returns a singleton `GenPackageGeneratorAdapter`.
`void` `dispose()` Disposes this adapter factory and all of the adapters it has created.
`Generator` `getGenerator()` Returns the `Generator` associated with this adapter factory.
`protected java.lang.String` `getMergeRulesURI(GenModel genModel)` Returns the URI of the merge rules file for the given `GenModel`.
`protected java.lang.String[]` `getTemplatePath(GenModel genModel)` Deprecated. org.eclipse.emf.codegen.ecore 2.2.2 Override `AbstractGeneratorAdapter.addBaseTemplatePathEntries(java.util.List)` and, if needed, `getMergeRulesURI(GenModel)`, instead.
`void` `initialize(java.lang.Object input)` Performs initialization for the given input `GenModel`.
`boolean` `isFactoryForType(java.lang.Object type)` Returns `true` when the type is `GeneratorAdapter.class`.
`void` `setGenerator(Generator generator)` Sets the `Generator` associated with this adapter factory.

Methods inherited from class org.eclipse.emf.codegen.ecore.genmodel.util.GenModelAdapterFactory
`createAdapter, createEObjectAdapter, createGenAnnotationAdapter, createGenBaseAdapter, createGenClassifierAdapter, createGenDataTypeAdapter, createGenEnumLiteralAdapter, createGenFeatureAdapter, createGenOperationAdapter, createGenParameterAdapter, createGenTypedElementAdapter, createGenTypeParameterAdapter`

Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterFactoryImpl
`adapt, adaptAllNew, adaptNew, associate, createAdapter, resolve`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.eclipse.emf.common.notify.AdapterFactory
`adapt, adaptAllNew, adaptNew`

Field Detail

### DESCRIPTOR

    public static final GeneratorAdapterFactory.Descriptor DESCRIPTOR

  A descriptor for this adapter factory, which can be used to programatically `register` it.

  See Also:
    `GeneratorAdapterFactory.Descriptor.Registry`

### MERGE_RULES_PATH_NAME

    protected static final java.lang.String MERGE_RULES_PATH_NAME

  The default JMerge rules file for EMF.

  See Also:
    Constant Field Values

### generator

    protected Generator generator

### genModelGeneratorAdapter

    protected GenBaseGeneratorAdapter genModelGeneratorAdapter

### genPackageGeneratorAdapter

    protected GenBaseGeneratorAdapter genPackageGeneratorAdapter

### genClassGeneratorAdapter

    protected GenBaseGeneratorAdapter genClassGeneratorAdapter

### genEnumGeneratorAdapter

    protected GenBaseGeneratorAdapter genEnumGeneratorAdapter

Constructor Detail

### GenModelGeneratorAdapterFactory

    public GenModelGeneratorAdapterFactory()

Method Detail

### isFactoryForType

    public boolean isFactoryForType(java.lang.Object type)

  Returns `true` when the type is `GeneratorAdapter.class`.

  Specified by:
    `isFactoryForType` in interface `AdapterFactory`
  Overrides:
    `isFactoryForType` in class `GenModelAdapterFactory`
  Parameters:
    `type` - the key indicating the type of adapter in question.
  Returns:
    whether this factory is applicable for the type of the object.
  See Also:
    `Adapter.isAdapterForType(java.lang.Object)`

### adapt

    public Adapter adapt(Notifier target,
                         java.lang.Object type)

  Does an `adapt(Notifier, Object)`, substituting `this` for the given `type`. This substitution is necessary because each of many generator adapter factories can have its own generator adapter on a single object.

  Specified by:
    `adapt` in interface `AdapterFactory`
  Overrides:
    `adapt` in class `AdapterFactoryImpl`
  Parameters:
    `target` - the notifier to adapt.
    `type` - the key indicating the type of adapter required.
  Returns:
    a previously existing associated adapter, a new associated adapter if possible, or `null` otherwise.
  See Also:
    `Adapter.setTarget(org.eclipse.emf.common.notify.Notifier)`, `AdapterFactory.adaptNew(org.eclipse.emf.common.notify.Notifier, java.lang.Object)`

### createGenModelAdapter

    public Adapter createGenModelAdapter()

  Returns a singleton `GenModelGeneratorAdapter`.

  Overrides:
    `createGenModelAdapter` in class `GenModelAdapterFactory`
  Returns:
    the new adapter.
  See Also:
    `GenModel`

### createGenPackageAdapter

    public Adapter createGenPackageAdapter()

  Returns a singleton `GenPackageGeneratorAdapter`.

  Overrides:
    `createGenPackageAdapter` in class `GenModelAdapterFactory`
  Returns:
    the new adapter.
  See Also:
    `GenPackage`

### createGenClassAdapter

    public Adapter createGenClassAdapter()

  Returns a singleton `GenClassGeneratorAdapter`.

  Overrides:
    `createGenClassAdapter` in class `GenModelAdapterFactory`
  Returns:
    the new adapter.
  See Also:
    `GenClass`

### createGenEnumAdapter

    public Adapter createGenEnumAdapter()

  Returns a singleton `GenEnumGeneratorAdapter`.

  Overrides:
    `createGenEnumAdapter` in class `GenModelAdapterFactory`
  Returns:
    the new adapter.
  See Also:
    `GenEnum`

### getGenerator

    public Generator getGenerator()

  Description copied from interface: `GeneratorAdapterFactory`
  Returns the `Generator` associated with this adapter factory.

  Specified by:
    `getGenerator` in interface `GeneratorAdapterFactory`
  See Also:
    `GeneratorAdapterFactory.setGenerator(Generator)`

### setGenerator

    public void setGenerator(Generator generator)

  Description copied from interface: `GeneratorAdapterFactory`
  Sets the `Generator` associated with this adapter factory.

  Specified by:
    `setGenerator` in interface `GeneratorAdapterFactory`
  See Also:
    `GeneratorAdapterFactory.getGenerator()`

### initialize

    public void initialize(java.lang.Object input)

  Performs initialization for the given input `GenModel`. It is used as the basis for setting `options` on the associated `Generator`.

  Specified by:
    `initialize` in interface `GeneratorAdapterFactory`

### getTemplatePath

    @Deprecated
    protected java.lang.String[] getTemplatePath(GenModel genModel)

  Deprecated. org.eclipse.emf.codegen.ecore 2.2.2 Override `AbstractGeneratorAdapter.addBaseTemplatePathEntries(java.util.List)` and, if needed, `getMergeRulesURI(GenModel)`, instead.

  Computes the template path for the given `GenModel`. The result of this method was intended to be used in setting the generator's `templatePath` option. However, a single path for all code generation is actually insufficient. The path needs to be specified and extended on a per-adapter basis.

  If this implementation is not overridden, the generator's `templatePath` will no longer be set to the default value. Instead, it will be left null, and template paths will be computed on a per-adapter basis using `AbstractGeneratorAdapter.addBaseTemplatePathEntries(java.util.List)`.

  In order to preserve backwards compatibility, if this implementation is overridden to return something other than the default, the generator's `templatePath` will be set to this result.

  Previously, this path was also searched to obtain the value to set as the generator's `mergeRulesURI` option. Now, if this method is not overridden, the new `getMergeRulesURI(GenModel)` method will be invoked to compute that value.

### getMergeRulesURI

    protected java.lang.String getMergeRulesURI(GenModel genModel)

  Returns the URI of the merge rules file for the given `GenModel`.

  The default implementation of this method is to search the default path that would be returned by `getTemplatePath(GenModel)`, if not overridden, for a file called "emf-merge.xml", and return the URI of the first such file encountered. Since that method has been deprecated, this method can now be overridden to search a different path, or indeed, obtain the merge rules URI in some other way.

  This method is only invoked if `getTemplatePath(GenModel)` has not been overridden.

  Since:
    org.eclipse.emf.codegen.ecore 2.2.2

### dispose

    public void dispose()

  Description copied from interface: `GeneratorAdapterFactory`
  Disposes this adapter factory and all of the adapters it has created.

  Specified by:
    `dispose` in interface `GeneratorAdapterFactory`

Copyright 2001-2006 IBM Corporation and others. All Rights Reserved.