public abstract class FieldAccessor extends Object implements Instrumentation
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.
|
Modifier and Type | Class and Description |
---|---|
protected class |
FieldAccessor.Appender
An byte code appender for an field accessor instrumentation.
|
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.
|
protected static class |
FieldAccessor.ForBeanProperty
Implementation of a field accessor instrumentation where a field is identified by a method's name following
the Java specification for bean properties.
|
protected static class |
FieldAccessor.ForNamedField
Implementation of a field accessor instrumentation where the field name is given explicitly.
|
static interface |
FieldAccessor.OwnerTypeLocatable
A field accessor that can be configured to locate a field in a specific manner.
|
Instrumentation.Compound, Instrumentation.Context, Instrumentation.ForAbstractMethod
Modifier and Type | Field and Description |
---|---|
protected Assigner |
assigner
The assigner to use.
|
protected boolean |
considerRuntimeType
true if the runtime type of the field's value should be considered when a field
is accessed. |
Modifier | Constructor and Description |
---|---|
protected |
FieldAccessor(Assigner assigner,
boolean considerRuntimeType)
Creates a new field accessor.
|
Modifier and Type | Method and Description |
---|---|
protected ByteCodeAppender.Size |
applyGetter(org.objectweb.asm.MethodVisitor methodVisitor,
Instrumentation.Context instrumentationContext,
FieldDescription fieldDescription,
MethodDescription methodDescription)
Applies a field getter instrumentation.
|
protected ByteCodeAppender.Size |
applySetter(org.objectweb.asm.MethodVisitor methodVisitor,
Instrumentation.Context instrumentationContext,
FieldDescription fieldDescription,
MethodDescription methodDescription)
Applies a field setter instrumentation.
|
boolean |
equals(Object other) |
protected abstract String |
getFieldName(MethodDescription targetMethod)
Locates a field's name.
|
int |
hashCode() |
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.
|
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 boolean considerRuntimeType
true
if the runtime type of the field's value should be considered when a field
is accessed.protected FieldAccessor(Assigner assigner, boolean considerRuntimeType)
assigner
- The assigner to use.considerRuntimeType
- true
if a field value's runtime type should be considered.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
.protected ByteCodeAppender.Size applyGetter(org.objectweb.asm.MethodVisitor methodVisitor, Instrumentation.Context instrumentationContext, FieldDescription fieldDescription, MethodDescription methodDescription)
methodVisitor
- The method visitor to write any instructions to.instrumentationContext
- The instrumentation context of the current instrumentation.fieldDescription
- The description of the field to read.methodDescription
- The method that is target of the instrumentation.protected ByteCodeAppender.Size applySetter(org.objectweb.asm.MethodVisitor methodVisitor, Instrumentation.Context instrumentationContext, FieldDescription fieldDescription, MethodDescription methodDescription)
methodVisitor
- The method visitor to write any instructions to.instrumentationContext
- The instrumentation context of the current instrumentation.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 instrumentation.Copyright © 2014. All rights reserved.