## org.eclipse.emf.codegen.merge.java.facade.ast
Class ASTNodeConverter.TypeToEnumConverter

    java.lang.Object
      org.eclipse.emf.codegen.merge.java.facade.ast.ASTNodeConverter.Converter
          org.eclipse.emf.codegen.merge.java.facade.ast.ASTNodeConverter.TypeToEnumConverter

Enclosing class:
  ASTNodeConverter

    protected class ASTNodeConverter.TypeToEnumConverter

extends ASTNodeConverter.Converter

Converter of type to enum.

See Also:
  `convert()`

Field Summary
`protected org.eclipse.jdt.core.dom.AST` `ast` AST of the source and converted node
`protected java.util.Map<java.lang.String,ASTJField>` `fieldNamesMap` Map of field names to fields
`protected ASTJType` `type` Type that will be converted
`protected java.util.List<JNode>` `typeChildren` List of children of the type

Constructor Summary
`ASTNodeConverter.TypeToEnumConverter(ASTJType type)`

Method Summary
`ASTJEnum` `convert()` Converts type to the enum.
`protected ASTJNode<?>` `convertFieldToEnumConst(ASTJField field)` Converts given field to enum constant if possible.
`protected void` `setEnumConstantArgumentsAndBody(ASTJEnumConstant enumConstant, ASTJField field)` Sets arguments and body of the enum constant from the initializer of the given field.

Methods inherited from class org.eclipse.emf.codegen.merge.java.facade.ast.ASTNodeConverter.Converter
`moveChildren, replaceNode`

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

Field Detail

### type

    protected ASTJType type

  Type that will be converted

### ast

    protected org.eclipse.jdt.core.dom.AST ast

  AST of the source and converted node

### typeChildren

    protected java.util.List<JNode> typeChildren

  List of children of the type

### fieldNamesMap

    protected java.util.Map<java.lang.String,ASTJField> fieldNamesMap

  Map of field names to fields

Constructor Detail

### ASTNodeConverter.TypeToEnumConverter

    public ASTNodeConverter.TypeToEnumConverter(ASTJType type)

Parameters:
  `type` - to convert to enum

Method Detail

### convert

    public ASTJEnum convert()

  Converts type to the enum.

  Name, flags, comment, super interfaces of the enum are set from the type.

  All children of the type is added to the enum.

  Fields that are `public static final` and have the same type are converted to enum constants. Arguments of the enum constants are set from arguments of the initializer. Arguments that match the name of any other field are replaced by initializer value of that field.

  Conversion must be done only once for the same type.

  Specified by:
    `convert` in class `ASTNodeConverter.Converter`
  Returns:
    converted type, or `null` if conversion not possible

### convertFieldToEnumConst

    protected ASTJNode<?> convertFieldToEnumConst(ASTJField field)

  Converts given field to enum constant if possible.

  Field must be declared as `public static final` field, and field must be of the same type as its parent (e.g. type).

  Enum constant arguments and body is set from the original initializer of the field.

  Parameters:
    `field` - to convert
  Returns:
    original field if conversion not possible, or converted field otherwise
  See Also:
    `setEnumConstantArgumentsAndBody(ASTJEnumConstant, ASTJField)`

### setEnumConstantArgumentsAndBody

    protected void setEnumConstantArgumentsAndBody(ASTJEnumConstant enumConstant,
                                                   ASTJField field)

  Sets arguments and body of the enum constant from the initializer of the given field.

  Note that the original field's initializer node structure is used (e.g. if `ASTJField.setInitializer(String)` has been called, this method will use the original initializer of the field).

  Parameters:
    `enumConstant` -
    `field` -

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