Class RecordDeclaration


  • public class RecordDeclaration
    extends AbstractTypeDeclaration
    Record declaration AST node type (added in JLS14 API).
     RecordDeclaration:
         [ Javadoc ] { ExtendedModifier } record Identifier
                    [ < TypeParameter > ]
                    (
                    [ FormalParameter { , FormalParameter } ]
                    ) { Dimension }
                    [ implements Type { , Type } ]
                    [ ; { RecordBodyDeclaration | ; } ]
     
    The AbstractTypeDeclaration.bodyDeclarations() list holds the class body declarations that appear after the semicolon.

    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 first modifier or annotation (if present), or the first character of the "record" keyword (if no modifiers or annotations). The source range extends through the last character of the "}" token following the body declarations.

    Since:
    3.22
    Restriction:
    This class is not intended to be referenced by clients as it is a part of Java preview feature.
    Restriction:
    This class is not intended to be instantiated by clients.
    • Method Detail

      • setRestrictedIdentifierStartPosition

        public void setRestrictedIdentifierStartPosition​(int restrictedIdentifierStartPosition)
      • getRestrictedIdentifierStartPosition

        public int getRestrictedIdentifierStartPosition()
      • 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.22
        Restriction:
        This method is not intended to be referenced by clients.
      • propertyDescriptors

        public static List propertyDescriptors​(int apiLevel,
                                               boolean previewEnabled)
        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
        previewEnabled - the previewEnabled flag
        Returns:
        a list of property descriptors (element type: StructuralPropertyDescriptor)
        Since:
        3.22
        Restriction:
        This method is not intended to be referenced by clients.
      • typeParameters

        public List typeParameters()
        Returns the live ordered list of type parameters of this type declaration (added in JLS3 API). This list is non-empty for parameterized types.
        Returns:
        the live list of type parameters (element type: TypeParameter)
        Since:
        3.22
      • superInterfaceTypes

        public List superInterfaceTypes()
        Returns the live ordered list of superinterfaces of this type declaration (added in JLS3 API). For a class declaration, these are the interfaces that this class implements; for an interface declaration, these are the interfaces that this interface extends.
        Returns:
        the live list of interface types (element type: Type)
        Since:
        3.22
      • recordComponents

        public List recordComponents()
        Returns the live ordered list of recordComponents of record declaration.
        Returns:
        the live list of recordComponents (element type: SingleVariableDeclaration)
        Since:
        3.22
      • getFields

        public FieldDeclaration[] getFields()
        Returns the ordered list of field declarations of this type declaration. For a class declaration, these are the field declarations; for an interface declaration, these are the constant declarations.

        This convenience method returns this node's body declarations with non-fields filtered out. Unlike bodyDeclarations, this method does not return a live result.

        Returns:
        the (possibly empty) list of field declarations
      • getMethods

        public MethodDeclaration[] getMethods()
        Returns the ordered list of method declarations of this type declaration.

        This convenience method returns this node's body declarations with non-methods filtered out. Unlike bodyDeclarations, this method does not return a live result.

        Returns:
        the (possibly empty) list of method (and constructor) declarations
      • getTypes

        public RecordDeclaration[] getTypes()
        Returns the ordered list of member type declarations of this type declaration.

        This convenience method returns this node's body declarations with non-types filtered out. Unlike bodyDeclarations, this method does not return a live result.

        Returns:
        the (possibly empty) list of member type declarations