public abstract class FieldAccessor extends Object implements Implementation
getFoo()
will be instrumented to read and return the value of a field foo
or another field if one was specified explicitly. If a property is of type Boolean
or
boolean
, the name isFoo()
is also permitted.setFoo(value)
will be instrumented to write the given argument value
to a field foo
or to another field if one was specified explicitly.Type | Property and Description |
---|---|
static FieldAccessor.OwnerTypeLocatable |
ofBean
Defines a field accessor where any access is targeted to a field that matches the methods
name with the Java specification for bean properties, i.e. a method
getFoo or setFoo(value)
will either read or write a field named foo . |
Modifier and Type | Class and Description |
---|---|
protected class |
FieldAccessor.Appender
An byte code appender for an field accessor implementation.
|
static interface |
FieldAccessor.AssignerConfigurable
A field accessor that can be configured to use a given assigner and runtime type use configuration.
|
static interface |
FieldAccessor.FieldDefinable
Determines a field accessor that accesses a field of a given name which might not yet be
defined.
|
static interface |
FieldAccessor.FieldLocator
A field locator allows to determine a field name for a given method.
|
static interface |
FieldAccessor.FieldNameExtractor
A field name extractor is responsible for determining a field name to a method that is implemented
to access this method.
|
protected static class |
FieldAccessor.ForNamedField
Implementation of a field accessor implementation where the field name is given explicitly.
|
protected static class |
FieldAccessor.ForUnnamedField
Implementation of a field accessor implementation where a field is identified by a method's name following
the Java specification for bean properties.
|
static interface |
FieldAccessor.OwnerTypeLocatable
A field accessor that can be configured to locate a field in a specific manner.
|
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
Modifier and Type | Field and Description |
---|---|
protected Assigner |
assigner
The assigner to use.
|
protected Assigner.Typing |
typing
Indicates if dynamic type castings should be attempted for incompatible assignments.
|
Modifier | Constructor and Description |
---|---|
protected |
FieldAccessor(Assigner assigner,
Assigner.Typing typing)
Creates a new field accessor.
|
Modifier and Type | Method and Description |
---|---|
protected ByteCodeAppender.Size |
applyGetter(MethodVisitor methodVisitor,
Implementation.Context implementationContext,
FieldDescription fieldDescription,
MethodDescription methodDescription)
Applies a field getter implementation.
|
protected ByteCodeAppender.Size |
applySetter(MethodVisitor methodVisitor,
Implementation.Context implementationContext,
FieldDescription fieldDescription,
MethodDescription methodDescription)
Applies a field setter implementation.
|
boolean |
equals(Object other) |
protected abstract String |
getFieldName(MethodDescription targetMethod)
Locates a field's name.
|
int |
hashCode() |
static FieldAccessor.OwnerTypeLocatable |
of(FieldAccessor.FieldNameExtractor fieldNameExtractor)
Defines a custom strategy for determining the field that is accessed by this field accessor.
|
static FieldAccessor.OwnerTypeLocatable |
ofBeanProperty()
Defines a field accessor where any access is targeted to a field that matches the methods
name with the Java specification for bean properties, i.e. a method
getFoo or setFoo(value)
will either read or write a field named foo . |
static FieldAccessor.FieldDefinable |
ofField(String name)
Defines a field accessor where any access is targeted to a field named
name . |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
appender
prepare
public static FieldAccessor.OwnerTypeLocatable ofBeanProperty
getFoo
or setFoo(value)
will either read or write a field named foo
.protected final Assigner assigner
protected final Assigner.Typing typing
protected FieldAccessor(Assigner assigner, Assigner.Typing typing)
assigner
- The assigner to use.typing
- Indicates if dynamic type castings should be attempted for incompatible assignments.public static FieldAccessor.FieldDefinable ofField(String name)
name
.name
- The name of the field to be accessed.public static FieldAccessor.OwnerTypeLocatable ofBeanProperty()
getFoo
or setFoo(value)
will either read or write a field named foo
.public static FieldAccessor.OwnerTypeLocatable of(FieldAccessor.FieldNameExtractor fieldNameExtractor)
fieldNameExtractor
- The field name extractor to use.protected ByteCodeAppender.Size applyGetter(MethodVisitor methodVisitor, Implementation.Context implementationContext, FieldDescription fieldDescription, MethodDescription methodDescription)
methodVisitor
- The method visitor to write any instructions to.implementationContext
- The implementation context of the current implementation.fieldDescription
- The description of the field to read.methodDescription
- The method that is target of the implementation.protected ByteCodeAppender.Size applySetter(MethodVisitor methodVisitor, Implementation.Context implementationContext, FieldDescription fieldDescription, MethodDescription methodDescription)
methodVisitor
- The method visitor to write any instructions to.implementationContext
- The implementation context of the current implementation.fieldDescription
- The description of the field to write to.methodDescription
- The method that is target of the instrumentation.protected abstract String getFieldName(MethodDescription targetMethod)
targetMethod
- The method that is target of the implementation.Copyright © 2014–2016. All rights reserved.