MethodSignature class final

What is known about an advised member without calling it: its name, its types, its annotations and those of its class.

Dart has no runtime reflection, so the generator writes one constant per proxied member. Pointcuts match against it, and advice reads it from JoinPoint.signature to know which member is being called: for a log line, a metric name, or the member's annotations (a @Timed threshold, a cache name). Applications read it, never create it.

Type names are simple class names without type arguments (Future, not Future<int>), written at build time so they survive minified builds.

// Logs "int add(int, int)" style lines before each Calculator call.
@Before('execution(* Calculator.*(..))')
void before(JoinPoint joinPoint) {
  final signature = joinPoint.signature;
  log.info('${signature.returnType} ${signature.name}'
      '(${signature.parameterTypes.join(', ')})');
}

Spring (Java):

@Before("execution(* Calculator.*(..))")
void before(JoinPoint joinPoint) {
  MethodSignature signature = (MethodSignature) joinPoint.getSignature();
  log.info(signature.getReturnType() + " "
      + signature.getName()
      + Arrays.toString(signature.getParameterTypes()));
}

Constructors

MethodSignature({required String name, required String declaringType, required String targetType, List<String> declaringTypes = const [], MemberKind kind = MemberKind.method, String returnType = 'dynamic', List<String> parameterTypes = const [], List<String> parameterNames = const [], List<List<Object>> parameterAnnotations = const [], List<Object> annotations = const [], List<Object>? mergedAnnotations, List<String> targetTypes = const [], List<Object> targetAnnotations = const [], List<String> annotationTypes = const [], List<String> targetAnnotationTypes = const [], List<String> implementingTypes = const [], List<Object>? implementingTypeAnnotations, List<String>? implementingTypeAnnotationTypes, List<List<Object>> superclassAnnotations = const [], bool isProtected = false})
Describes the member name; written by the generator, one per proxied member.
const

Properties

annotations → List<Object>
The annotations on the member that @annotation(...) pointcuts match: those of the method that runs and of the interface methods it implements. As in AspectJ, an annotation that is only on a superclass or mixin method it overrides does not count; see mergedAnnotations.
final
annotationTypes → List<String>
The class names of annotations, written by the generator. @annotation(Timed) matches these names rather than runtimeType.toString(), which is minified in release builds (dart2js, --obfuscate).
final
declaringType → String
The most abstract type that declares the member, such as the interface Calculator rather than the class SimpleCalculator.
final
declaringTypes → List<String>
Every type of the bean that declares the member; the type part of an execution pattern matches any of them.
final
hashCode → int
The hash code for this object.
no setterinherited
implementingType → String
The class whose body runs for the member: the bean class, or the superclass or mixin it inherits the member from. within(...) matches it.
no setter
implementingTypeAnnotations → List<Object>?
The annotations on implementingType, for @within(...); null when that is the bean class, whose annotations are targetAnnotations.
final
implementingTypeAnnotationTypes → List<String>?
The class names of implementingTypeAnnotations; null when that is the bean class (targetAnnotationTypes).
final
implementingTypeHierarchy → List<String>
implementingType and its supertypes, for within(Type+).
no setter
implementingTypeHierarchyAnnotations → List<Object>
The annotations on implementingType, then on its superclasses and mixins, nearest first.
no setter
implementingTypes → List<String>
The class whose body runs for the member (the bean class, or the superclass or mixin it inherits the member from), then its supertypes. Empty means [targetType, ...targetTypes].
final
isProtected → bool
Whether the member is annotated @protected (package:meta), the closest Dart has to Java's protected; execution(protected ...) matches it.
final
kind → MemberKind
Whether the member is a method, a getter or a setter.
final
mergedAnnotations → List<Object>
The annotations on the member and on every declaration it overrides or implements (superclasses, mixins, interfaces), most specific first, as Spring's AnnotatedElementUtils finds them.
no setter
name → String
The member's name, such as add; a setter's name has no =.
final
parameterAnnotations → List<List<Object>>
The annotations of each parameter, in the order of parameterNames, taken from both the interface and the implementation. Method validation reads constraints and @Valid here. Empty when no parameter has annotations.
final
parameterNames → List<String>
The parameter names, in the order of JoinPoint.args (positional ones, then named ones). Expressions read arguments by these names, such as the cache key '#isbn'.
final
parameterTypes → List<String>
The parameter types' names, without type arguments.
final
returnType → String
The return type's name without type arguments; void when it returns nothing, dynamic when unknown.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
superclassAnnotations → List<List<Object>>
The annotations of each superclass and mixin of implementingType that has some, nearest first. Read them through implementingTypeHierarchyAnnotations.
final
targetAnnotations → List<Object>
The annotations on the bean class, for @target(...).
final
targetAnnotationTypes → List<String>
The class names of targetAnnotations, for the same reason as annotationTypes.
final
targetType → String
The bean's class, such as SimpleCalculator.
final
targetTypes → List<String>
The names of the bean class and all its supertypes, for target(Type) and this(Type).
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toShortString() → String
The declaring type and the member name for logs, such as Greeter.greet(..).
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited