Class EnumConstantDeclaration


public class EnumConstantDeclaration extends BodyDeclaration
Enumeration constant declaration AST node type (added in JLS3 API).
 EnumConstantDeclaration:
     [ Javadoc ] { ExtendedModifier } Identifier
         [ ( [ Expression { , Expression } ] ) ]
         [ AnonymousClassDeclaration ]
 

When a Javadoc comment is present, the source range begins with the first character of the "/**" comment delimiter. When there is no Javadoc comment, the source range begins with the first character of the identifier. If there are class body declarations, the source range extends through the last character of the last character of the "}" token following the body declarations. If there are arguments but no class body declarations, the source range extends through the last character of the ")" token following the arguments. If there are no arguments and no class body declarations, the source range extends through the last character of the identifier.

Since:
3.1
Restriction:
This class is not intended to be instantiated by clients.
  • Field Details

  • Method Details

    • propertyDescriptors

      public static List propertyDescriptors(int apiLevel)
      Returns a list of structural property descriptors for this node type. Clients must not modify the result.
      Parameters:
      apiLevel - the API level; one of the AST.JLS* constants
      Returns:
      a list of property descriptors (element type: StructuralPropertyDescriptor)
    • getName

      public SimpleName getName()
      Returns the name of the constant declared in this enum declaration.
      Returns:
      the constant name node
    • setName

      public void setName(SimpleName constantName)
      Sets the name of the constant declared in this enum declaration to the given name.
      Parameters:
      constantName - the new constant name
      Throws:
      IllegalArgumentException - if:
      • the node belongs to a different AST
      • the node already has a parent
    • arguments

      public List arguments()
      Returns the live ordered list of argument expressions in this enumeration constant declaration. Note that an empty list of arguments is equivalent to not explicitly specifying arguments.
      Returns:
      the live list of argument expressions (element type: Expression)
    • getAnonymousClassDeclaration

      public AnonymousClassDeclaration getAnonymousClassDeclaration()
      Returns the anonymous class declaration introduced by this enum constant declaration, if it has one.
      Returns:
      the anonymous class declaration, or null if none
    • setAnonymousClassDeclaration

      public void setAnonymousClassDeclaration(AnonymousClassDeclaration decl)
      Sets whether this enum constant declaration declares an anonymous class (that is, has class body declarations).
      Parameters:
      decl - the anonymous class declaration, or null if none
    • resolveConstructorBinding

      public IMethodBinding resolveConstructorBinding()
      Resolves and returns the binding for the constructor invoked by this enum constant.

      Note that bindings are generally unavailable unless requested when the AST is being built.

      Returns:
      the constructor binding, or null if the binding cannot be resolved
    • resolveVariable

      public IVariableBinding resolveVariable()
      Resolves and returns the field binding for this enum constant.

      Note that bindings are generally unavailable unless requested when the AST is being built.

      Returns:
      the binding, or null if the binding cannot be resolved