public interface IBinding
IPackageBinding
,
ITypeBinding
,
IVariableBinding
,
IMethodBinding
,
IAnnotationBinding
,
IMemberValuePairBinding
Modifier and Type | Field and Description |
---|---|
static int |
ANNOTATION
Kind constant (value 5) indicating an annotation binding.
|
static int |
MEMBER_VALUE_PAIR
Kind constant (value 6) indicating a member value pair binding.
|
static int |
METHOD
Kind constant (value 4) indicating a method or constructor binding.
|
static int |
PACKAGE
Kind constant (value 1) indicating a package binding.
|
static int |
TYPE
Kind constant (value 2) indicating a type binding.
|
static int |
VARIABLE
Kind constant (value 3) indicating a field or local variable binding.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
There is no special definition of equality for bindings; equality is
simply object identity.
|
IAnnotationBinding[] |
getAnnotations()
Returns the resolved declaration annotations associated with this binding.
|
IJavaElement |
getJavaElement()
Returns the Java element that corresponds to this binding.
|
String |
getKey()
Returns the key for this binding.
|
int |
getKind()
Returns the kind of bindings this is.
|
int |
getModifiers()
Returns the modifiers for this binding.
|
String |
getName()
Returns the name of this binding.
|
boolean |
isDeprecated()
Return whether this binding is for something that is deprecated.
|
boolean |
isEqualTo(IBinding binding)
Returns whether this binding has the same key as that of the given
binding.
|
boolean |
isRecovered()
Return whether this binding is created because the bindings recovery is enabled.
|
boolean |
isSynthetic()
Returns whether this binding is synthetic.
|
String |
toString()
Returns a string representation of this binding suitable for debugging
purposes only.
|
static final int PACKAGE
IPackageBinding
.getKind()
,
IPackageBinding
,
Constant Field Valuesstatic final int TYPE
ITypeBinding
.getKind()
,
ITypeBinding
,
Constant Field Valuesstatic final int VARIABLE
IVariableBinding
.getKind()
,
IVariableBinding
,
Constant Field Valuesstatic final int METHOD
IMethodBinding
.getKind()
,
IMethodBinding
,
Constant Field Valuesstatic final int ANNOTATION
IAnnotationBinding
.getKind()
,
IAnnotationBinding
,
Constant Field Valuesstatic final int MEMBER_VALUE_PAIR
IMemberValuePairBinding
.getKind()
,
IMemberValuePairBinding
,
Constant Field ValuesIAnnotationBinding[] getAnnotations()
Note: This method only returns declaration annotations.
Type annotations in the sense of JLS8 9.7.4 are not returned.
Type annotations can be retrieved via ITypeBinding.getTypeAnnotations()
.
int getKind()
PACKAGE
,
TYPE
,
VARIABLE
,
METHOD
,
ANNOTATION
,
or MEMBER_VALUE_PAIR
.
Note that additional kinds might be added in the future, so clients should not assume this list is exhaustive and should program defensively, e.g. by having a reasonable default in a switch statement.
String getName()
int getModifiers()
Note that 'deprecated' is not included among the modifiers.
Use isDeprecated
to find out whether a binding is deprecated.
Modifier
constantsModifier
boolean isDeprecated()
true
if this binding is deprecated, and
false
otherwiseboolean isRecovered()
true
if this binding is a recovered binding, and
false
otherwiseboolean isSynthetic()
IMethodBinding.isDefaultConstructor
for cases where the compiled-generated default constructor can be recognized
instead.true
if this binding is synthetic, and
false
otherwiseIMethodBinding.isDefaultConstructor()
IJavaElement getJavaElement()
null
if this binding has no corresponding
Java element.
For array types, this method returns the Java element that corresponds
to the array's element type. For raw and parameterized types, this method
returns the Java element of the erasure. For annotations, this method
returns the Java element of the annotation (i.e. an IAnnotation
).
Here are the cases where a null
should be expected:
null
.
null
if noneString getKey()
Within a single cluster of bindings (produced by the same call to an
ASTParser#create*(*)
method)), each binding has a distinct key.
The keys are generated in a manner that is predictable and as
stable as possible. This last property makes these keys useful for
comparing bindings between different clusters of bindings (for example,
the bindings between the "before" and "after" ASTs of the same
compilation unit).
The exact details of how the keys are generated is unspecified. However, it is a function of the following information:
The key for a type binding does not contain type annotations
,
so type bindings with different type annotations may have the same key (iff they denote the same un-annotated type).
By construction, this also applies to method bindings if their declaring types contain type annotations.
Note that the key for member value pair bindings is
not yet implemented. This method returns null
for that kind of bindings.
Recovered bindings have a unique key.
boolean equals(Object obj)
ASTParser#create*(*)
method),
each binding is represented by a separate object. However,
between different clusters of bindings, the binding objects may or may
not be different; in these cases, the client should compare bindings
using isEqualTo(IBinding)
, which is functionally equivalent to
checking their keys for equality.
Since JLS8, type bindings can contain type annotations
.
Note that type bindings that denote the same un-annotated type have the same key
,
but they are not identical if they contain different type annotations.
Type bindings that contain the same type annotations may or may not be identical.
equals
in class Object
obj
- ITypeBinding.getTypeDeclaration()
boolean isEqualTo(IBinding binding)
ASTParser#create*(*)
method), each
binding is represented by a distinct object. However, between
different clusters of bindings, the binding objects may or may
not be different objects; in these cases, the binding keys
are used where available.
Note that type bindings that only differ in their type annotations
have the same key
, and hence this method returns
true
for such type bindings. By construction of the key, this also applies
to method bindings if their declaring types contain type annotations.
binding
- the other binding, or null
true
if the given binding is the identical
object as this binding, or if the keys of both bindings are the
same string; false
if the given binding is
null
, or if the bindings do not have the same key,
or if one or both of the bindings have no keygetKey()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.