Top Description Inners Methods
net.bytebuddy.implementation.bind.annotation

public @Interface Argument

extends Annotation
Known Direct Implementers
net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.DelegationProcessor.Handler.Unbound.DefaultArgument
Annotations
@Documented
@Retention:RUNTIME
@Target:PARAMETER
Imports
net.bytebuddy.description.annotation.AnnotationDescription, net.bytebuddy.description.method.MethodDescription, .MethodList, .ParameterDescription, net.bytebuddy.description.type.TypeDescription, net.bytebuddy.implementation.Implementation, net.bytebuddy.implementation.bind.ArgumentTypeResolver, .MethodDelegationBinder, net.bytebuddy.implementation.bytecode.StackManipulation, net.bytebuddy.implementation.bytecode.assign.Assigner, net.bytebuddy.implementation.bytecode.member.MethodVariableAccess, java.lang.annotation.*

Parameters that are annotated with this annotation will be assigned the value of the parameter of the source method with the given parameter. For example, if source method foo(String, Integer) is bound to target method bar(@Argument(1) Integer), the second parameter of foo will be bound to the first argument of bar.

If a source method has less parameters than specified by Argument#value(), the method carrying this parameter annotation is excluded from the list of possible binding candidates to this particular source method. The same happens, if the source method parameter at the specified index is not assignable to the annotated parameter.

Important Note

Don't confuse this annotation with net.bytebuddy.asm.Advice.Argument or net.bytebuddy.asm.MemberSubstitution.Argument. This annotation should be used with net.bytebuddy.implementation.MethodDelegation only.

See Also
net.bytebuddy.implementation.MethodDelegation, net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder, net.bytebuddy.implementation.bind.annotation.RuntimeType

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static enum
Argument.BindingMechanic

Determines if a parameter binding should be considered for resolving ambiguous method bindings.

Method Summary

Modifier and TypeMethod and Description
public Argument.BindingMechanic

Returns:

The binding type that should be applied to this parameter binding.
bindingMechanic
()

Determines if the argument binding is to be considered by a net.bytebuddy.implementation.bind.ArgumentTypeResolver for resolving ambiguous bindings of two methods.

public int

Returns:

The required parameter index.
value
()

The index of the parameter of the source method that should be bound to this parameter.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

bindingMechanicback to summary
public Argument.BindingMechanic bindingMechanic()

Determines if the argument binding is to be considered by a net.bytebuddy.implementation.bind.ArgumentTypeResolver for resolving ambiguous bindings of two methods. If net.bytebuddy.implementation.bind.annotation.Argument.BindingMechanic#UNIQUE, of two bindable target methods such as for example foo(String) and bar(Object), the foo method would be considered as dominant over the bar method because of its more specific argument type. As a side effect, only one parameter of any target method can be bound to a source method parameter with a given index unless the net.bytebuddy.implementation.bind.annotation.Argument.BindingMechanic#ANONYMOUS option is used for any other binding.

Returns:Argument.BindingMechanic

The binding type that should be applied to this parameter binding.

See Also
net.bytebuddy.implementation.bind.ArgumentTypeResolver
valueback to summary
public int value()

The index of the parameter of the source method that should be bound to this parameter.

Returns:int

The required parameter index.

net.bytebuddy.implementation.bind.annotation back to summary

public final Enum Argument.Binder

extends Enum<Argument.Binder>
implements TargetMethodAnnotationDrivenBinder.ParameterBinder<Argument>
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder

A binder for handling the net.bytebuddy.implementation.bind.annotation.Argument annotation.
See Also
TargetMethodAnnotationDrivenBinder

Field Summary

Modifier and TypeField and Description
private static final MethodDescription.InDefinedShape
BINDING_MECHANIC

A description of the Argument#bindingMechanic() method.

public static final Argument.Binder
INSTANCE

The singleton instance.

private static final MethodDescription.InDefinedShape
VALUE

A description of the Argument#value() method.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MethodDelegationBinder.ParameterBinding<?>
bind(AnnotationDescription.Loadable<Argument>
The annotation that was cause for the delegation to this argument binder.
annotation
,
MethodDescription
The intercepted source method.
source
,
ParameterDescription
Tge target parameter that is subject to be bound to intercepting the source method.
target
,
Implementation.Target
The target of the current implementation that is subject to this binding.
implementationTarget
,
Assigner
An assigner that can be used for applying the binding.
assigner
,
Assigner.Typing
The typing to apply.
typing
)

Implements net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.bind.

