Class PropertyAccessorFactoryLambda
java.lang.Object
com.alibaba.fastjson2.introspect.PropertyAccessorFactory
com.alibaba.fastjson2.introspect.PropertyAccessorFactoryLambda
- Direct Known Subclasses:
PropertyAccessorFactoryUnsafe
-
Nested Class Summary
Nested classes/interfaces inherited from class PropertyAccessorFactory
PropertyAccessorFactory.PropertyAccessorBigDecimal, PropertyAccessorFactory.PropertyAccessorBigInteger, PropertyAccessorFactory.PropertyAccessorBoolean, PropertyAccessorFactory.PropertyAccessorBooleanValue, PropertyAccessorFactory.PropertyAccessorByte, PropertyAccessorFactory.PropertyAccessorByteValue, PropertyAccessorFactory.PropertyAccessorCharacter, PropertyAccessorFactory.PropertyAccessorCharValue, PropertyAccessorFactory.PropertyAccessorDouble, PropertyAccessorFactory.PropertyAccessorDoubleValue, PropertyAccessorFactory.PropertyAccessorFloat, PropertyAccessorFactory.PropertyAccessorInteger, PropertyAccessorFactory.PropertyAccessorIntValue, PropertyAccessorFactory.PropertyAccessorLong, PropertyAccessorFactory.PropertyAccessorLongValue, PropertyAccessorFactory.PropertyAccessorNumber, PropertyAccessorFactory.PropertyAccessorObject, PropertyAccessorFactory.PropertyAccessorShort, PropertyAccessorFactory.PropertyAccessorShortValue, PropertyAccessorFactory.PropertyAccessorString -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate(String name, Class<?> propertyClass, Type propertyType, Method getter, Method setter, BiFunction<PropertyAccessor, Throwable, RuntimeException> exceptionHandler) Creates a property accessor using getter and/or setter methods with explicit type information.createBiFunction(Constructor constructor) Creates a BiFunction that can instantiate objects using the given constructor.createDoubleFunction(Constructor constructor) Creates a Function that can instantiate objects using the given constructor.createFunction(Constructor constructor) Creates a Function that can instantiate objects using the given constructor.createIntFunction(Constructor constructor) Creates a Function that can instantiate objects using the given constructor.createLongFunction(Constructor constructor) Creates a Function that can instantiate objects using the given constructor.createSupplier(Constructor constructor) Creates a Supplier that can instantiate objects using the given constructor via MethodHandle and LambdaMetafactory for better performance than reflection.createSupplier(String name, Method getter, Method setter) Creates a property accessor using getter and/or setter methods.getBoolean(Method method) Creates a Predicate functional interface to access a boolean property via the given getter method.Creates a ToByteFunction functional interface to access a byte property via the given getter method.Creates a ToCharFunction functional interface to access a char property via the given getter method.Creates a ToIntFunction functional interface to access an int property via the given getter method.Creates a ToShortFunction functional interface to access a short property via the given getter method.protected MethodHandles.LookupsetBoolean(Method method) Creates an ObjBoolConsumer functional interface to set a boolean property via the given setter method.Creates a BiConsumer functional interface to set an Object property via the given setter 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.
-
Constructor Details
-
PropertyAccessorFactoryLambda
public PropertyAccessorFactoryLambda()
-
-
Method Details
-
lookup
-
createSupplier
Creates a Supplier that can instantiate objects using the given constructor via MethodHandle and LambdaMetafactory for better performance than reflection. If the MethodHandle approach fails, it falls back to the parent class implementation.- Overrides:
createSupplierin classPropertyAccessorFactory- Parameters:
constructor- the constructor to use for object instantiation- Returns:
- a Supplier that creates new instances using the provided constructor
-
createFunction
Description copied from class:PropertyAccessorFactoryCreates a Function that can instantiate objects using the given constructor.- Overrides:
createFunctionin classPropertyAccessorFactory- Parameters:
constructor- the constructor to use for object instantiation- Returns:
- a Function that creates new instances using the provided constructor
-
createIntFunction
Description copied from class:PropertyAccessorFactoryCreates a Function that can instantiate objects using the given constructor.- Overrides:
createIntFunctionin classPropertyAccessorFactory- Parameters:
constructor- the constructor to use for object instantiation- Returns:
- a Function that creates new instances using the provided constructor
-
createLongFunction
Description copied from class:PropertyAccessorFactoryCreates a Function that can instantiate objects using the given constructor.- Overrides:
createLongFunctionin classPropertyAccessorFactory- Parameters:
constructor- the constructor to use for object instantiation- Returns:
- a Function that creates new instances using the provided constructor
-
createDoubleFunction
Description copied from class:PropertyAccessorFactoryCreates a Function that can instantiate objects using the given constructor.- Overrides:
createDoubleFunctionin classPropertyAccessorFactory- Parameters:
constructor- the constructor to use for object instantiation- Returns:
- a Function that creates new instances using the provided constructor
-
createBiFunction
Description copied from class:PropertyAccessorFactoryCreates a BiFunction that can instantiate objects using the given constructor.- Overrides:
createBiFunctionin classPropertyAccessorFactory- Parameters:
constructor- the constructor to use for object instantiation- Returns:
- a BiFunction that creates new instances using the provided constructor
-
createSupplier
Creates a property accessor using getter and/or setter methods. This method delegates to the parent class's implementation.- Parameters:
name- the property namegetter- the getter method (optional, may be null)setter- the setter method (optional, may be null)- Returns:
- a PropertyAccessor instance for the specified getter/setter methods
-
create
public PropertyAccessor create(String name, Class<?> propertyClass, Type propertyType, Method getter, Method setter, BiFunction<PropertyAccessor, Throwable, RuntimeException> exceptionHandler) Creates a property accessor using getter and/or setter methods with explicit type information. This method attempts to optimize access by using LambdaMetafactory to create efficient functional interfaces for property access when possible.- Overrides:
createin classPropertyAccessorFactory- Parameters:
name- 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)- Returns:
- a PropertyAccessor instance for the specified getter/setter methods
-
getBoolean
Creates a Predicate functional interface to access a boolean property via the given getter method. Uses LambdaMetafactory to create an efficient functional interface that wraps the method call.- Parameters:
method- the getter method for the boolean property- Returns:
- a Predicate that can access the boolean property, or null if method is null
-
setBoolean
Creates an ObjBoolConsumer functional interface to set a boolean property via the given setter method. Uses LambdaMetafactory to create an efficient functional interface that wraps the method call.- Parameters:
method- the setter method for the boolean property- Returns:
- an ObjBoolConsumer that can set the boolean property, or null if method is null
-
getByte
Creates a ToByteFunction functional interface to access a byte property via the given getter method. For JDK 8, this implementation delegates to getInt and converts the result to byte.- Parameters:
method- the getter method for the byte property- Returns:
- a ToByteFunction that can access the byte property, or null if method is null
-
getShort
Creates a ToShortFunction functional interface to access a short property via the given getter method. For JDK 8, this implementation delegates to getInt and converts the result to short.- Parameters:
method- the getter method for the short property- Returns:
- a ToShortFunction that can access the short property, or null if method is null
-
getChar
Creates a ToCharFunction functional interface to access a char property via the given getter method. For JDK 8, this implementation delegates to getInt and converts the result to char.- Parameters:
method- the getter method for the char property- Returns:
- a ToCharFunction that can access the char property, or null if method is null
-
getInt
Creates a ToIntFunction functional interface to access an int property via the given getter method. Uses LambdaMetafactory to create an efficient functional interface that wraps the method call.- Parameters:
method- the getter method for the int property- Returns:
- a ToIntFunction that can access the int property, or null if method is null
-
getLong
-
getObject
-
setByte
-
setChar
-
setShort
-
setInt
-
setLong
-
getFloat
-
setFloat
-
getDouble
-
setDouble
-
setObject
Creates a BiConsumer functional interface to set an Object property via the given setter method. Uses LambdaMetafactory to create an efficient functional interface that wraps the method call.- Parameters:
method- the setter method for the Object property- Returns:
- a BiConsumer that can set the Object property, or null if method is null
-
setObject
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. Uses LambdaMetafactory to create an efficient functional interface that wraps the method call.- Parameters:
name- the property name (for chainable setters)method- the setter method for the Object property- Returns:
- a BiConsumer that can set the Object property, or null if method is null
-