Class JsonbPolymorphismHandler


  • public class JsonbPolymorphismHandler
    extends Object
    • Constructor Detail

      • JsonbPolymorphismHandler

        public JsonbPolymorphismHandler()
    • Method Detail

      • hasPolymorphism

        public boolean hasPolymorphism​(Class<?> clazz)
      • getTypeToDeserialize

        public Class<?> getTypeToDeserialize​(jakarta.json.JsonObject jsonObject,
                                             Class<?> clazz)
      • getOrCreatePolymorphismTypeInfo

        public JsonbPolymorphismTypeInfo getOrCreatePolymorphismTypeInfo​(Class<?> clazz)
        Looks up a JsonbPolymorphismTypeInfo from the cache or creates it for the given clazz if it supports polymorphism. This is the case if either one of these conditions is truthy:
        • clazz has an JsonbTypeInfo annotation
        • any class in the type hierarchy of clazz has an JsonbTypeInfo annotation
        Parameters:
        clazz - Class to inspect
        Returns:
        JsonbPolymorphismTypeInfo if the class supports polymorphism, null otherwise
      • validateSubtypeCompatibility

        protected void validateSubtypeCompatibility​(Class<?> classToValidate)
        Validation fails if any clazz and JsonbSubtype.type() aren't compatible.
        Parameters:
        classToValidate - Class to validate
        Throws:
        jakarta.json.bind.JsonbException - validation failed
      • validateOnlyOneParentWithTypeInfo

        protected void validateOnlyOneParentWithTypeInfo​(Class<?> classToValidate)
        Validates that only one parent class (superclass + interfaces) has JsonbTypeInfo annotation
        Parameters:
        classToValidate - class to validate
        Throws:
        jakarta.json.bind.JsonbException - validation failed
      • validateNoTypeInfoKeyCollision

        protected void validateNoTypeInfoKeyCollision​(Class<?> classToValidate)
        Validates that JsonbTypeInfo.key() is only defined once in type hierarchy. Assumes validateOnlyOneParentWithTypeInfo(Class) already passed.
        Parameters:
        classToValidate - class to validate
        Throws:
        jakarta.json.bind.JsonbException - validation failed