Class FieldProxy.Binder
java.lang.Object
net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding<FieldProxy>
net.bytebuddy.implementation.bind.annotation.FieldProxy.Binder
- All Implemented Interfaces:
TargetMethodAnnotationDrivenBinder.ParameterBinder<FieldProxy>
- Enclosing class:
FieldProxy
@Enhance
public static class FieldProxy.Binder
extends TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding<FieldProxy>
A binder for the
FieldProxy
annotation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
A proxy type for accessing a field either by a getter or a setter.protected static class
Implementation for a getter method.protected static interface
A resolver for creating an instrumentation for a field access.protected static class
Implementation for a setter method.protected static class
Represents an implementation for implementing a proxy type constructor when a non-static field is accessed.protected static enum
Represents an implementation for implementing a proxy type constructor when a static field is accessed.Nested classes/interfaces inherited from interface net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder
TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding<S extends Annotation>, TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFixedValue<S extends Annotation>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final MethodDescription.InDefinedShape
A reference to the method that declares the field annotation's defining type property.private static final MethodDescription.InDefinedShape
A reference to the method that declares the field annotation's field name property.private final FieldProxy.Binder.FieldResolver.Factory
The field resolver factory to apply by this binder.private static final MethodDescription.InDefinedShape
A reference to the method that declares the field annotation's serializable proxy property.Fields inherited from class net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding
BEAN_PROPERTY
Fields inherited from interface net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder
DEFAULTS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Binder
(MethodDescription.InDefinedShape getterMethod, MethodDescription.InDefinedShape setterMethod) Creates a new binder for aFieldProxy
in simplex mode.protected
Binder
(TypeDescription proxyType, MethodDescription.InDefinedShape getterMethod, MethodDescription.InDefinedShape setterMethod) Creates a new binder for aFieldProxy
in duplex mode.protected
Binder
(FieldProxy.Binder.FieldResolver.Factory fieldResolverFactory) Creates a new binder for aFieldProxy
. -
Method Summary
Modifier and TypeMethodDescriptionprotected MethodDelegationBinder.ParameterBinding
<?> bind
(FieldDescription fieldDescription, AnnotationDescription.Loadable<FieldProxy> annotation, MethodDescription source, ParameterDescription target, Implementation.Target implementationTarget, Assigner assigner) Creates a parameter binding for the given target parameter.protected TypeDescription
declaringType
(AnnotationDescription.Loadable<FieldProxy> annotation) Extracts the declaring type from an annotation.protected String
fieldName
(AnnotationDescription.Loadable<FieldProxy> annotation) Extracts the field name from an annotation.The annotation type that is handled by this parameter binder.Creates a binder by installing a single proxy type where annotating a parameter withFieldProxy
allows getting and setting values for a given field.Creates a binder by installing two proxy types which are implemented by this binder if a field getter or a field setter is requested by using theFieldProxy
annotation.install
(TypeDescription typeDescription) Creates a binder by installing a single proxy type where annotating a parameter withFieldProxy
allows getting and setting values for a given field.install
(TypeDescription getterType, TypeDescription setterType) Creates a binder by installing two proxy types which are implemented by this binder if a field getter or a field setter is requested by using theFieldProxy
annotation.private static MethodDescription.InDefinedShape
onlyMethod
(TypeDescription typeDescription) Extracts the only method from a given type description which is validated for the required properties for using the type as a proxy base type.Methods inherited from class net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding
bind
-
Field Details
-
DECLARING_TYPE
A reference to the method that declares the field annotation's defining type property. -
FIELD_NAME
A reference to the method that declares the field annotation's field name property. -
SERIALIZABLE_PROXY
A reference to the method that declares the field annotation's serializable proxy property. -
fieldResolverFactory
The field resolver factory to apply by this binder.
-
-
Constructor Details
-
Binder
protected Binder(MethodDescription.InDefinedShape getterMethod, MethodDescription.InDefinedShape setterMethod) Creates a new binder for aFieldProxy
in simplex mode.- Parameters:
getterMethod
- The getter method.setterMethod
- The setter method.
-
Binder
protected Binder(TypeDescription proxyType, MethodDescription.InDefinedShape getterMethod, MethodDescription.InDefinedShape setterMethod) Creates a new binder for aFieldProxy
in duplex mode.- Parameters:
proxyType
- The proxy type.getterMethod
- The getter method.setterMethod
- The setter method.
-
Binder
Creates a new binder for aFieldProxy
.- Parameters:
fieldResolverFactory
- The field resolver factory to apply by this binder.
-
-
Method Details
-
install
Creates a binder by installing a single proxy type where annotating a parameter withFieldProxy
allows getting and setting values for a given field.- Parameters:
type
- A type which declares exactly one abstract getter and an abstract setter for theObject
type. The type is allowed to be generic.- Returns:
- A binder for the
FieldProxy
annotation.
-
install
public static TargetMethodAnnotationDrivenBinder.ParameterBinder<FieldProxy> install(TypeDescription typeDescription) Creates a binder by installing a single proxy type where annotating a parameter withFieldProxy
allows getting and setting values for a given field.- Parameters:
typeDescription
- A type which declares exactly one abstract getter and an abstract setter for theObject
type. The type is allowed to be generic.- Returns:
- A binder for the
FieldProxy
annotation.
-
install
public static TargetMethodAnnotationDrivenBinder.ParameterBinder<FieldProxy> install(Class<?> getterType, Class<?> setterType) Creates a binder by installing two proxy types which are implemented by this binder if a field getter or a field setter is requested by using theFieldProxy
annotation.- Parameters:
getterType
- The type which should be used for getter proxies. The type must represent an interface which defines a single method which returns anObject
return type and does not take any arguments. The use of generics is permitted.setterType
- The type which should be uses for setter proxies. The type must represent an interface which defines a single method which returnsvoid
and takes a singleObject
-typed argument. The use of generics is permitted.- Returns:
- A binder for the
FieldProxy
annotation.
-
install
public static TargetMethodAnnotationDrivenBinder.ParameterBinder<FieldProxy> install(TypeDescription getterType, TypeDescription setterType) Creates a binder by installing two proxy types which are implemented by this binder if a field getter or a field setter is requested by using theFieldProxy
annotation.- Parameters:
getterType
- The type which should be used for getter proxies. The type must represent an interface which defines a single method which returns anObject
return type and does not take any arguments. The use of generics is permitted.setterType
- The type which should be uses for setter proxies. The type must represent an interface which defines a single method which returnsvoid
and takes a singleObject
-typed argument. The use of generics is permitted.- Returns:
- A binder for the
FieldProxy
annotation.
-
onlyMethod
Extracts the only method from a given type description which is validated for the required properties for using the type as a proxy base type.- Parameters:
typeDescription
- The type description to evaluate.- Returns:
- The only method which was found to be compatible to the proxy requirements.
-
getHandledType
The annotation type that is handled by this parameter binder.- Returns:
- The
Annotation.annotationType()
handled by this parameter binder.
-
fieldName
Description copied from class:TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding
Extracts the field name from an annotation.- Specified by:
fieldName
in classTargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding<FieldProxy>
- Parameters:
annotation
- The annotation from which to extract the field name.- Returns:
- The field name defined by the handled annotation.
-
declaringType
Description copied from class:TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding
Extracts the declaring type from an annotation.- Specified by:
declaringType
in classTargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding<FieldProxy>
- Parameters:
annotation
- The annotation from which to extract the declaring type.- Returns:
- The declaring type defined by the handled annotation.
-
bind
protected MethodDelegationBinder.ParameterBinding<?> bind(FieldDescription fieldDescription, AnnotationDescription.Loadable<FieldProxy> annotation, MethodDescription source, ParameterDescription target, Implementation.Target implementationTarget, Assigner assigner) Description copied from class:TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding
Creates a parameter binding for the given target parameter.- Specified by:
bind
in classTargetMethodAnnotationDrivenBinder.ParameterBinder.ForFieldBinding<FieldProxy>
- Parameters:
fieldDescription
- The field for which this binder binds a value.annotation
- The annotation that was cause for the delegation to this argument binder.source
- The intercepted source method.target
- Tge target parameter that is subject to be bound to intercepting thesource
method.implementationTarget
- The target of the current implementation that is subject to this binding.assigner
- An assigner that can be used for applying the binding.- Returns:
- A parameter binding for the requested target method parameter.
-