Interface MethodMirror
Usage
Usage is only valid with interface types. A MethodMirror can traverse the declared methods of an interface
yielding MethodId for each of them, and it can call those methods in a possibly-efficient manner. It should
never return bridge or synthetic methods.
Implementing
Implementing this interface correctly requires a number of considerations. It is recommended to check the library source code as a reference implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA wrapper for an instance whose methods can be called, as long as those methods conform to a certain enclosing type.static interfaceController for accessing the reflected methods of a given type -
Method Summary
Modifier and TypeMethodDescription@NonNull MethodMirror.InvokermakeInvoker(@NonNull Object receiver, @NonNull Class<?> enclosingType) Creates an invoker that allows calling methods on the given receiver.@NonNull MethodMirror.TypeWalkertypeWalker(@NonNull ReifiedType.Annotated reifiedType) Makes a type walker for the given type.
-
Method Details
-
typeWalker
Makes a type walker for the given type.The type walker allows the caller to control movement and selection of super classes insofar as the control flow suits them.
- Parameters:
reifiedType- the reified type being walked- Returns:
- the type walker
-
makeInvoker
@NonNull MethodMirror.Invoker makeInvoker(@NonNull Object receiver, @NonNull Class<?> enclosingType) Creates an invoker that allows calling methods on the given receiver.Usage of the invoker is restricted to methods declared in the given enclosing type. The caller upholds the guarantee that no other methods (such as inherited methods) will be called.
- Parameters:
receiver- the receiver object, on which the methods are calledenclosingType- the enclosing type- Returns:
- an invoker for the receiver
-