Package com.jayway.jsonpath.spi.mapper
Class JakartaMappingProvider
java.lang.Object
com.jayway.jsonpath.spi.mapper.JakartaMappingProvider
- All Implemented Interfaces:
MappingProvider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classprivate static classprivate static classRuntime adapter forJsonParserto pull the JSON objects and values from aJsonStructurecontent tree instead of plain JSON string. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate MethodfindMethod(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.private TypegetFirstTypeArgument(Type targetType) private Class<?> getRawClass(Type targetType) <T> Tmap(Object source, TypeRef<T> targetType, Configuration configuration) Maps supplied JSON sourceObjectto a given target type or collection.<T> Tmap(Object source, Class<T> targetType, Configuration configuration) Maps supplied JSON sourceObjectto a given target class or collection.private <T> TmapDecimalJsonNumber(jakarta.json.JsonNumber jsonNumber, Class<?> targetType) private Objectprivate <T> TmapIntegralJsonNumber(jakarta.json.JsonNumber jsonNumber, Class<?> targetType) private Collection<Object> newCollectionOfType(Class<?> collectionType) Creates new instance ofCollectiontype specified by the argument.private ObjectnewNoArgInstance(Class<?> targetType) Lists all publicly accessible constructors for theClassidentified 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.private ObjectunwrapJsonValue(Object jsonValue)
-
Field Details
-
jsonb
private final jakarta.json.bind.Jsonb jsonb -
jsonToClassMethod
-
jsonToTypeMethod
-
-
Constructor Details
-
JakartaMappingProvider
public JakartaMappingProvider() -
JakartaMappingProvider
public JakartaMappingProvider(jakarta.json.bind.JsonbConfig jsonbConfiguration)
-
-
Method Details
-
map
Maps supplied JSON sourceObjectto a given target class or collection. This implementation ignores the JsonPath'sConfigurationargument.- Specified by:
mapin interfaceMappingProvider- Type Parameters:
T- the mapped result type- Parameters:
source- object to maptargetType- the type the source object should be mapped toconfiguration- current configuration- Returns:
- return the mapped object
-
map
Maps supplied JSON sourceObjectto a given target type or collection. This implementation ignores the JsonPath'sConfigurationargument.Method may produce a
ClassCastExceptionon 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:
mapin interfaceMappingProvider- Type Parameters:
T- the mapped result type- Parameters:
source- object to maptargetType- the type the source object should be mapped toconfiguration- current configuration- Returns:
- return the mapped object
-
mapImpl
-
mapIntegralJsonNumber
-
mapDecimalJsonNumber
-
unwrapJsonValue
-
newCollectionOfType
Creates new instance ofCollectiontype 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
Lists all publicly accessible constructors for theClassidentified 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 returnsnull.- 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
Locates optional API method on the supplied JSON-B API implementation class with the supplied name and parameter types. Searches the superclasses up toObject, but ignores interfaces and default interface methods. Returnsnullif noMethodcan be found.- Parameters:
clazz- the implementation class to reflect uponname- the name of the methodparamTypes- the parameter types of the method- Returns:
- the
Methodreference, ornullif none found
-
getRawClass
-
getFirstTypeArgument
-