Class JakartaMappingProvider

java.lang.Object
com.jayway.jsonpath.spi.mapper.JakartaMappingProvider
All Implemented Interfaces:
MappingProvider

public class JakartaMappingProvider extends Object implements MappingProvider
  • Field Details

    • jsonb

      private final jakarta.json.bind.Jsonb jsonb
    • jsonToClassMethod

      private Method jsonToClassMethod
    • jsonToTypeMethod

      private Method jsonToTypeMethod
  • Constructor Details

    • JakartaMappingProvider

      public JakartaMappingProvider()
    • JakartaMappingProvider

      public JakartaMappingProvider(jakarta.json.bind.JsonbConfig jsonbConfiguration)
  • Method Details

    • map

      public <T> T map(Object source, Class<T> targetType, Configuration configuration)
      Maps supplied JSON source Object to a given target class or collection. This implementation ignores the JsonPath's Configuration argument.
      Specified by:
      map in interface MappingProvider
      Type Parameters:
      T - the mapped result type
      Parameters:
      source - object to map
      targetType - the type the source object should be mapped to
      configuration - current configuration
      Returns:
      return the mapped object
    • map

      public <T> T map(Object source, TypeRef<T> targetType, Configuration configuration)
      Maps supplied JSON source Object to a given target type or collection. This implementation ignores the JsonPath's Configuration argument.

      Method may produce a ClassCastException on an attempt to cast the result of JSON mapping operation to a requested target type, especially if a parameterized generic type is used.

      Specified by:
      map in interface MappingProvider
      Type Parameters:
      T - the mapped result type
      Parameters:
      source - object to map
      targetType - the type the source object should be mapped to
      configuration - current configuration
      Returns:
      return the mapped object
    • mapImpl

      private Object mapImpl(Object source, Type targetType)
    • mapIntegralJsonNumber

      private <T> T mapIntegralJsonNumber(jakarta.json.JsonNumber jsonNumber, Class<?> targetType)
    • mapDecimalJsonNumber

      private <T> T mapDecimalJsonNumber(jakarta.json.JsonNumber jsonNumber, Class<?> targetType)
    • unwrapJsonValue

      private Object unwrapJsonValue(Object jsonValue)
    • newCollectionOfType

      private Collection<Object> newCollectionOfType(Class<?> collectionType) throws MappingException
      Creates new instance of Collection type specified by the argument. If the argument refers to an interface, then a matching Java standard implementation is returned; if it is a concrete class, then method attempts to instantiate an object of that class given there is a public no-arg constructor available.
      Parameters:
      collectionType - collection type; may be an interface or a class
      Returns:
      instance of collection type identified by the argument
      Throws:
      MappingException - on a type that cannot be safely instantiated
    • newNoArgInstance

      private Object newNoArgInstance(Class<?> targetType) throws MappingException
      Lists all publicly accessible constructors for the Class identified by the argument, including any constructors inherited from superclasses, and uses a no-args constructor, if available, to create a new instance of the class. If argument is interface, this method returns null.
      Parameters:
      targetType - class type to create instance of
      Returns:
      an instance of the class represented by the argument
      Throws:
      MappingException - if no-arg public constructor is not there
    • findMethod

      private Method findMethod(Class<?> clazz, String name, Class<?>... paramTypes)
      Locates optional API method on the supplied JSON-B API implementation class with the supplied name and parameter types. Searches the superclasses up to Object, but ignores interfaces and default interface methods. Returns null if no Method can be found.
      Parameters:
      clazz - the implementation class to reflect upon
      name - the name of the method
      paramTypes - the parameter types of the method
      Returns:
      the Method reference, or null if none found
    • getRawClass

      private Class<?> getRawClass(Type targetType)
    • getFirstTypeArgument

      private Type getFirstTypeArgument(Type targetType)