Creates a parameter binding for the given target parameter.
public Class<Argument>
public static Argument.Binder
public static Argument.Binder[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BINDING_MECHANICback to summary
private static final MethodDescription.InDefinedShape BINDING_MECHANIC

A description of the Argument#bindingMechanic() method.

INSTANCEback to summary
public static final Argument.Binder INSTANCE

The singleton instance.

VALUEback to summary
private static final MethodDescription.InDefinedShape VALUE

A description of the Argument#value() method.

Constructor Detail

Binderback to summary
private Binder()

Method Detail

bindback to summary
public MethodDelegationBinder.ParameterBinding<?> bind(AnnotationDescription.Loadable<Argument> annotation, MethodDescription source, ParameterDescription target, Implementation.Target implementationTarget, Assigner assigner, Assigner.Typing typing)

Implements net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.bind.

Doc from net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.bind.

Creates a parameter binding for the given target parameter.

Parameters
annotation:AnnotationDescription.Loadable<Argument>

The annotation that was cause for the delegation to this argument binder.

source:MethodDescription

The intercepted source method.

target:ParameterDescription

Tge target parameter that is subject to be bound to intercepting the source method.

implementationTarget:Implementation.Target

The target of the current implementation that is subject to this binding.

assigner:Assigner

An assigner that can be used for applying the binding.

typing:Assigner.Typing

The typing to apply.

Returns:MethodDelegationBinder.ParameterBinding<?>

A parameter binding for the requested target method parameter.

getHandledTypeback to summary
public Class<Argument> getHandledType()

Implements net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.getHandledType.

Doc from net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.getHandledType.

The annotation type that is handled by this parameter binder.

Returns:Class<Argument>

The java.lang.annotation.Annotation#annotationType() handled by this parameter binder.

valueOfback to summary
public static Argument.Binder valueOf(String name)
valuesback to summary
public static Argument.Binder[] values()
net.bytebuddy.implementation.bind.annotation back to summary

public sealed Enum Argument.BindingMechanic

extends Enum<Argument.BindingMechanic>
Class Inheritance

Determines if a parameter binding should be considered for resolving ambiguous method bindings.
See Also
Argument#bindingMechanic(), net.bytebuddy.implementation.bind.ArgumentTypeResolver

Field Summary

Modifier and TypeField and Description
public static final Argument.BindingMechanic
ANONYMOUS

The binding is anonymous, i.e. it can be present on several parameters of the same method.

public static final Argument.BindingMechanic
UNIQUE

The binding is unique, i.e. only one such binding must be present among all parameters of a method.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected abstract MethodDelegationBinder.ParameterBinding<?>

Returns:

A binding considering the chosen binding mechanic.
makeBinding
(TypeDescription.Generic
The source type to be bound.
source
,
TypeDescription.Generic
The target type the sourceType is to be bound to.
target
,
int
The index of the source parameter.
sourceParameterIndex
,
Assigner
The assigner that is used to perform the assignment.
assigner
,
Assigner.Typing
Indicates if dynamic type castings should be attempted for incompatible assignments.
typing
,
int
The offset of the source method's parameter.
parameterOffset
)

Creates a binding that corresponds to this binding mechanic.

public static Argument.BindingMechanic
public static Argument.BindingMechanic[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ANONYMOUSback to summary
public static final Argument.BindingMechanic ANONYMOUS

The binding is anonymous, i.e. it can be present on several parameters of the same method.

UNIQUEback to summary
public static final Argument.BindingMechanic UNIQUE

The binding is unique, i.e. only one such binding must be present among all parameters of a method. As a consequence, the binding can be latter identified by an net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.

Constructor Detail

BindingMechanicback to summary
private BindingMechanic()

Method Detail

makeBindingback to summary
protected abstract MethodDelegationBinder.ParameterBinding<?> makeBinding(TypeDescription.Generic source, TypeDescription.Generic target, int sourceParameterIndex, Assigner assigner, Assigner.Typing typing, int parameterOffset)

Creates a binding that corresponds to this binding mechanic.

Parameters
source:TypeDescription.Generic

The source type to be bound.

target:TypeDescription.Generic

The target type the sourceType is to be bound to.

sourceParameterIndex:int

The index of the source parameter.

assigner:Assigner

The assigner that is used to perform the assignment.

typing:Assigner.Typing

Indicates if dynamic type castings should be attempted for incompatible assignments.

parameterOffset:int

The offset of the source method's parameter.

Returns:MethodDelegationBinder.ParameterBinding<?>

A binding considering the chosen binding mechanic.

valueOfback to summary
public static Argument.BindingMechanic valueOf(String name)
valuesback to summary
public static Argument.BindingMechanic[] values()