T - the type of the object containing the propertypublic abstract class FunctionAccessor<T> extends java.lang.Object implements PropertyAccessor
Implements PropertyAccessor interface using functional interfaces for property access, providing efficient property access for serialization and deserialization operations.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.function.BiFunction<PropertyAccessor,java.lang.Throwable,java.lang.RuntimeException> |
exceptionHandler |
protected java.lang.Object |
getter
The getter function for accessing the property value
|
protected java.lang.String |
name
The name of the property being accessed
|
protected java.lang.Class<?> |
propertyClass
The runtime class of the property
|
protected java.lang.reflect.Type |
propertyType
The generic type of the property
|
protected java.lang.Object |
setter
The setter function for setting the property value
|
| Constructor and Description |
|---|
FunctionAccessor(java.lang.String name,
java.lang.reflect.Type propertyType,
java.lang.Class<?> propertyClass,
java.lang.Object getter,
java.lang.Object setter) |
FunctionAccessor(java.lang.String name,
java.lang.reflect.Type propertyType,
java.lang.Class<?> propertyClass,
java.lang.Object getter,
java.lang.Object setter,
java.util.function.BiFunction<PropertyAccessor,java.lang.Throwable,java.lang.RuntimeException> exceptionHandler)
Constructs a FunctionAccessor with the specified parameters.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) JSONException |
errorForGet(java.lang.Throwable e)
Creates a JSON exception for getter errors.
|
(package private) java.lang.RuntimeException |
errorForSet(java.lang.Throwable e)
Creates a JSON exception for setter errors.
|
java.lang.String |
name()
Returns the name of the property being accessed.
|
java.lang.Class<?> |
propertyClass()
Returns the runtime class of the property.
|
java.lang.reflect.Type |
propertyType()
Returns the generic type of the property.
|
boolean |
supportGet()
Checks if the property supports getting values.
|
boolean |
supportSet()
Checks if the property supports setting values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBooleanValue, getByteValue, getCharValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getObject, getShortValue, setBooleanValue, setByteValue, setCharValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setObject, setShortValueprotected final java.lang.String name
protected final java.lang.reflect.Type propertyType
protected final java.lang.Class<?> propertyClass
protected final java.lang.Object getter
protected final java.lang.Object setter
protected final java.util.function.BiFunction<PropertyAccessor,java.lang.Throwable,java.lang.RuntimeException> exceptionHandler
public FunctionAccessor(java.lang.String name,
java.lang.reflect.Type propertyType,
java.lang.Class<?> propertyClass,
java.lang.Object getter,
java.lang.Object setter)
public FunctionAccessor(java.lang.String name,
java.lang.reflect.Type propertyType,
java.lang.Class<?> propertyClass,
java.lang.Object getter,
java.lang.Object setter,
java.util.function.BiFunction<PropertyAccessor,java.lang.Throwable,java.lang.RuntimeException> exceptionHandler)
name - the name of the propertypropertyType - the generic type of the propertypropertyClass - the runtime class of the propertygetter - the getter function for accessing the property valuesetter - the setter function for setting the property valuepublic final java.lang.String name()
PropertyAccessorname in interface PropertyAccessorpublic final boolean supportGet()
supportGet in interface PropertyAccessorpublic final boolean supportSet()
supportSet in interface PropertyAccessorpublic final java.lang.Class<?> propertyClass()
PropertyAccessorpropertyClass in interface PropertyAccessorpublic final java.lang.reflect.Type propertyType()
PropertyAccessorpropertyType in interface PropertyAccessorfinal JSONException errorForGet(java.lang.Throwable e)
e - the exception that occurred during gettingjava.lang.RuntimeException errorForSet(java.lang.Throwable e)
e - the exception that occurred during setting