Package org.eclipse.jdt.core
Interface IField
- All Superinterfaces:
org.eclipse.core.runtime.IAdaptable,IAnnotatable,IJavaElement,IMember,IParent,ISourceManipulation,ISourceReference
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
Modifier and TypeMethodDescriptionReturns the constant value associated with this field ornullif this field has none.Returns the simple name of this field.getKey()Returns the binding key for this field only if the given field isresolved.Returns the type signature of this field.booleanReturns whether this field represents an enum constant.booleanReturns whether this field represents a record component.booleanReturns whether this field represents a resolved field.Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapterMethods inherited from interface org.eclipse.jdt.core.IAnnotatable
getAnnotation, getAnnotationsMethods inherited from interface org.eclipse.jdt.core.IJavaElement
exists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getElementType, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnownMethods inherited from interface org.eclipse.jdt.core.IMember
getCategories, getClassFile, getCompilationUnit, getDeclaringType, getFlags, getJavadocRange, getOccurrenceCount, getType, getTypeRoot, isBinaryMethods inherited from interface org.eclipse.jdt.core.IParent
getChildren, hasChildrenMethods inherited from interface org.eclipse.jdt.core.ISourceManipulation
copy, delete, move, renameMethods inherited from interface org.eclipse.jdt.core.ISourceReference
exists, getNameRange, getSource, getSourceRange
-
Method Details
-
getConstant
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:
-
getTypeSignature
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:
-
isEnumConstant
Returns 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
Returns whether this field represents a record component.- Returns:
- whether this field represents a record component.
- Throws:
JavaModelException- Since:
- 3.26
-