ProxyMethod class final
The description of one method of an interface proxy: its name, parameters, return type and annotations, and a way to call it.
The generator writes one per method; an InvocationHandler reads it to know what a call means (for Feign: the HTTP method, path and parameter bindings), and callOn lets it forward the call to a real implementation such as a fallback bean.
// Future<Book> find(@PathVariable() String isbn)
ProxyMethod(
'find',
parameters: const [
BeanParameter('isbn', type: ClassType<String>(), isRequired: true,
annotations: [PathVariable()]),
],
returnType: const ClassType<Book>(),
isFuture: true,
annotations: const [GetMapping('/books/{isbn}')],
call: (target, arguments) =>
(target as CatalogClient).find(arguments[0] as String),
);
Spring (Java): the java.lang.reflect.Method passed to
InvocationHandler.invoke.
Constructors
-
ProxyMethod(String name, {required TypeInfo<
Object?> returnType, Object? call(Object target, List<Object?> arguments)?, List<BeanParameter> parameters = const [], bool isFuture = false, bool isVoid = false, List<Object> annotations = const []}) -
Describes the method
name;callinvokes it on any implementation of the interface (e.g. a fallback bean). The generator leavescallout where there is no other implementation to call.
Properties
-
annotations
→ List<
Object> -
The const annotations on the method.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFuture → bool
-
Whether the method returns a
Future(whose value is returnType).final - isVoid → bool
-
Whether the result is
void(orFuture<void>).final - name → String
-
The method's name.
final
-
parameters
→ List<
BeanParameter> -
Its parameters (positional first, then named), in the order of the
argumentspassed to InvocationHandler.invoke.final -
returnType
→ TypeInfo<
Object?> -
The result type; for
Future<T>the type ofT.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
annotation<
A> () → A? -
The first annotation of type
A, ornull. -
callOn(
Object target, List< Object?> arguments) → Object? -
Calls this method on
target, an implementation of the interface, withargumentsin the order of parameters. Throws a StateError when the method was described without acall. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited