public final class Methods
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <N> java.lang.reflect.Method |
findMethod(java.lang.Class<N> type,
java.util.function.Consumer<? super N> methodLambda)
Find a method on an interface type without needing to look it up by its
string name.
|
static Visibility |
getVisibility(java.lang.reflect.Method method)
Determine the visibility of the method
|
public static <N> java.lang.reflect.Method findMethod(java.lang.Class<N> type, java.util.function.Consumer<? super N> methodLambda)
For example to get a Method
instance over the
Comparable.compareTo(Object)
method, invoke as
Methods.findMethod(Comparable.class, c -> c.compareTo(null));
. Or
to get a reference to Supplier.get()
, invoke as
Methods.findMethod(Supplier.class, Supplier::get);
.
N
- the interface containing the methodtype
- the type of the class which declares the methodmethodLambda
- a consumer, typically given as a lambda or method reference, which
invokes the requested methodConsumer
on an instance of the given typepublic static Visibility getVisibility(java.lang.reflect.Method method)
method
- the method whose visibility we wish to determineVisibility
object describing the method