public final class ElementUtilities extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ElementUtilities.ElementAcceptor
Filter
Element s |
Modifier and Type | Method and Description |
---|---|
boolean |
alreadyDefinedIn(CharSequence name,
ExecutableType method,
TypeElement enclClass)
Returns true if a method specified by name and type is defined in a
class type.
|
Element |
elementFor(com.sun.javadoc.Doc doc)
Find a
Element corresponding to a given Doc . |
TypeElement |
enclosingTypeElement(Element element)
Returns the type element within which this member or constructor
is declared.
|
Element |
findElement(String description)
Looks up the given Java element.
|
List<? extends ExecutableElement> |
findUnimplementedMethods(TypeElement impl)
Find all methods in given type and its supertypes, which are not implemented.
|
static String |
getBinaryName(TypeElement element)
Returns a binary name of a type.
|
Iterable<? extends TypeElement> |
getGlobalTypes(ElementUtilities.ElementAcceptor acceptor)
Return
TypeElement s:
which are imported
which are in the same package as the current file
which are in the java.lang package
|
Element |
getImplementationOf(ExecutableElement method,
TypeElement origin)
Returns the implementation of a method in class origin; null if none exists.
|
Iterable<? extends Element> |
getLocalMembersAndVars(Scope scope,
ElementUtilities.ElementAcceptor acceptor)
Return members declared in the given scope.
|
Iterable<? extends Element> |
getLocalVars(Scope scope,
ElementUtilities.ElementAcceptor acceptor)
Return variables declared in the given scope.
|
Iterable<? extends Element> |
getMembers(TypeMirror type,
ElementUtilities.ElementAcceptor acceptor)
Returns all members of a type, whether inherited or
declared directly.
|
ExecutableElement |
getOverriddenMethod(ExecutableElement method)
Returns the parent method which the specified method overrides, or null
if the method does not override a parent class method.
|
boolean |
implementsMethod(ExecutableElement element)
Returns true if this element represents a method which
implements a method in an interface the parent class implements.
|
boolean |
isEffectivelyFinal(VariableElement e)
Check whether the given variable is effectively final or final.
|
boolean |
isErroneous(Element e)
Checks whether 'e' contains error or is missing.
|
boolean |
isLocal(Element element)
Returns true if the element is declared (directly or indirectly) local
to a method or variable initializer.
|
boolean |
isMemberOf(Element e,
TypeElement type)
Returns true if a type element has the specified element as a member.
|
boolean |
isSynthetic(Element element)
Returns true if the given element is synthetic.
|
com.sun.javadoc.Doc |
javaDocFor(Element element)
Get javadoc for given element.
|
TypeElement |
outermostTypeElement(Element element)
The outermost TypeElement which indirectly encloses this element.
|
boolean |
overridesMethod(ExecutableElement element)
Returns true if this element represents a method which overrides a
method in one of its superclasses.
|
public TypeElement enclosingTypeElement(Element element) throws IllegalArgumentException
IllegalArgumentException
- if the provided element is a package elementpublic TypeElement outermostTypeElement(Element element)
public Element getImplementationOf(ExecutableElement method, TypeElement origin)
public boolean isSynthetic(Element element)
element
- to checkpublic boolean overridesMethod(ExecutableElement element)
public static String getBinaryName(TypeElement element) throws IllegalArgumentException
element
- for which the binary name should be returnedIllegalArgumentException
- when the element is not a javac elementpublic com.sun.javadoc.Doc javaDocFor(Element element)
public Element elementFor(com.sun.javadoc.Doc doc)
Element
corresponding to a given Doc
.public Iterable<? extends Element> getMembers(TypeMirror type, ElementUtilities.ElementAcceptor acceptor)
type
- the type being examinedacceptor
- to filter the membersElements.getAllMembers(javax.lang.model.element.TypeElement)
public Iterable<? extends Element> getLocalMembersAndVars(Scope scope, ElementUtilities.ElementAcceptor acceptor)
public Iterable<? extends Element> getLocalVars(Scope scope, ElementUtilities.ElementAcceptor acceptor)
public Iterable<? extends TypeElement> getGlobalTypes(ElementUtilities.ElementAcceptor acceptor)
TypeElement
s:
public boolean isLocal(Element element)
public boolean alreadyDefinedIn(CharSequence name, ExecutableType method, TypeElement enclClass)
public boolean isMemberOf(Element e, TypeElement type)
public ExecutableElement getOverriddenMethod(ExecutableElement method)
public boolean implementsMethod(ExecutableElement element)
public List<? extends ExecutableElement> findUnimplementedMethods(TypeElement impl)
type
- to inspectpublic boolean isErroneous(@NullAllowed Element e)
e
- Element to check or null
null
) or contains errors.public boolean isEffectivelyFinal(VariableElement e)
e
- variable to check for effectively final status@CheckForNull public Element findElement(@NonNull String description)
elementDescription
format is as follows:
.
field name.
method name(
comma separated parameter types)
.
simple name of enclosing type(
comma separated parameter types)
elementDescription
- the description of the element that should be checked for existenceBuilt on August 25 2014. | Portions Copyright 1997-2014 Oracle. All rights reserved.