Module org.apache.johnzon.jsonb
Class JsonbPolymorphismHandler
java.lang.Object
org.apache.johnzon.jsonb.polymorphism.JsonbPolymorphismHandler
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetOrCreatePolymorphismTypeInfo(Class<?> clazz) Looks up aJsonbPolymorphismTypeInfofrom the cache or creates it for the givenclazzif it supports polymorphism.getPolymorphismPropertiesToSerialize(Class<?> clazz, Collection<String> otherProperties) Class<?>getTypeToDeserialize(jakarta.json.JsonObject jsonObject, Class<?> clazz) booleanhasPolymorphism(Class<?> clazz) voidvalidateJsonbPolymorphismAnnotations(Class<?> classToValidate) ValidatesJsonbTypeInfoannotation on clazz and its parents (superclass/interfaces), seevalidateSubtypeCompatibility(Class),validateOnlyOneParentWithTypeInfo(Class)andvalidateNoTypeInfoKeyCollision(Class)protected voidvalidateNoTypeInfoKeyCollision(Class<?> classToValidate) Validates thatJsonbTypeInfo.key()is only defined once in type hierarchy.protected voidvalidateOnlyOneParentWithTypeInfo(Class<?> classToValidate) Validates that only one parent class (superclass + interfaces) hasJsonbTypeInfoannotationprotected voidvalidateSubtypeCompatibility(Class<?> classToValidate) Validation fails if any clazz andJsonbSubtype.type()aren't compatible.
-
Field Details
-
typeInfoCache
-
-
Constructor Details
-
JsonbPolymorphismHandler
public JsonbPolymorphismHandler()
-
-
Method Details
-
hasPolymorphism
-
getPolymorphismPropertiesToSerialize
-
getTypeToDeserialize
-
getOrCreatePolymorphismTypeInfo
Looks up aJsonbPolymorphismTypeInfofrom the cache or creates it for the givenclazzif it supports polymorphism. This is the case if either one of these conditions is truthy:clazzhas anJsonbTypeInfoannotation- any class in the type hierarchy of
clazzhas anJsonbTypeInfoannotation
- Parameters:
clazz- Class to inspect- Returns:
JsonbPolymorphismTypeInfoif the class supports polymorphism,nullotherwise
-
validateJsonbPolymorphismAnnotations
ValidatesJsonbTypeInfoannotation on clazz and its parents (superclass/interfaces), seevalidateSubtypeCompatibility(Class),validateOnlyOneParentWithTypeInfo(Class)andvalidateNoTypeInfoKeyCollision(Class)- Parameters:
classToValidate- Class to validate- Throws:
jakarta.json.bind.JsonbException- validation failed
-
validateSubtypeCompatibility
Validation fails if any clazz andJsonbSubtype.type()aren't compatible.- Parameters:
classToValidate- Class to validate- Throws:
jakarta.json.bind.JsonbException- validation failed
-
validateOnlyOneParentWithTypeInfo
Validates that only one parent class (superclass + interfaces) hasJsonbTypeInfoannotation- Parameters:
classToValidate- class to validate- Throws:
jakarta.json.bind.JsonbException- validation failed
-
validateNoTypeInfoKeyCollision
Validates thatJsonbTypeInfo.key()is only defined once in type hierarchy. AssumesvalidateOnlyOneParentWithTypeInfo(Class)already passed.- Parameters:
classToValidate- class to validate- Throws:
jakarta.json.bind.JsonbException- validation failed
-