Module org.apache.johnzon.jsonb
Class JsonbPolymorphismHandler
- java.lang.Object
-
- org.apache.johnzon.jsonb.polymorphism.JsonbPolymorphismHandler
-
public class JsonbPolymorphismHandler extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Class<?>,JsonbPolymorphismTypeInfo>typeInfoCache
-
Constructor Summary
Constructors Constructor Description JsonbPolymorphismHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Class<?>getParentWithTypeInfo(java.lang.Class<?> clazz)java.util.Map.Entry<java.lang.String,java.lang.String>[]getPolymorphismPropertiesToSerialize(java.lang.Class<?> clazz, java.util.Collection<java.lang.String> otherProperties)java.lang.Class<?>getTypeToDeserialize(jakarta.json.JsonObject jsonObject, java.lang.Class<?> clazz)booleanhasPolymorphism(java.lang.Class<?> clazz)voidpopulateTypeInfoCache(java.lang.Class<?> clazz)voidvalidateJsonbPolymorphismAnnotations(java.lang.Class<?> classToValidate)ValidatesJsonbTypeInfoannotation on clazz and its parents (superclass/interfaces), seevalidateSubtypeCompatibility(Class),validateOnlyOneParentWithTypeInfo(Class)andvalidateNoTypeInfoKeyCollision(Class)protected voidvalidateNoTypeInfoKeyCollision(java.lang.Class<?> classToValidate)Validates thatJsonbTypeInfo.key()is only defined once in type hierarchy.protected voidvalidateOnlyOneParentWithTypeInfo(java.lang.Class<?> classToValidate)Validates that only one parent class (superclass + interfaces) hasJsonbTypeInfoannotationprotected voidvalidateSubtypeCompatibility(java.lang.Class<?> classToValidate)Validation fails if any clazz andJsonbSubtype.type()aren't compatible.
-
-
-
Field Detail
-
typeInfoCache
private final java.util.Map<java.lang.Class<?>,JsonbPolymorphismTypeInfo> typeInfoCache
-
-
Method Detail
-
hasPolymorphism
public boolean hasPolymorphism(java.lang.Class<?> clazz)
-
getPolymorphismPropertiesToSerialize
public java.util.Map.Entry<java.lang.String,java.lang.String>[] getPolymorphismPropertiesToSerialize(java.lang.Class<?> clazz, java.util.Collection<java.lang.String> otherProperties)
-
getTypeToDeserialize
public java.lang.Class<?> getTypeToDeserialize(jakarta.json.JsonObject jsonObject, java.lang.Class<?> clazz)
-
populateTypeInfoCache
public void populateTypeInfoCache(java.lang.Class<?> clazz)
-
validateJsonbPolymorphismAnnotations
public void validateJsonbPolymorphismAnnotations(java.lang.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
-
validateSubtypeCompatibility
protected void validateSubtypeCompatibility(java.lang.Class<?> classToValidate)
Validation fails if any clazz andJsonbSubtype.type()aren't compatible.- Parameters:
classToValidate- Class to validate- Throws:
jakarta.json.bind.JsonbException- validation failed
-
validateOnlyOneParentWithTypeInfo
protected void validateOnlyOneParentWithTypeInfo(java.lang.Class<?> classToValidate)
Validates that only one parent class (superclass + interfaces) hasJsonbTypeInfoannotation- Parameters:
classToValidate- class to validate- Throws:
jakarta.json.bind.JsonbException- validation failed
-
validateNoTypeInfoKeyCollision
protected void validateNoTypeInfoKeyCollision(java.lang.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
-
getParentWithTypeInfo
protected java.lang.Class<?> getParentWithTypeInfo(java.lang.Class<?> clazz)
-
-