T
- the getTarget()
typeF
- the getDeclaredFieldType()
typeprotected static class BeanPathAdapter.FieldHandle<T,F>
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
BeanPathAdapter.FieldHandle(T target,
java.lang.String fieldName,
java.lang.Class<F> declaredFieldType)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected static java.lang.invoke.MethodHandle |
buildAccessor(java.lang.Object target,
java.lang.String fieldName,
java.lang.String... fieldNamePrefix)
Attempts to build a <code>MethodHandle</code> accessor for the field name
using common prefixes used for methods to access a field
|
protected static java.lang.invoke.MethodHandle |
buildAccessorWithLikelyPrefixes(java.lang.Object target,
java.lang.String fieldName)
Attempts to build a <code>MethodHandle</code> accessor for the field name
using common prefixes used for methods to access a field
|
protected static java.lang.String |
buildMethodName(java.lang.String prefix,
java.lang.String fieldName)
Builds a method name using a prefix and a field name
|
protected static java.lang.invoke.MethodHandle |
buildSetter(java.lang.invoke.MethodHandle accessor,
java.lang.Object target,
java.lang.String fieldName)
Builds a setter <code>MethodHandle</code>
|
F |
defaultValue()
Gets a default value for the
getDeclaredFieldType() |
static <VT> VT |
defaultValue(java.lang.Class<VT> clazz)
Gets a default value for the specified class
|
protected F |
deriveValueFromAccessor()
Gets an accessor's return target value obtained by calling the
accessor's
MethodHandle.invoke(Object...) method. |
protected java.lang.invoke.MethodHandle |
getAccessor() |
static java.lang.Class<?> |
getAccessorType(java.lang.Object target,
java.lang.String fieldName)
Gets the
buildAccessorWithLikelyPrefixes(Object, String)
MethodHandle.type() |
java.lang.Class<F> |
getDeclaredFieldType() |
java.lang.String |
getFieldName() |
java.lang.Class<?> |
getFieldType() |
protected java.lang.invoke.MethodHandle |
getSetter() |
T |
getTarget() |
static boolean |
hasDefault(java.lang.Class<?> clazz)
Determines if a <code>Class</code> has a default value designated
|
boolean |
hasDefaultDerived() |
F |
setDerivedValueFromAccessor()
Sets the derived value from
deriveValueFromAccessor() using
getSetter() |
void |
setTarget(T target)
Binds a new target to the
BeanPathAdapter.FieldHandle |
protected void |
updateMethodHandles()
|
static <VT> VT |
valueOf(java.lang.Class<VT> valueOfClass,
java.lang.Object value)
Attempts to invoke a
valueOf using the specified class |
F |
valueOf(java.lang.String value)
Attempts to invoke a
valueOf using the
getDeclaredFieldType() class |
protected BeanPathAdapter.FieldHandle(T target, java.lang.String fieldName, java.lang.Class<F> declaredFieldType)
target
- the getTarget()
for the <code>MethodHandle</code>sfieldName
- the field name defined in the getTarget()
declaredFieldType
- the declared field type for the getFieldName()
protected void updateMethodHandles()
getAccessor()
and getSetter()
using the
current getTarget()
and getFieldName()
.
<code>MethodHandle</code>s are immutable so new ones are created.public static java.lang.Class<?> getAccessorType(java.lang.Object target, java.lang.String fieldName)
buildAccessorWithLikelyPrefixes(Object, String)
MethodHandle.type()
target
- the accessor targetfieldName
- the field name of the targetprotected static java.lang.invoke.MethodHandle buildAccessorWithLikelyPrefixes(java.lang.Object target, java.lang.String fieldName)
target
- the target object that the accessor is forfieldName
- the field name that the accessor is forjava.lang.NoSuchMethodException
- thrown when an accessor cannot be found for the fieldprotected static java.lang.invoke.MethodHandle buildAccessor(java.lang.Object target, java.lang.String fieldName, java.lang.String... fieldNamePrefix)
target
- the target object that the accessor is forfieldName
- the field name that the accessor is forfieldNamePrefix
- the prefix of the method for the field nameprotected static java.lang.invoke.MethodHandle buildSetter(java.lang.invoke.MethodHandle accessor, java.lang.Object target, java.lang.String fieldName)
accessor
- the field's accesssor that will be used as the parameter
type for the settertarget
- the target object that the setter is forfieldName
- the field name that the setter is forpublic F valueOf(java.lang.String value)
valueOf
using the
getDeclaredFieldType()
classvalue
- the value to invoke the valueOf
method onpublic static <VT> VT valueOf(java.lang.Class<VT> valueOfClass, java.lang.Object value)
valueOf
using the specified classvalueOfClass
- the class to attempt to invoke a valueOf
method onvalue
- the value to invoke the valueOf
method onpublic static boolean hasDefault(java.lang.Class<?> clazz)
clazz
- the <code>Class</code> to checkpublic F defaultValue()
getDeclaredFieldType()
public static <VT> VT defaultValue(java.lang.Class<VT> clazz)
clazz
- the classprotected static java.lang.String buildMethodName(java.lang.String prefix, java.lang.String fieldName)
prefix
- the method's prefixfieldName
- the method's field namepublic F setDerivedValueFromAccessor()
deriveValueFromAccessor()
using
getSetter()
deriveValueFromAccessor()
protected F deriveValueFromAccessor()
MethodHandle.invoke(Object...)
method. When the
value returned is null
an attempt will be made to
instantiate it using either by using a default value from
DFLTS
(for primatives) or Class.newInstance()
on the
accessor's MethodType.returnType()
method.public void setTarget(T target)
BeanPathAdapter.FieldHandle
target
- the target to bind topublic T getTarget()
public java.lang.String getFieldName()
protected java.lang.invoke.MethodHandle getAccessor()
protected java.lang.invoke.MethodHandle getSetter()
public java.lang.Class<F> getDeclaredFieldType()
public java.lang.Class<?> getFieldType()
getAccessor()
of the property
valuepublic boolean hasDefaultDerived()