| 1 |
package jakarta.enterprise.lang.model.declarations; |
| 2 |
|
| 3 |
import jakarta.enterprise.lang.model.types.Type; |
| 4 |
import jakarta.enterprise.lang.model.types.TypeVariable; |
| 5 |
import java.util.List; |
| 6 |
|
| 7 |
/** |
| 8 |
* A method or a constructor, {@linkplain #declaringClass() declared} in some class. |
| 9 |
* |
| 10 |
* @since 4.0 |
| 11 |
*/ |
| 12 |
public interface MethodInfo extends DeclarationInfo { |
| 13 |
/** |
| 14 |
* Returns the name of this method. In case of constructors, returns the binary name of the declaring class. |
| 15 |
* |
| 16 |
* @return the name of this method, never {@code null} |
| 17 |
*/ |
| 18 |
String name(); |
| 19 |
|
| 20 |
/** |
| 21 |
* Returns a list of {@linkplain ParameterInfo parameters} declared or implicitly declared on this method. |
| 22 |
* |
| 23 |
* @return immutable list of {@linkplain ParameterInfo parameterts}, never {@code null} |
| 24 |
*/ |
| 25 |
List<ParameterInfo> parameters(); |
| 26 |
|
| 27 |
/** |
| 28 |
* Returns the return type of this method. In case of constructors, returns the type of the declaring class. |
| 29 |
* |
| 30 |
* @return the return type of this method, never {@code null} |
| 31 |
*/ |
| 32 |
Type returnType(); |
| 33 |
|
| 34 |
/** |
| 35 |
* Returns the {@linkplain Type type} of the receiver parameter declared by this method. |
| 36 |
* Returns {@code null} if this method cannot declare a receiver parameter; that is, if this method |
| 37 |
* is {@code static} or is a constructor of a top-level class or a {@code static} nested class. |
| 38 |
* If this method may declare a receiver parameter but does not, returns a {@link Type} with no annotations. |
| 39 |
* |
| 40 |
* @return the type of the receiver parameter declared by this method, with or without annotations, |
| 41 |
* or {@code null} if this method cannot declare a receiver parameter |
| 42 |
*/ |
| 43 |
Type receiverType(); |
| 44 |
|
| 45 |
/** |
| 46 |
* Returns a list of {@linkplain Type exception types} that are declared to be thrown by this method. |
| 47 |
* Returns an empty list if this method does not declare any exception. |
| 48 |
* |
| 49 |
* @return immutable list of {@linkplain Type exception types}, never {@code null} |
| 50 |
*/ |
| 51 |
List<Type> throwsTypes(); |
| 52 |
|
| 53 |
/** |
| 54 |
* Returns a list of {@linkplain TypeVariable type parameters} declared on this method. |
| 55 |
* Returns an empty list if this method is not generic and so does not declare type parameters. |
| 56 |
* |
| 57 |
* @return immutable list of {@linkplain TypeVariable type parameters}, never {@code null} |
| 58 |
*/ |
| 59 |
List<TypeVariable> typeParameters(); |
| 60 |
|
| 61 |
/** |
| 62 |
* Returns whether this method is, in fact, a constructor. |
| 63 |
* |
| 64 |
* @return whether this method is, in fact, a constructor |
| 65 |
*/ |
| 66 |
boolean isConstructor(); |
| 67 |
|
| 68 |
/** |
| 69 |
* Returns whether this method is {@code static}. |
| 70 |
* |
| 71 |
* @return whether this method is {@code static}. |
| 72 |
*/ |
| 73 |
boolean isStatic(); |
| 74 |
|
| 75 |
/** |
| 76 |
* Returns whether this method is abstract. |
| 77 |
* <p> |
| 78 |
* A {@code static} method is never abstract. |
| 79 |
* An instance method declared on a plain class or an enum is abstract if declared {@code abstract}. |
| 80 |
* An instance method declared on an interface is abstract unless declared {@code default}. |
| 81 |
* An instance method declared on an annotation type is always abstract. |
| 82 |
* An instance method declared on a record type is never abstract. |
| 83 |
* |
| 84 |
* @return whether this method is {@code abstract}. |
| 85 |
*/ |
| 86 |
boolean isAbstract(); |
| 87 |
|
| 88 |
/** |
| 89 |
* Returns whether this method is {@code final}. |
| 90 |
* |
| 91 |
* @return whether this method is {@code final}. |
| 92 |
*/ |
| 93 |
boolean isFinal(); |
| 94 |
|
| 95 |
/** |
| 96 |
* Returns the modifiers of this method as an {@code int}. |
| 97 |
* Use {@link java.lang.reflect.Modifier Modifier} to inspect the value. |
| 98 |
* |
| 99 |
* @return the modifiers of this method |
| 100 |
*/ |
| 101 |
int modifiers(); |
| 102 |
|
| 103 |
/** |
| 104 |
* Returns the {@linkplain ClassInfo class} that declares this method. |
| 105 |
* |
| 106 |
* @return the {@linkplain ClassInfo class} that declares this method, never {@code null} |
| 107 |
*/ |
| 108 |
ClassInfo declaringClass(); |
| 109 |
|
| 110 |
// --- |
| 111 |
|
| 112 |
@Override |
| 113 |
default Kind kind() { |
| 114 |
return Kind.METHOD; |
| 115 |
} |
| 116 |
|
| 117 |
@Override |
| 118 |
default MethodInfo asMethod() { |
| 119 |
return this; |
| 120 |
} |
| 121 |
} |