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; call invokes it on any implementation of the interface (e.g. a fallback bean). The generator leaves call out 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 (or Future<void>).
final
name → String
The method's name.
final
parameters → List<BeanParameter>
Its parameters (positional first, then named), in the order of the arguments passed to InvocationHandler.invoke.
final
returnType → TypeInfo<Object?>
The result type; for Future<T> the type of T.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

annotation<A>() → A?
The first annotation of type A, or null.
callOn(Object target, List<Object?> arguments) → Object?
Calls this method on target, an implementation of the interface, with arguments in the order of parameters. Throws a StateError when the method was described without a call.
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