Class SerDeserializers


  • public final class SerDeserializers
    extends Object
    Manages a map of deserializers that assist with data migration.

    Deserializers handle situations where the data being read does not match the bean in the classpath. See also RenameHandler.

    Normally, it makes sense to customize the shared singleton instance, because the classpath is static and fixed and the transformations are common.

    Implementations must be thread-safe singletons.

    • Field Detail

      • INSTANCE

        public static final SerDeserializers INSTANCE
        Shared global instance which can be mutated.
      • LENIENT

        public static final SerDeserializers LENIENT
        Lenient instance which can be mutated.
    • Constructor Detail

      • SerDeserializers

        public SerDeserializers()
        Creates an instance.
      • SerDeserializers

        public SerDeserializers​(SerDeserializerProvider... providers)
        Creates an instance using additional providers.
        Parameters:
        providers - the providers to use
      • SerDeserializers

        public SerDeserializers​(boolean lenient,
                                SerDeserializerProvider... providers)
        Creates an instance using additional providers.
        Parameters:
        lenient - whether to deserialize leniently
        providers - the providers to use
    • Method Detail

      • register

        public SerDeserializers register​(Class<?> type,
                                         SerDeserializer deserializer)
        Adds the deserializer to be used for the specified type.
        Parameters:
        type - the type, not null
        deserializer - the deserializer, not null
        Returns:
        this, for chaining, not null
      • getDeserializers

        public ConcurrentMap<Class<?>,​SerDeserializer> getDeserializers()
        Gets the map of deserializers which can be modified.
        Returns:
        the map of deserializers, not null
      • registerProvider

        public SerDeserializers registerProvider​(SerDeserializerProvider provider)
        Adds the deserializer provider to be used.
        Parameters:
        provider - the deserializer provider, not null
        Returns:
        this, for chaining, not null
      • findDeserializer

        public SerDeserializer findDeserializer​(Class<?> type)
        Finds the deserializer for the specified type.

        The DefaultDeserializer is used if one has not been registered.

        Parameters:
        type - the type, not null
        Returns:
        the deserializer, not null
      • decodeType

        public Class<?> decodeType​(String typeStr,
                                   JodaBeanSer settings,
                                   String basePackage,
                                   Map<String,​Class<?>> knownTypes,
                                   Class<?> defaultType)
                            throws ClassNotFoundException
        Decodes the type
        Parameters:
        typeStr - the type, not null
        settings - the settings, not null
        basePackage - the base package, not null
        knownTypes - the known types, not null
        defaultType - the default type, not null
        Returns:
        the decoded type
        Throws:
        ClassNotFoundException - if the class is not found