- All Superinterfaces:
AnnotatedConstruct
,Element
,Parameterizable
public interface ExecutableElement extends Element, Parameterizable
Represents a method, constructor, or initializer (static or
instance) of a class or interface, including annotation type
elements.
- Since:
- 1.6
- See Also:
ExecutableType
-
Method Summary
Modifier and Type Method Description TypeMirror
asType()
Returns the executable type defined by this executable element.AnnotationValue
getDefaultValue()
Returns the default value if this executable is an annotation type element.List<? extends VariableElement>
getParameters()
Returns the formal parameters of this executable.TypeMirror
getReceiverType()
TypeMirror
getReturnType()
Returns the return type of this executable.Name
getSimpleName()
Returns the simple name of a constructor, method, or initializer.List<? extends TypeMirror>
getThrownTypes()
Returns the exceptions and other throwables listed in this method or constructor'sthrows
clause in declaration order.List<? extends TypeParameterElement>
getTypeParameters()
Returns the formal type parameters of this executable in declaration order.boolean
isDefault()
Returnstrue
if this method is a default method and returnsfalse
otherwise.boolean
isVarArgs()
Returnstrue
if this method or constructor accepts a variable number of arguments and returnsfalse
otherwise.Methods declared in interface javax.lang.model.element.Element
accept, equals, getAnnotation, getAnnotationMirrors, getAnnotationsByType, getEnclosedElements, getEnclosingElement, getKind, getModifiers, hashCode
-
Method Details
-
asType
TypeMirror asType()Returns the executable type defined by this executable element.- Specified by:
asType
in interfaceElement
- Returns:
- the executable type defined by this executable element
- See Also:
ExecutableType
-
getTypeParameters
List<? extends TypeParameterElement> getTypeParameters()Returns the formal type parameters of this executable in declaration order.- Specified by:
getTypeParameters
in interfaceParameterizable
- Returns:
- the formal type parameters, or an empty list if there are none
-
getReturnType
TypeMirror getReturnType()Returns the return type of this executable. Returns aNoType
with kindVOID
if this executable is not a method, or is a method that does not return a value.- Returns:
- the return type of this executable
-
getParameters
List<? extends VariableElement> getParameters()Returns the formal parameters of this executable. They are returned in declaration order.- Returns:
- the formal parameters, or an empty list if there are none
-
getReceiverType
TypeMirror getReceiverType()Returns the receiver type of this executable, orNoType
with kindNONE
if the executable has no receiver type. An executable which is an instance method, or a constructor of an inner class, has a receiver type derived from the declaring type. An executable which is a static method, or a constructor of a non-inner class, or an initializer (static or instance), has no receiver type.- Returns:
- the receiver type of this executable
- See Java Language Specification:
-
8.4 Method Declarations
8.4.1 Formal Parameters
8.8 Constructor Declarations - Since:
- 1.8
-
isVarArgs
boolean isVarArgs()Returnstrue
if this method or constructor accepts a variable number of arguments and returnsfalse
otherwise.- Returns:
true
if this method or constructor accepts a variable number of arguments andfalse
otherwise
-
isDefault
boolean isDefault()Returnstrue
if this method is a default method and returnsfalse
otherwise.- Returns:
true
if this method is a default method andfalse
otherwise- Since:
- 1.8
-
getThrownTypes
List<? extends TypeMirror> getThrownTypes()Returns the exceptions and other throwables listed in this method or constructor'sthrows
clause in declaration order.- Returns:
- the exceptions and other throwables listed in the
throws
clause, or an empty list if there are none
-
getDefaultValue
AnnotationValue getDefaultValue()Returns the default value if this executable is an annotation type element. Returnsnull
if this method is not an annotation type element, or if it is an annotation type element with no default value.- Returns:
- the default value, or
null
if none
-
getSimpleName
Name getSimpleName()Returns the simple name of a constructor, method, or initializer. For a constructor, the name"<init>"
is returned, for a static initializer, the name"<clinit>"
is returned, and for an anonymous class or instance initializer, an empty name is returned.- Specified by:
getSimpleName
in interfaceElement
- Returns:
- the simple name of a constructor, method, or initializer
- See Also:
PackageElement.getSimpleName()
,getSimpleName()
,TypeElement.getSimpleName()
,VariableElement.getSimpleName()
,ModuleElement.getSimpleName()
,RecordComponentElement.getSimpleName()
-