Class FieldDeclaration


public class FieldDeclaration extends BodyDeclaration
Field declaration node type.

This kind of node collects several variable declaration fragments (VariableDeclarationFragment) into a single body declaration (BodyDeclaration), all sharing the same modifiers and base type.

 FieldDeclaration:
    [Javadoc] { ExtendedModifier } Type VariableDeclarationFragment
         { , VariableDeclarationFragment } ;
 

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 initial modifier or type. The source range extends through the last character of the final ";".

Since:
2.0
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)
      Since:
      3.0
    • getType

      public Type getType()
      Returns the base type declared in this field declaration.

      N.B. The individual child variable declaration fragments may specify additional array dimensions. So the type of the variable are not necessarily exactly this type.

      Returns:
      the base type
    • setType

      public void setType(Type type)
      Sets the base type declared in this field declaration to the given type.
      Parameters:
      type - the new base type
      Throws:
      IllegalArgumentException - if:
      • the node belongs to a different AST
      • the node already has a parent
    • fragments

      public List fragments()
      Returns the live list of variable declaration fragments in this field declaration. Adding and removing nodes from this list affects this node dynamically. All nodes in this list must be VariableDeclarationFragments; attempts to add any other type of node will trigger an exception.
      Returns:
      the live list of variable declaration fragments in this statement (element type: VariableDeclarationFragment)