Class PropertyAccessorFactoryLambda

java.lang.Object
com.alibaba.fastjson2.introspect.PropertyAccessorFactory
com.alibaba.fastjson2.introspect.PropertyAccessorFactoryLambda
Direct Known Subclasses:
PropertyAccessorFactoryUnsafe

public abstract class PropertyAccessorFactoryLambda extends PropertyAccessorFactory
  • Constructor Details

    • PropertyAccessorFactoryLambda

      public PropertyAccessorFactoryLambda()
  • Method Details

    • lookup

      protected MethodHandles.Lookup lookup(Class<?> declaringClass)
    • createSupplier

      public Supplier createSupplier(Constructor constructor)
      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:
      createSupplier in class PropertyAccessorFactory
      Parameters:
      constructor - the constructor to use for object instantiation
      Returns:
      a Supplier that creates new instances using the provided constructor
    • createFunction

      public Function createFunction(Constructor constructor)
      Description copied from class: PropertyAccessorFactory
      Creates a Function that can instantiate objects using the given constructor.
      Overrides:
      createFunction in class PropertyAccessorFactory
      Parameters:
      constructor - the constructor to use for object instantiation
      Returns:
      a Function that creates new instances using the provided constructor
    • createIntFunction

      public IntFunction createIntFunction(Constructor constructor)
      Description copied from class: PropertyAccessorFactory
      Creates a Function that can instantiate objects using the given constructor.
      Overrides:
      createIntFunction in class PropertyAccessorFactory
      Parameters:
      constructor - the constructor to use for object instantiation
      Returns:
      a Function that creates new instances using the provided constructor
    • createLongFunction

      public LongFunction createLongFunction(Constructor constructor)
      Description copied from class: PropertyAccessorFactory
      Creates a Function that can instantiate objects using the given constructor.
      Overrides:
      createLongFunction in class PropertyAccessorFactory
      Parameters:
      constructor - the constructor to use for object instantiation
      Returns:
      a Function that creates new instances using the provided constructor
    • createDoubleFunction

      public DoubleFunction createDoubleFunction(Constructor constructor)
      Description copied from class: PropertyAccessorFactory
      Creates a Function that can instantiate objects using the given constructor.
      Overrides:
      createDoubleFunction in class PropertyAccessorFactory
      Parameters:
      constructor - the constructor to use for object instantiation
      Returns:
      a Function that creates new instances using the provided constructor
    • createBiFunction

      public BiFunction createBiFunction(Constructor constructor)
      Description copied from class: PropertyAccessorFactory
      Creates a BiFunction that can instantiate objects using the given constructor.
      Overrides:
      createBiFunction in class PropertyAccessorFactory
      Parameters:
      constructor - the constructor to use for object instantiation
      Returns:
      a BiFunction that creates new instances using the provided constructor
    • createSupplier

      public PropertyAccessor createSupplier(String name, Method getter, Method setter)
      Creates a property accessor using getter and/or setter methods. This method delegates to the parent class's implementation.
      Parameters:
      name - the property name
      getter - 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:
      create in class PropertyAccessorFactory
      Parameters:
      name - the property name
      propertyClass - the class of the property value
      propertyType - the generic type of the property value
      getter - 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

      public Predicate<Object> getBoolean(Method method)
      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

      public ObjBoolConsumer setBoolean(Method method)
      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

      public ToByteFunction<Object> getByte(Method method)
      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

      public ToShortFunction<Object> getShort(Method method)
      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

      public ToCharFunction<Object> getChar(Method method)
      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

      public ToIntFunction<Object> getInt(Method method)
      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

      public ToLongFunction<Object> getLong(Method method)
    • getObject

      public Function<Object,Object> getObject(Method method)
    • setByte

      public ObjByteConsumer<Object> setByte(Method method)
    • setChar

      public ObjCharConsumer<Object> setChar(Method method)
    • setShort

      public ObjShortConsumer<Object> setShort(Method method)
    • setInt

      public ObjIntConsumer<Object> setInt(Method method)
    • setLong

      public ObjLongConsumer<Object> setLong(Method method)
    • getFloat

      public ToFloatFunction<Object> getFloat(Method method)
    • setFloat

      public ObjFloatConsumer setFloat(Method method)
    • getDouble

      public ToDoubleFunction<Object> getDouble(Method method)
    • setDouble

      public ObjDoubleConsumer<Object> setDouble(Method method)
    • setObject

      public BiConsumer<Object,Object> setObject(Method method)
      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

      public BiConsumer<Object,Object> setObject(String name, 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. 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