Class JsonbPolymorphismHandler
- java.lang.Object
- 
- org.apache.johnzon.jsonb.polymorphism.JsonbPolymorphismHandler
 
- 
 public class JsonbPolymorphismHandler extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description private Map<Class<?>,JsonbPolymorphismTypeInfo>typeInfoCache
 - 
Constructor SummaryConstructors Constructor Description JsonbPolymorphismHandler()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonbPolymorphismTypeInfogetOrCreatePolymorphismTypeInfo(Class<?> clazz)Looks up aJsonbPolymorphismTypeInfofrom the cache or creates it for the givenclazzif it supports polymorphism.Map.Entry<String,String>[]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 Detail- 
typeInfoCacheprivate final Map<Class<?>,JsonbPolymorphismTypeInfo> typeInfoCache 
 
- 
 - 
Method Detail- 
hasPolymorphismpublic boolean hasPolymorphism(Class<?> clazz) 
 - 
getPolymorphismPropertiesToSerializepublic Map.Entry<String,String>[] getPolymorphismPropertiesToSerialize(Class<?> clazz, Collection<String> otherProperties) 
 - 
getTypeToDeserializepublic Class<?> getTypeToDeserialize(jakarta.json.JsonObject jsonObject, Class<?> clazz) 
 - 
getOrCreatePolymorphismTypeInfopublic JsonbPolymorphismTypeInfo getOrCreatePolymorphismTypeInfo(Class<?> clazz) 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 an- JsonbTypeInfoannotation
- any class in the type hierarchy of clazzhas anJsonbTypeInfoannotation
 - Parameters:
- clazz- Class to inspect
- Returns:
- JsonbPolymorphismTypeInfoif the class supports polymorphism,- nullotherwise
 
 - 
validateJsonbPolymorphismAnnotationspublic void validateJsonbPolymorphismAnnotations(Class<?> classToValidate) 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
 
 - 
validateSubtypeCompatibilityprotected void validateSubtypeCompatibility(Class<?> classToValidate) Validation fails if any clazz andJsonbSubtype.type()aren't compatible.- Parameters:
- classToValidate- Class to validate
- Throws:
- jakarta.json.bind.JsonbException- validation failed
 
 - 
validateOnlyOneParentWithTypeInfoprotected void validateOnlyOneParentWithTypeInfo(Class<?> classToValidate) Validates that only one parent class (superclass + interfaces) hasJsonbTypeInfoannotation- Parameters:
- classToValidate- class to validate
- Throws:
- jakarta.json.bind.JsonbException- validation failed
 
 - 
validateNoTypeInfoKeyCollisionprotected void validateNoTypeInfoKeyCollision(Class<?> classToValidate) 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
 
 
- 
 
-