Package org.joda.beans.ser
Class SerDeserializers
- java.lang.Object
-
- org.joda.beans.ser.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 Summary
Fields Modifier and Type Field Description static SerDeserializers
INSTANCE
Shared global instance which can be mutated.static SerDeserializers
LENIENT
Lenient instance which can be mutated.
-
Constructor Summary
Constructors Constructor Description SerDeserializers()
Creates an instance.SerDeserializers(boolean lenient, SerDeserializerProvider... providers)
Creates an instance using additional providers.SerDeserializers(SerDeserializerProvider... providers)
Creates an instance using additional providers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>
decodeType(String typeStr, JodaBeanSer settings, String basePackage, Map<String,Class<?>> knownTypes, Class<?> defaultType)
Decodes the typeSerDeserializer
findDeserializer(Class<?> type)
Finds the deserializer for the specified type.ConcurrentMap<Class<?>,SerDeserializer>
getDeserializers()
Gets the map of deserializers which can be modified.SerDeserializers
register(Class<?> type, SerDeserializer deserializer)
Adds the deserializer to be used for the specified type.SerDeserializers
registerProvider(SerDeserializerProvider provider)
Adds the deserializer provider to be used.String
toString()
-
-
-
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 lenientlyproviders
- 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 nulldeserializer
- 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 nullsettings
- the settings, not nullbasePackage
- the base package, not nullknownTypes
- the known types, not nulldefaultType
- the default type, not null- Returns:
- the decoded type
- Throws:
ClassNotFoundException
- if the class is not found
-
-