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 theFieldProxy
annotation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
FieldProxy.Binder.AccessorProxy
A proxy type for accessing a field either by a getter or a setter.protected static class
FieldProxy.Binder.FieldGetter
Implementation for a getter method.protected static interface
FieldProxy.Binder.FieldResolver
A resolver for creating an instrumentation for a field access.protected static class
FieldProxy.Binder.FieldSetter
Implementation for a setter method.protected static class
FieldProxy.Binder.InstanceFieldConstructor
Represents an implementation for implementing a proxy type constructor when a non-static field is accessed.protected static class
FieldProxy.Binder.StaticFieldConstructor
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 java.lang.annotation.Annotation>, TargetMethodAnnotationDrivenBinder.ParameterBinder.ForFixedValue<S extends java.lang.annotation.Annotation>
-
-
Field Summary
Fields Modifier and Type Field Description private static MethodDescription.InDefinedShape
DECLARING_TYPE
A reference to the method that declares the field annotation's defining type property.private static MethodDescription.InDefinedShape
FIELD_NAME
A reference to the method that declares the field annotation's field name property.private FieldProxy.Binder.FieldResolver.Factory
fieldResolverFactory
The field resolver factory to apply by this binder.private static MethodDescription.InDefinedShape
SERIALIZABLE_PROXY
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
Constructors Modifier Constructor Description protected
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 java.lang.String
fieldName(AnnotationDescription.Loadable<FieldProxy> annotation)
Extracts the field name from an annotation.java.lang.Class<FieldProxy>
getHandledType()
The annotation type that is handled by this parameter binder.static TargetMethodAnnotationDrivenBinder.ParameterBinder<FieldProxy>
install(java.lang.Class<?> type)
Creates a binder by installing a single proxy type where annotating a parameter withFieldProxy
allows getting and setting values for a given field.static TargetMethodAnnotationDrivenBinder.ParameterBinder<FieldProxy>
install(java.lang.Class<?> getterType, java.lang.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.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.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.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 Detail
-
DECLARING_TYPE
private static final MethodDescription.InDefinedShape DECLARING_TYPE
A reference to the method that declares the field annotation's defining type property.
-
FIELD_NAME
private static final MethodDescription.InDefinedShape FIELD_NAME
A reference to the method that declares the field annotation's field name property.
-
SERIALIZABLE_PROXY
private static final MethodDescription.InDefinedShape SERIALIZABLE_PROXY
A reference to the method that declares the field annotation's serializable proxy property.
-
fieldResolverFactory
private final FieldProxy.Binder.FieldResolver.Factory fieldResolverFactory
The field resolver factory to apply by this binder.
-
-
Constructor Detail
-
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
protected Binder(FieldProxy.Binder.FieldResolver.Factory fieldResolverFactory)
Creates a new binder for aFieldProxy
.- Parameters:
fieldResolverFactory
- The field resolver factory to apply by this binder.
-
-
Method Detail
-
install
public static TargetMethodAnnotationDrivenBinder.ParameterBinder<FieldProxy> install(java.lang.Class<?> type)
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(java.lang.Class<?> getterType, java.lang.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
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.- Parameters:
typeDescription
- The type description to evaluate.- Returns:
- The only method which was found to be compatible to the proxy requirements.
-
getHandledType
public java.lang.Class<FieldProxy> getHandledType()
The annotation type that is handled by this parameter binder.- Returns:
- The
Annotation.annotationType()
handled by this parameter binder.
-
fieldName
protected java.lang.String fieldName(AnnotationDescription.Loadable<FieldProxy> annotation)
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
protected TypeDescription declaringType(AnnotationDescription.Loadable<FieldProxy> annotation)
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.
-
-