Class FieldAccessor.ForImplicitProperty
- java.lang.Object
-
- net.bytebuddy.implementation.FieldAccessor
-
- net.bytebuddy.implementation.FieldAccessor.ForImplicitProperty
-
- All Implemented Interfaces:
InstrumentedType.Prepareable
,FieldAccessor.AssignerConfigurable
,FieldAccessor.OwnerTypeLocatable
,FieldAccessor.PropertyConfigurable
,Implementation
- Enclosing class:
- FieldAccessor
protected static class FieldAccessor.ForImplicitProperty extends FieldAccessor implements FieldAccessor.OwnerTypeLocatable
A field accessor for an implicit property where a getter or setter property is inferred from the signature.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
FieldAccessor.ForImplicitProperty.Appender
An byte code appender for an field accessor implementation.-
Nested classes/interfaces inherited from class net.bytebuddy.implementation.FieldAccessor
FieldAccessor.AssignerConfigurable, FieldAccessor.FieldLocation, FieldAccessor.FieldNameExtractor, FieldAccessor.ForImplicitProperty, FieldAccessor.ForSetter<T>, FieldAccessor.OwnerTypeLocatable, FieldAccessor.PropertyConfigurable
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
-
-
Field Summary
-
Fields inherited from class net.bytebuddy.implementation.FieldAccessor
assigner, fieldLocation, typing
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForImplicitProperty(FieldAccessor.FieldLocation fieldLocation)
Creates a field accessor for an implicit property.private
ForImplicitProperty(FieldAccessor.FieldLocation fieldLocation, Assigner assigner, Assigner.Typing typing)
Creates a field accessor for an implicit property.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteCodeAppender
appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.FieldAccessor.AssignerConfigurable
in(java.lang.Class<?> type)
Determines that a field should only be considered when it was defined in a given type.FieldAccessor.AssignerConfigurable
in(TypeDescription typeDescription)
Determines that a field should only be considered when it was defined in a given type.FieldAccessor.AssignerConfigurable
in(FieldLocator.Factory fieldLocatorFactory)
Determines that a field should only be considered when it was identified by a field locator that is produced by the given factory.InstrumentedType
prepare(InstrumentedType instrumentedType)
Prepares a given instrumented type.Implementation.Composable
setsArgumentAt(int index)
Defines a setter of the specified parameter for the field being described.Implementation.Composable
setsDefaultValue()
Defines a setter of the described field's default value, i.e.Implementation.Composable
setsFieldValueOf(java.lang.reflect.Field field)
Defines a setter of a value that sets another field's value.Implementation.Composable
setsFieldValueOf(java.lang.String fieldName)
Defines a setter of a value that sets another field's value.Implementation.Composable
setsFieldValueOf(FieldDescription fieldDescription)
Defines a setter of a value that sets another field's value.Implementation.Composable
setsFieldValueOf(FieldAccessor.FieldNameExtractor fieldNameExtractor)
Defines a setter of a value that sets another field's value.Implementation.Composable
setsReference(java.lang.Object value)
Defines a setter of a given value for the described field.Implementation.Composable
setsReference(java.lang.Object value, java.lang.String name)
Defines a setter of a given value for the described field.Implementation.Composable
setsValue(java.lang.Object value)
Defines a setter of a given value for the described field.Implementation.Composable
setsValue(TypeDescription typeDescription)
Defines a setter of a given class constant value for the described field.Implementation.Composable
setsValue(StackManipulation stackManipulation, java.lang.reflect.Type type)
Defines a setter of a value that is represented by a stack manipulation.Implementation.Composable
setsValue(StackManipulation stackManipulation, TypeDescription.Generic typeDescription)
Defines a setter of a value that is represented by a stack manipulation.Implementation.Composable
setsValue(JavaConstant constant)
Defines a setter of a given constant value for the described field.FieldAccessor.PropertyConfigurable
withAssigner(Assigner assigner, Assigner.Typing typing)
Returns a field accessor that is identical to this field accessor but uses the given assigner and runtime type use configuration.-
Methods inherited from class net.bytebuddy.implementation.FieldAccessor
of, of, of, ofBeanProperty, ofField
-
-
-
-
Constructor Detail
-
ForImplicitProperty
protected ForImplicitProperty(FieldAccessor.FieldLocation fieldLocation)
Creates a field accessor for an implicit property.- Parameters:
fieldLocation
- The field's location.
-
ForImplicitProperty
private ForImplicitProperty(FieldAccessor.FieldLocation fieldLocation, Assigner assigner, Assigner.Typing typing)
Creates a field accessor for an implicit property.- Parameters:
fieldLocation
- The field's location.assigner
- The assigner to use.typing
- The typing to use.
-
-
Method Detail
-
prepare
public InstrumentedType prepare(InstrumentedType instrumentedType)
Prepares a given instrumented type.- Specified by:
prepare
in interfaceInstrumentedType.Prepareable
- Parameters:
instrumentedType
- The instrumented type in its current form.- Returns:
- The prepared instrumented type.
-
appender
public ByteCodeAppender appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.- Specified by:
appender
in interfaceImplementation
- Parameters:
implementationTarget
- The target of the current implementation.- Returns:
- A byte code appender for implementing methods delegated to this implementation. This byte code appender
is also responsible for handling methods that were added by this implementation on the call to
InstrumentedType.Prepareable.prepare(InstrumentedType)
.
-
setsArgumentAt
public Implementation.Composable setsArgumentAt(int index)
Defines a setter of the specified parameter for the field being described.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsArgumentAt
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
index
- The index of the parameter for which to set the field's value.- Returns:
- An instrumentation that sets the parameter's value to the described field.
-
setsDefaultValue
public Implementation.Composable setsDefaultValue()
Defines a setter of the described field's default value, i.e.
null
or a primitive type's representation of0
.Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsDefaultValue
in interfaceFieldAccessor.PropertyConfigurable
- Returns:
- An instrumentation that sets the field's default value.
-
setsValue
public Implementation.Composable setsValue(java.lang.Object value)
Defines a setter of a given value for the described field. If the value is a constant value, it will be defined as a constant assignment, otherwise it is defined as a reference value that is stored in a static field of the instrumented type.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsValue
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
value
- The value to set.- Returns:
- An instrumentation that sets the field's value as specified.
-
setsValue
public Implementation.Composable setsValue(TypeDescription typeDescription)
Defines a setter of a given class constant value for the described field.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsValue
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
typeDescription
- The type to set to the described field.- Returns:
- An instrumentation that sets the field's value to the given class constant.
-
setsValue
public Implementation.Composable setsValue(JavaConstant constant)
Defines a setter of a given constant value for the described field.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsValue
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
constant
- The constant to set as a value.- Returns:
- An instrumentation that sets the field's value to the given constant.
-
setsValue
public Implementation.Composable setsValue(StackManipulation stackManipulation, java.lang.reflect.Type type)
Defines a setter of a value that is represented by a stack manipulation.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsValue
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
stackManipulation
- A stack manipulation to load the field's value.type
- The field value's type.- Returns:
- An instrumentation that sets the field's value to the given value.
-
setsValue
public Implementation.Composable setsValue(StackManipulation stackManipulation, TypeDescription.Generic typeDescription)
Defines a setter of a value that is represented by a stack manipulation.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsValue
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
stackManipulation
- A stack manipulation to load the field's value.typeDescription
- The field value's type.- Returns:
- An instrumentation that sets the field's value to the given value.
-
setsReference
public Implementation.Composable setsReference(java.lang.Object value)
Defines a setter of a given value for the described field. The value is kept as a referenced that is stored in a static field of the instrumented type. The field name is chosen based on the value's hash code.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsReference
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
value
- The value to set.- Returns:
- An instrumentation that sets the field's value as specified.
-
setsReference
public Implementation.Composable setsReference(java.lang.Object value, java.lang.String name)
Defines a setter of a given value for the described field. The value is kept as a referenced that is stored in a static field of the instrumented type.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsReference
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
value
- The value to set.name
- The name of the field.- Returns:
- An instrumentation that sets the field's value as specified.
-
setsFieldValueOf
public Implementation.Composable setsFieldValueOf(java.lang.reflect.Field field)
Defines a setter of a value that sets another field's value.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsFieldValueOf
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
field
- The field that holds the value to be set.- Returns:
- An instrumentation that sets the field's value to the specified field's value.
-
setsFieldValueOf
public Implementation.Composable setsFieldValueOf(FieldDescription fieldDescription)
Defines a setter of a value that sets another field's value.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsFieldValueOf
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
fieldDescription
- The field that holds the value to be set.- Returns:
- An instrumentation that sets the field's value to the specified field's value.
-
setsFieldValueOf
public Implementation.Composable setsFieldValueOf(java.lang.String fieldName)
Defines a setter of a value that sets another field's value.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsFieldValueOf
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
fieldName
- The name of the field that is specified by the instrumented type.- Returns:
- An instrumentation that sets the field's value to the specified field's value.
-
setsFieldValueOf
public Implementation.Composable setsFieldValueOf(FieldAccessor.FieldNameExtractor fieldNameExtractor)
Defines a setter of a value that sets another field's value.
Note: If the instrumented method does not return
void
, a chained instrumentation must be supplied.- Specified by:
setsFieldValueOf
in interfaceFieldAccessor.PropertyConfigurable
- Parameters:
fieldNameExtractor
- A field name extractor for the field that is specified by the instrumented type.- Returns:
- An instrumentation that sets the field's value to the specified field's value.
-
withAssigner
public FieldAccessor.PropertyConfigurable withAssigner(Assigner assigner, Assigner.Typing typing)
Returns a field accessor that is identical to this field accessor but uses the given assigner and runtime type use configuration.- Specified by:
withAssigner
in interfaceFieldAccessor.AssignerConfigurable
- Parameters:
assigner
- The assigner to use.typing
- Indicates if dynamic type castings should be attempted for incompatible assignments.- Returns:
- This field accessor with the given assigner and runtime type use configuration.
-
in
public FieldAccessor.AssignerConfigurable in(java.lang.Class<?> type)
Determines that a field should only be considered when it was defined in a given type.- Specified by:
in
in interfaceFieldAccessor.OwnerTypeLocatable
- Parameters:
type
- The type to be considered.- Returns:
- This field accessor which will only considered fields that are defined in the given type.
-
in
public FieldAccessor.AssignerConfigurable in(TypeDescription typeDescription)
Determines that a field should only be considered when it was defined in a given type.- Specified by:
in
in interfaceFieldAccessor.OwnerTypeLocatable
- Parameters:
typeDescription
- A description of the type to be considered.- Returns:
- This field accessor which will only considered fields that are defined in the given type.
-
in
public FieldAccessor.AssignerConfigurable in(FieldLocator.Factory fieldLocatorFactory)
Determines that a field should only be considered when it was identified by a field locator that is produced by the given factory.- Specified by:
in
in interfaceFieldAccessor.OwnerTypeLocatable
- Parameters:
fieldLocatorFactory
- A factory that will produce a field locator that will be used to find locate a field to be accessed.- Returns:
- This field accessor which will only considered fields that are defined in the given type.
-
-