Package org.eclipse.jdt.core
Interface IField
-
- All Superinterfaces:
IAdaptable,IAnnotatable,IJavaElement,IMember,IParent,ISourceManipulation,ISourceReference
public interface IField extends IMember, IAnnotatable
Represents a field declared in a type.- Restriction:
- This interface is not intended to be implemented by clients.
-
-
Field Summary
-
Fields inherited from interface org.eclipse.jdt.core.IJavaElement
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_MODULE, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETER
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ObjectgetConstant()Returns the constant value associated with this field ornullif this field has none.StringgetElementName()Returns the simple name of this field.StringgetKey()Returns the binding key for this field only if the given field isresolved.StringgetTypeSignature()Returns the type signature of this field.booleanisEnumConstant()Returns whether this field represents an enum constant.booleanisRecordComponent()Returns whether this field represents a record component.booleanisResolved()Returns whether this field represents a resolved field.-
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
-
Methods inherited from interface org.eclipse.jdt.core.IAnnotatable
getAnnotation, getAnnotations
-
Methods inherited from interface org.eclipse.jdt.core.IJavaElement
exists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getElementType, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnown
-
Methods inherited from interface org.eclipse.jdt.core.IMember
getCategories, getClassFile, getCompilationUnit, getDeclaringType, getFlags, getJavadocRange, getOccurrenceCount, getType, getTypeRoot, isBinary
-
Methods inherited from interface org.eclipse.jdt.core.IParent
getChildren, hasChildren
-
Methods inherited from interface org.eclipse.jdt.core.ISourceManipulation
copy, delete, move, rename
-
Methods inherited from interface org.eclipse.jdt.core.ISourceReference
exists, getNameRange, getSource, getSourceRange
-
-
-
-
Method Detail
-
getConstant
Object getConstant() throws JavaModelException
Returns the constant value associated with this field ornullif 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
nullfor more complex constant expressions).For primitive types, returns the boxed value.
- Returns:
- the constant value associated with this field, or
nullif not available - Throws:
JavaModelException- if this element does not exist or if an exception occurs while accessing its corresponding resource
-
getElementName
String getElementName()
Returns the simple name of this field.- Specified by:
getElementNamein interfaceIJavaElement- Returns:
- the simple name of this field.
-
getKey
String getKey()
Returns the binding key for this field only if the given field isresolved. 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.
- Returns:
- the binding key for this field
- Since:
- 3.1
- See Also:
IBinding.getKey(),BindingKey,isResolved()
-
getTypeSignature
String getTypeSignature() throws JavaModelException
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
Signaturefor details.- 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:
Signature
-
isEnumConstant
boolean isEnumConstant() throws JavaModelExceptionReturns whether this field represents an enum constant.- 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- Since:
- 3.1
-
isResolved
boolean isResolved()
Returns whether this field represents a resolved field. If a field is resolved, its key contains resolved information.- Returns:
- whether this field represents a resolved field.
- Since:
- 3.1
-
isRecordComponent
boolean isRecordComponent() throws JavaModelExceptionReturns whether this field represents a record component.- Returns:
- whether this field represents a record component.
- Throws:
JavaModelException- Restriction:
- This method is not intended to be referenced by clients as it is a part of Java preview feature.
-
-