Class Method
java.lang.Object
be.imgn.gaia.processing.source.Method
A method, a constructor, or the compact constructor of a record.
Method.newBuilder("max")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.returns(int.class)
.addParameter(int.class, "a")
.addParameter(int.class, "b")
.addStatement("return a > b ? a : b")
.build();
Methods are values: two methods written the same are equal.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionReturns the annotations.code()Returns the code of the body.Returns the default value of an annotation type member.booleanReturns the exceptions in thethrowsclause.inthashCode()booleanReturns whether this is the compact constructor of a record.booleanReturns whether this is a constructor, compact or not.booleanReturns whether the last parameter is variable arity, writtenString... names.javadoc()Returns the Javadoc.Returns the modifiers.name()Returns the name.static Method.BuildernewBuilder(String name) Returns a builder of methods, which returnvoidunless told otherwise.static Method.BuilderReturns a builder of compact constructors, for records: a constructor without parameter list, whose code runs before the components are assigned.static Method.BuilderReturns a builder of constructors.static Method.Builderoverriding(ExecutableElement method) Returns a builder of a method that overrides another one: the same name, type variables, return type, parameters and exceptions, annotated with@Override, and withoutabstract,default,native,synchronizedorstrictfp.static Method.Builderoverriding(ExecutableElement method, DeclaredType enclosing, Types types) Returns a builder of a method that overrides another one, as a member of a type: type variables of the type are replaced by its type arguments.Returns the parameters.@Nullable TypeNameReturns the return type.Returns a builder that starts with this method.toString()Returns the declared type variables.
-
Method Details
-
newBuilder
Returns a builder of methods, which returnvoidunless told otherwise.- Parameters:
name- the name of the method- Returns:
- a new builder
- Throws:
IllegalArgumentException- if the name is not a valid identifier
-
newConstructorBuilder
Returns a builder of constructors.- Returns:
- a new builder
-
newCompactConstructorBuilder
Returns a builder of compact constructors, for records: a constructor without parameter list, whose code runs before the components are assigned.- Returns:
- a new builder
-
overriding
Returns a builder of a method that overrides another one: the same name, type variables, return type, parameters and exceptions, annotated with@Override, and withoutabstract,default,native,synchronizedorstrictfp.- Parameters:
method- the method to override- Returns:
- a new builder, to add the code to
- Throws:
IllegalArgumentException- if the method is private, static or final, a member of a final type, or not a method; or a type in its signature has no name, asTypeName.of(TypeMirror)names it
-
overriding
public static Method.Builder overriding(ExecutableElement method, DeclaredType enclosing, Types types) Returns a builder of a method that overrides another one, as a member of a type: type variables of the type are replaced by its type arguments. For example, overridingComparable.compareTo(T)inComparable<String>givescompareTo(String).- Parameters:
method- the method to overrideenclosing- the type the method is a member of, such asComparable<String>types- the type utilities of the processing environment- Returns:
- a new builder, to add the code to
- Throws:
IllegalArgumentException- if the method is private, static or final, a member of a final type, or not a method; it is not a member of the type; or a type in its signature has no name, asTypeName.of(TypeMirror)names it
-
name
Returns the name.- Returns:
- the name of the method;
<init>for a constructor,<compact>for a compact constructor
-
isConstructor
public boolean isConstructor()Returns whether this is a constructor, compact or not.- Returns:
truefor a constructor
-
isCompactConstructor
public boolean isCompactConstructor()Returns whether this is the compact constructor of a record.- Returns:
truefor a compact constructor
-
modifiers
-
annotations
-
javadoc
-
typeVariables
Returns the declared type variables.- Returns:
- the type variables, in order
-
returnType
Returns the return type.- Returns:
- the return type, or
nullfor a constructor
-
parameters
-
isVarargs
public boolean isVarargs()Returns whether the last parameter is variable arity, writtenString... names.- Returns:
truefor a varargs method
-
exceptions
-
code
Returns the code of the body.- Returns:
- the code, empty for no body or an empty one
-
defaultValue
Returns the default value of an annotation type member.- Returns:
- the value after
default, empty if there is none
-
toBuilder
Returns a builder that starts with this method.- Returns:
- a new builder
-
equals
-
hashCode
-
toString
-