Package net.bytebuddy.implementation
Class FieldAccessor.ForSetter<T>
- java.lang.Object
-
- net.bytebuddy.implementation.FieldAccessor
-
- net.bytebuddy.implementation.FieldAccessor.ForSetter<T>
-
- Type Parameters:
T
- The type of the value that is initialized per instrumented type.
- All Implemented Interfaces:
InstrumentedType.Prepareable
,Implementation
,Implementation.Composable
- Direct Known Subclasses:
FieldAccessor.ForSetter.OfConstantValue
,FieldAccessor.ForSetter.OfDefaultValue
,FieldAccessor.ForSetter.OfFieldValue
,FieldAccessor.ForSetter.OfParameterValue
,FieldAccessor.ForSetter.OfReferenceValue
- Enclosing class:
- FieldAccessor
@Enhance protected abstract static class FieldAccessor.ForSetter<T> extends FieldAccessor implements Implementation.Composable
A field accessor for a field setter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
FieldAccessor.ForSetter.Appender
An appender to implement a field setter.protected static class
FieldAccessor.ForSetter.OfConstantValue
An instrumentation that sets a constant value to a field.protected static class
FieldAccessor.ForSetter.OfDefaultValue
A setter instrumentation that sets anull
or a primitive type's default value.protected static class
FieldAccessor.ForSetter.OfFieldValue
A setter that reads a value of another field and sets this value.protected static class
FieldAccessor.ForSetter.OfParameterValue
A setter instrumentation for a parameter value.protected static class
FieldAccessor.ForSetter.OfReferenceValue
An instrumentation that sets a field to a reference value that is stored in a static field of the instrumented type.protected static class
FieldAccessor.ForSetter.TerminationHandler
A termination handler is responsible for handling a field accessor's return.-
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 Modifier and Type Field Description private FieldAccessor.ForSetter.TerminationHandler
terminationHandler
The termination handler to apply.-
Fields inherited from class net.bytebuddy.implementation.FieldAccessor
assigner, fieldLocation, typing
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForSetter(FieldAccessor.FieldLocation fieldLocation, Assigner assigner, Assigner.Typing typing, FieldAccessor.ForSetter.TerminationHandler terminationHandler)
Creates a new field accessor for a setter instrumentation.
-
Method Summary
All Methods Instance Methods Abstract 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.protected abstract T
initialize(TypeDescription instrumentedType)
Initializes a value to be used during method instrumentation.protected abstract StackManipulation
resolve(T initialized, FieldDescription fieldDescription, TypeDescription instrumentedType, MethodDescription instrumentedMethod)
Resolves the stack manipulation to load the value being set.-
Methods inherited from class net.bytebuddy.implementation.FieldAccessor
of, of, of, ofBeanProperty, ofField
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.bytebuddy.implementation.Implementation.Composable
andThen, andThen
-
Methods inherited from interface net.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable
prepare
-
-
-
-
Field Detail
-
terminationHandler
private final FieldAccessor.ForSetter.TerminationHandler terminationHandler
The termination handler to apply.
-
-
Constructor Detail
-
ForSetter
protected ForSetter(FieldAccessor.FieldLocation fieldLocation, Assigner assigner, Assigner.Typing typing, FieldAccessor.ForSetter.TerminationHandler terminationHandler)
Creates a new field accessor for a setter instrumentation.- Parameters:
fieldLocation
- The field's location.assigner
- The assigner to use.typing
- Indicates if dynamic type castings should be attempted for incompatible assignments.terminationHandler
- The termination handler to apply.
-
-
Method Detail
-
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)
.
-
initialize
protected abstract T initialize(TypeDescription instrumentedType)
Initializes a value to be used during method instrumentation.- Parameters:
instrumentedType
- The instrumented type.- Returns:
- The initialized value.
-
resolve
protected abstract StackManipulation resolve(T initialized, FieldDescription fieldDescription, TypeDescription instrumentedType, MethodDescription instrumentedMethod)
Resolves the stack manipulation to load the value being set.- Parameters:
initialized
- The method that was initialized for the instrumented type.fieldDescription
- The field to set the value for.instrumentedType
- The instrumented type.instrumentedMethod
- The instrumented method.- Returns:
- The stack manipulation to apply.
-
-