Class SourceField

All Implemented Interfaces:
IAnnotatable, IField, IJavaElement, IMember, IParent, ISourceManipulation, ISourceReference, org.eclipse.core.runtime.IAdaptable
Direct Known Subclasses:
ResolvedSourceField

public class SourceField extends NamedMember implements IField
See Also:
IField
  • Constructor Details

    • SourceField

      protected SourceField(JavaElement parent, String name)
      Constructs a handle to the field with the given name in the specified type.
  • Method Details

    • equals

      public boolean equals(Object o)
      Description copied from class: JavaElement
      Returns true if this handle represents the same Java element as the given handle. By default, two handles represent the same element if they are identical or if they represent the same type of element, have equal names, parents, and occurrence counts.

      If a subclass has other requirements for equality, this method must be overridden.

      Overrides:
      equals in class SourceRefElement
      See Also:
      Object.equals(java.lang.Object)
    • findNode

      public ASTNode findNode(CompilationUnit ast)
      Description copied from class: SourceRefElement
      Returns the ASTNode that corresponds to this JavaElement or null if there is no corresponding node.
      Overrides:
      findNode in class SourceRefElement
    • getConstant

      public Object getConstant() throws JavaModelException
      Description copied from interface: IField
      Returns the constant value associated with this field or null if this field has none. To have a constant value, the field needs to be final and initialized with a compile-time constant expression.

      For types from source, this currently only works if the field initializer is a literal (returns null for more complex constant expressions).

      For primitive types, returns the boxed value.

      Specified by:
      getConstant in interface IField
      Returns:
      the constant value associated with this field, or null if not available
      Throws:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
      See Also:
      IField
    • getElementType

      public int getElementType()
      Description copied from interface: IJavaElement
      Returns this element's kind encoded as an integer. This is a handle-only method.
      Specified by:
      getElementType in interface IJavaElement
      Returns:
      the kind of element; one of the constants declared in IJavaElement
      See Also:
      IJavaElement
    • getKey

      public String getKey()
      Description copied from interface: IField
      Returns the binding key for this field only if the given field is resolved. A binding key is a key that uniquely identifies this field. It allows access to generic info for parameterized fields.

      If the given field is not resolved, the returned key is simply the java element's key.

      Specified by:
      getKey in interface IField
      Returns:
      the binding key for this field
      See Also:
      IBinding.getKey(), BindingKey, IField.isResolved()
    • getHandleMementoDelimiter

      protected char getHandleMementoDelimiter()
      Description copied from class: JavaElement
      Returns the char that marks the start of this handles contribution to a memento.
      Overrides:
      getHandleMementoDelimiter in class Member
      See Also:
      JavaElement.getHandleMemento()
    • getPrimaryElement

      public JavaElement getPrimaryElement(boolean checkOwner)
      Overrides:
      getPrimaryElement in class JavaElement
    • getTypeSignature

      public String getTypeSignature() throws JavaModelException
      Description copied from interface: IField
      Returns the type signature of this field. For enum constants, this returns the signature of the declaring enum class.

      The type signature may be either unresolved (for source types) or resolved (for binary types), and either basic (for basic types) or rich (for parameterized types). See Signature for details.

      Specified by:
      getTypeSignature in interface IField
      Returns:
      the type signature of this field
      Throws:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
      See Also:
      IField
    • isEnumConstant

      public boolean isEnumConstant() throws JavaModelException
      Description copied from interface: IField
      Returns whether this field represents an enum constant.
      Specified by:
      isEnumConstant in interface IField
      Returns:
      whether this field represents an enum constant
      Throws:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
    • isResolved

      public boolean isResolved()
      Description copied from interface: IField
      Returns whether this field represents a resolved field. If a field is resolved, its key contains resolved information.
      Specified by:
      isResolved in interface IField
      Returns:
      whether this field represents a resolved field.
    • resolved

      public JavaElement resolved(Binding binding)
      Overrides:
      resolved in class JavaElement
    • toStringInfo

      protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo)
      Description copied from class: JavaElement
      Debugging purposes
      Overrides:
      toStringInfo in class JavaElement
      showResolvedInfo - TODO
    • isRecordComponent

      public boolean isRecordComponent() throws JavaModelException
      Description copied from interface: IField
      Returns whether this field represents a record component.
      Specified by:
      isRecordComponent in interface IField
      Returns:
      whether this field represents a record component.
      Throws:
      JavaModelException