public abstract class PropertyAccessorFactoryLambda extends PropertyAccessorFactory
PropertyAccessorFactory.ConstructorBiFunction, PropertyAccessorFactory.ConstructorDoubleFunction, PropertyAccessorFactory.ConstructorFunction, PropertyAccessorFactory.ConstructorFunctionBase, PropertyAccessorFactory.ConstructorIntFunction, PropertyAccessorFactory.ConstructorLongFunction, PropertyAccessorFactory.ConstructorSupplier, PropertyAccessorFactory.FieldAccessorReflect, PropertyAccessorFactory.FieldAccessorReflectBigDecimal, PropertyAccessorFactory.FieldAccessorReflectBigInteger, PropertyAccessorFactory.FieldAccessorReflectBoolean, PropertyAccessorFactory.FieldAccessorReflectBooleanValue, PropertyAccessorFactory.FieldAccessorReflectByte, PropertyAccessorFactory.FieldAccessorReflectByteValue, PropertyAccessorFactory.FieldAccessorReflectCharacter, PropertyAccessorFactory.FieldAccessorReflectCharValue, PropertyAccessorFactory.FieldAccessorReflectDouble, PropertyAccessorFactory.FieldAccessorReflectDoubleValue, PropertyAccessorFactory.FieldAccessorReflectFloat, PropertyAccessorFactory.FieldAccessorReflectFloatValue, PropertyAccessorFactory.FieldAccessorReflectInteger, PropertyAccessorFactory.FieldAccessorReflectIntValue, PropertyAccessorFactory.FieldAccessorReflectLong, PropertyAccessorFactory.FieldAccessorReflectLongValue, PropertyAccessorFactory.FieldAccessorReflectNumber, PropertyAccessorFactory.FieldAccessorReflectObject, PropertyAccessorFactory.FieldAccessorReflectShort, PropertyAccessorFactory.FieldAccessorReflectShortValue, PropertyAccessorFactory.FieldAccessorReflectString, PropertyAccessorFactory.FunctionAccessorBigDecimal<T>, PropertyAccessorFactory.FunctionAccessorBigInteger<T>, PropertyAccessorFactory.FunctionAccessorBoolean<T>, PropertyAccessorFactory.FunctionAccessorBooleanValue<T>, PropertyAccessorFactory.FunctionAccessorByte<T>, PropertyAccessorFactory.FunctionAccessorByteValue<T>, PropertyAccessorFactory.FunctionAccessorCharacter<T>, PropertyAccessorFactory.FunctionAccessorCharValue<T>, PropertyAccessorFactory.FunctionAccessorDouble<T>, PropertyAccessorFactory.FunctionAccessorDoubleValue<T>, PropertyAccessorFactory.FunctionAccessorFloat<T>, PropertyAccessorFactory.FunctionAccessorFloatValue<T>, PropertyAccessorFactory.FunctionAccessorInteger<T>, PropertyAccessorFactory.FunctionAccessorIntValue<T>, PropertyAccessorFactory.FunctionAccessorLong<T>, PropertyAccessorFactory.FunctionAccessorLongValue<T>, PropertyAccessorFactory.FunctionAccessorNumber<T>, PropertyAccessorFactory.FunctionAccessorObject<T,V>, PropertyAccessorFactory.FunctionAccessorShort<T>, PropertyAccessorFactory.FunctionAccessorShortValue<T>, PropertyAccessorFactory.FunctionAccessorString<T>, PropertyAccessorFactory.MethodAccessorBigDecimal, PropertyAccessorFactory.MethodAccessorBigInteger, PropertyAccessorFactory.MethodAccessorBoolean, PropertyAccessorFactory.MethodAccessorBooleanValue, PropertyAccessorFactory.MethodAccessorByte, PropertyAccessorFactory.MethodAccessorByteValue, PropertyAccessorFactory.MethodAccessorCharacter, PropertyAccessorFactory.MethodAccessorCharValue, PropertyAccessorFactory.MethodAccessorDouble, PropertyAccessorFactory.MethodAccessorDoubleValue, PropertyAccessorFactory.MethodAccessorFloat, PropertyAccessorFactory.MethodAccessorFloatValue, PropertyAccessorFactory.MethodAccessorInteger, PropertyAccessorFactory.MethodAccessorIntValue, PropertyAccessorFactory.MethodAccessorLong, PropertyAccessorFactory.MethodAccessorLongValue, PropertyAccessorFactory.MethodAccessorNumber, PropertyAccessorFactory.MethodAccessorObject, PropertyAccessorFactory.MethodAccessorShort, PropertyAccessorFactory.MethodAccessorShortValue, PropertyAccessorFactory.MethodAccessorString, PropertyAccessorFactory.PropertyAccessorBigDecimal, PropertyAccessorFactory.PropertyAccessorBigInteger, PropertyAccessorFactory.PropertyAccessorBoolean, PropertyAccessorFactory.PropertyAccessorBooleanValue, PropertyAccessorFactory.PropertyAccessorByte, PropertyAccessorFactory.PropertyAccessorByteValue, PropertyAccessorFactory.PropertyAccessorCharacter, PropertyAccessorFactory.PropertyAccessorCharValue, PropertyAccessorFactory.PropertyAccessorDouble, PropertyAccessorFactory.PropertyAccessorDoubleValue, PropertyAccessorFactory.PropertyAccessorFloat, PropertyAccessorFactory.PropertyAccessorFloatValue, PropertyAccessorFactory.PropertyAccessorInteger, PropertyAccessorFactory.PropertyAccessorIntValue, PropertyAccessorFactory.PropertyAccessorLong, PropertyAccessorFactory.PropertyAccessorLongValue, PropertyAccessorFactory.PropertyAccessorNumber, PropertyAccessorFactory.PropertyAccessorObject, PropertyAccessorFactory.PropertyAccessorShort, PropertyAccessorFactory.PropertyAccessorShortValue, PropertyAccessorFactory.PropertyAccessorString, PropertyAccessorFactory.PropertyAccessorWrapper, PropertyAccessorFactory.PropertyAccessorWrapperBigDecimal, PropertyAccessorFactory.PropertyAccessorWrapperBigInteger, PropertyAccessorFactory.PropertyAccessorWrapperBoolean, PropertyAccessorFactory.PropertyAccessorWrapperBooleanValue, PropertyAccessorFactory.PropertyAccessorWrapperByte, PropertyAccessorFactory.PropertyAccessorWrapperByteValue, PropertyAccessorFactory.PropertyAccessorWrapperCharacter, PropertyAccessorFactory.PropertyAccessorWrapperCharValue, PropertyAccessorFactory.PropertyAccessorWrapperDouble, PropertyAccessorFactory.PropertyAccessorWrapperDoubleValue, PropertyAccessorFactory.PropertyAccessorWrapperFloat, PropertyAccessorFactory.PropertyAccessorWrapperFloatValue, PropertyAccessorFactory.PropertyAccessorWrapperInteger, PropertyAccessorFactory.PropertyAccessorWrapperIntValue, PropertyAccessorFactory.PropertyAccessorWrapperLong, PropertyAccessorFactory.PropertyAccessorWrapperLongValue, PropertyAccessorFactory.PropertyAccessorWrapperNumber, PropertyAccessorFactory.PropertyAccessorWrapperObject, PropertyAccessorFactory.PropertyAccessorWrapperShort, PropertyAccessorFactory.PropertyAccessorWrapperShortValue, PropertyAccessorFactory.PropertyAccessorWrapperString| Modifier and Type | Field and Description |
|---|---|
private static boolean |
USE_UNSAFE |
| Constructor and Description |
|---|
PropertyAccessorFactoryLambda() |
| Modifier and Type | Method and Description |
|---|---|
(package private) static java.lang.Class<?> |
box(java.lang.Class cls) |
PropertyAccessor |
create(java.lang.String name,
java.lang.Class<?> propertyClass,
java.lang.reflect.Type propertyType,
java.lang.reflect.Method getter,
java.lang.reflect.Method setter,
java.util.function.BiFunction<PropertyAccessor,java.lang.Throwable,java.lang.RuntimeException> exceptionHandler)
Creates a property accessor using getter and/or setter methods with explicit type information.
|
java.util.function.BiFunction |
createBiFunction(java.lang.reflect.Constructor constructor)
Creates a BiFunction that can instantiate objects using the given constructor.
|
java.util.function.DoubleFunction |
createDoubleFunction(java.lang.reflect.Constructor constructor)
Creates a Function that can instantiate objects using the given constructor.
|
java.util.function.Function |
createFunction(java.lang.reflect.Constructor constructor)
Creates a Function that can instantiate objects using the given constructor.
|
java.util.function.IntFunction |
createIntFunction(java.lang.reflect.Constructor constructor)
Creates a Function that can instantiate objects using the given constructor.
|
private PropertyAccessor |
createLambdaAccessor(java.lang.String name,
java.lang.Class<?> propertyClass,
java.lang.reflect.Type propertyType,
java.lang.reflect.Method getter,
java.lang.reflect.Method setter,
java.util.function.BiFunction<PropertyAccessor,java.lang.Throwable,java.lang.RuntimeException> exceptionHandler)
Creates a LambdaMetafactory based accessor for the given property.
|
java.util.function.LongFunction |
createLongFunction(java.lang.reflect.Constructor constructor)
Creates a Function that can instantiate objects using the given constructor.
|
java.util.function.Supplier |
createSupplier(java.lang.reflect.Constructor constructor)
Creates a Supplier that can instantiate objects using the given constructor
via MethodHandle and LambdaMetafactory for better performance than reflection.
|
PropertyAccessor |
createSupplier(java.lang.String name,
java.lang.reflect.Method getter,
java.lang.reflect.Method setter)
Creates a property accessor using getter and/or setter methods.
|
java.util.function.Predicate<java.lang.Object> |
getBoolean(java.lang.reflect.Method method)
Creates a Predicate functional interface to access a boolean property via the given getter method.
|
ToByteFunction<java.lang.Object> |
getByte(java.lang.reflect.Method method)
Creates a ToByteFunction functional interface to access a byte property via the given getter method.
|
ToCharFunction<java.lang.Object> |
getChar(java.lang.reflect.Method method)
Creates a ToCharFunction functional interface to access a char property via the given getter method.
|
java.util.function.ToDoubleFunction<java.lang.Object> |
getDouble(java.lang.reflect.Method method) |
ToFloatFunction<java.lang.Object> |
getFloat(java.lang.reflect.Method method) |
java.util.function.ToIntFunction<java.lang.Object> |
getInt(java.lang.reflect.Method method)
Creates a ToIntFunction functional interface to access an int property via the given getter method.
|
java.util.function.ToLongFunction<java.lang.Object> |
getLong(java.lang.reflect.Method method) |
java.util.function.Function<java.lang.Object,java.lang.Object> |
getObject(java.lang.reflect.Method method) |
ToShortFunction<java.lang.Object> |
getShort(java.lang.reflect.Method method)
Creates a ToShortFunction functional interface to access a short property via the given getter method.
|
(package private) static boolean |
isChainableSetter(java.lang.reflect.Method method)
Checks if the given method is a chainable setter (fluent setter).
|
private boolean |
lambdaSupported(java.lang.Class<?> declaringClass)
LambdaMetafactory requires the caller Lookup to have private access, otherwise it rejects the
call with
LambdaConversionException: Invalid caller. |
protected java.lang.invoke.MethodHandles.Lookup |
lookup(java.lang.Class<?> declaringClass) |
private java.lang.invoke.MethodHandles.Lookup |
lookup(java.lang.reflect.Method method) |
ObjBoolConsumer |
setBoolean(java.lang.reflect.Method method)
Creates an ObjBoolConsumer functional interface to set a boolean property via the given setter method.
|
ObjByteConsumer<java.lang.Object> |
setByte(java.lang.reflect.Method method) |
ObjCharConsumer<java.lang.Object> |
setChar(java.lang.reflect.Method method) |
java.util.function.ObjDoubleConsumer<java.lang.Object> |
setDouble(java.lang.reflect.Method method) |
ObjFloatConsumer |
setFloat(java.lang.reflect.Method method) |
java.util.function.ObjIntConsumer<java.lang.Object> |
setInt(java.lang.reflect.Method method) |
java.util.function.ObjLongConsumer<java.lang.Object> |
setLong(java.lang.reflect.Method method) |
java.util.function.BiConsumer<java.lang.Object,java.lang.Object> |
setObject(java.lang.reflect.Method method)
Creates a BiConsumer functional interface to set an Object property via the given setter method.
|
java.util.function.BiConsumer<java.lang.Object,java.lang.Object> |
setObject(java.lang.String name,
java.lang.reflect.Method method)
Creates a BiConsumer functional interface to set an Object property via the given setter method,
with the option to pass a property name for chainable setters.
|
ObjShortConsumer<java.lang.Object> |
setShort(java.lang.reflect.Method method) |
(package private) static void |
validateMethodAndParameterType(java.lang.reflect.Method method,
java.lang.Class<?> expectedParameterType)
Validates that the method has exactly one parameter of the expected type.
|
private static java.lang.IllegalArgumentException |
validateMethodAndParameterTypeError(java.lang.Class<?> expectedParameterType,
java.lang.Class<?>[] parameterTypes)
Creates an IllegalArgumentException for method parameter type validation errors.
|
(package private) static void |
validateMethodAndReturnType(java.lang.reflect.Method method,
java.lang.Class<?> expectedReturnType)
Validates that the method has the expected return type.
|
private static java.lang.IllegalArgumentException |
validateMethodAndReturnTypeEror(java.lang.reflect.Method method,
java.lang.Class<?> expectedReturnType)
Creates an IllegalArgumentException for method return type validation errors.
|
private java.lang.invoke.MethodHandles.Lookup lookup(java.lang.reflect.Method method)
protected java.lang.invoke.MethodHandles.Lookup lookup(java.lang.Class<?> declaringClass)
private boolean lambdaSupported(java.lang.Class<?> declaringClass)
LambdaConversionException: Invalid caller. When lookup(Class) cannot
produce a trusted lookup (for example JDKUtils.trustedLookup degraded to
IMPL_LOOKUP.in(declaringClass), which drops the PRIVATE bit), the lambda path can never
succeed, so the reflection based accessors are used directly instead of throwing per property.declaringClass - the class declaring the getter/setterpublic java.util.function.Supplier createSupplier(java.lang.reflect.Constructor constructor)
createSupplier in class PropertyAccessorFactoryconstructor - the constructor to use for object instantiationpublic java.util.function.Function createFunction(java.lang.reflect.Constructor constructor)
PropertyAccessorFactorycreateFunction in class PropertyAccessorFactoryconstructor - the constructor to use for object instantiationpublic java.util.function.IntFunction createIntFunction(java.lang.reflect.Constructor constructor)
PropertyAccessorFactorycreateIntFunction in class PropertyAccessorFactoryconstructor - the constructor to use for object instantiationpublic java.util.function.LongFunction createLongFunction(java.lang.reflect.Constructor constructor)
PropertyAccessorFactorycreateLongFunction in class PropertyAccessorFactoryconstructor - the constructor to use for object instantiationpublic java.util.function.DoubleFunction createDoubleFunction(java.lang.reflect.Constructor constructor)
PropertyAccessorFactorycreateDoubleFunction in class PropertyAccessorFactoryconstructor - the constructor to use for object instantiationpublic java.util.function.BiFunction createBiFunction(java.lang.reflect.Constructor constructor)
PropertyAccessorFactorycreateBiFunction in class PropertyAccessorFactoryconstructor - the constructor to use for object instantiationstatic java.lang.Class<?> box(java.lang.Class cls)
public PropertyAccessor createSupplier(java.lang.String name, java.lang.reflect.Method getter, java.lang.reflect.Method setter)
name - the property namegetter - the getter method (optional, may be null)setter - the setter method (optional, may be null)public PropertyAccessor create(java.lang.String name, java.lang.Class<?> propertyClass, java.lang.reflect.Type propertyType, java.lang.reflect.Method getter, java.lang.reflect.Method setter, java.util.function.BiFunction<PropertyAccessor,java.lang.Throwable,java.lang.RuntimeException> exceptionHandler)
create in class PropertyAccessorFactoryname - the property namepropertyClass - the class of the property valuepropertyType - the generic type of the property valuegetter - the getter method (optional, may be null)setter - the setter method (optional, may be null)private PropertyAccessor createLambdaAccessor(java.lang.String name, java.lang.Class<?> propertyClass, java.lang.reflect.Type propertyType, java.lang.reflect.Method getter, java.lang.reflect.Method setter, java.util.function.BiFunction<PropertyAccessor,java.lang.Throwable,java.lang.RuntimeException> exceptionHandler)
static void validateMethodAndReturnType(java.lang.reflect.Method method,
java.lang.Class<?> expectedReturnType)
method - the method to validateexpectedReturnType - the expected return typeprivate static java.lang.IllegalArgumentException validateMethodAndReturnTypeEror(java.lang.reflect.Method method,
java.lang.Class<?> expectedReturnType)
method - the method with the mismatched return typeexpectedReturnType - the expected return typepublic java.util.function.Predicate<java.lang.Object> getBoolean(java.lang.reflect.Method method)
method - the getter method for the boolean propertypublic ObjBoolConsumer setBoolean(java.lang.reflect.Method method)
method - the setter method for the boolean propertypublic ToByteFunction<java.lang.Object> getByte(java.lang.reflect.Method method)
method - the getter method for the byte propertypublic ToShortFunction<java.lang.Object> getShort(java.lang.reflect.Method method)
method - the getter method for the short propertypublic ToCharFunction<java.lang.Object> getChar(java.lang.reflect.Method method)
method - the getter method for the char propertypublic java.util.function.ToIntFunction<java.lang.Object> getInt(java.lang.reflect.Method method)
method - the getter method for the int propertypublic java.util.function.ToLongFunction<java.lang.Object> getLong(java.lang.reflect.Method method)
public java.util.function.Function<java.lang.Object,java.lang.Object> getObject(java.lang.reflect.Method method)
public ObjByteConsumer<java.lang.Object> setByte(java.lang.reflect.Method method)
public ObjCharConsumer<java.lang.Object> setChar(java.lang.reflect.Method method)
public ObjShortConsumer<java.lang.Object> setShort(java.lang.reflect.Method method)
public java.util.function.ObjIntConsumer<java.lang.Object> setInt(java.lang.reflect.Method method)
public java.util.function.ObjLongConsumer<java.lang.Object> setLong(java.lang.reflect.Method method)
public ToFloatFunction<java.lang.Object> getFloat(java.lang.reflect.Method method)
public ObjFloatConsumer setFloat(java.lang.reflect.Method method)
public java.util.function.ToDoubleFunction<java.lang.Object> getDouble(java.lang.reflect.Method method)
public java.util.function.ObjDoubleConsumer<java.lang.Object> setDouble(java.lang.reflect.Method method)
public java.util.function.BiConsumer<java.lang.Object,java.lang.Object> setObject(java.lang.reflect.Method method)
method - the setter method for the Object propertypublic java.util.function.BiConsumer<java.lang.Object,java.lang.Object> setObject(java.lang.String name,
java.lang.reflect.Method method)
name - the property name (for chainable setters)method - the setter method for the Object propertystatic boolean isChainableSetter(java.lang.reflect.Method method)
method - the method to checkstatic void validateMethodAndParameterType(java.lang.reflect.Method method,
java.lang.Class<?> expectedParameterType)
method - the method to validateexpectedParameterType - the expected parameter typeprivate static java.lang.IllegalArgumentException validateMethodAndParameterTypeError(java.lang.Class<?> expectedParameterType,
java.lang.Class<?>[] parameterTypes)
expectedParameterType - the expected parameter typeparameterTypes - the actual parameter types