Module dev.metaschema.databind
Package dev.metaschema.databind.io
Class AbstractSerializer<CLASS extends IBoundObject>
java.lang.Object
dev.metaschema.databind.io.AbstractSerializer<CLASS>
- Type Parameters:
CLASS- the bound class to serialize from
- All Implemented Interfaces:
IConfiguration<SerializationFeature<?>>,IMutableConfiguration<SerializationFeature<?>>,ISerializer<CLASS>
- Direct Known Subclasses:
DefaultJsonSerializer,DefaultXmlSerializer
public abstract class AbstractSerializer<CLASS extends IBoundObject>
extends Object
implements ISerializer<CLASS>
The base class of all format-specific serializers.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractSerializer(IBoundDefinitionModelAssembly definition) Construct a new serializer. -
Method Summary
Modifier and TypeMethodDescriptionapplyConfiguration(IConfiguration<SerializationFeature<?>> other) Replace this configuration with theotherconfiguration.protected voidCallback method invoked when the configuration has been changed.disableFeature(SerializationFeature<?> feature) Turn off the provided feature.enableFeature(SerializationFeature<?> feature) Turn on the provided feature.<V> Vget(SerializationFeature<?> feature) Get the configuration value of the providedfeature.protected IBindingContextRetrieve the binding context associated with the serializer.protected IMutableConfiguration<SerializationFeature<?>>Get the current configuration of the serializer/deserializer.protected IBoundDefinitionModelAssemblyRetrieve the bound class information associated with the assembly that the serializer/deserializer will write/read data from.Get the mapping of each feature mapped to its value.booleanisFeatureEnabled(SerializationFeature<?> feature) Determines if a specific feature is enabled.set(SerializationFeature<?> feature, Object value) Set the value of the providedfeatureto the provided value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.metaschema.core.configuration.IConfiguration
get, getFeatureValues, isFeatureEnabledMethods inherited from interface dev.metaschema.databind.io.ISerializer
serialize, serialize, serialize, serialize
-
Constructor Details
-
AbstractSerializer
Construct a new serializer.- Parameters:
definition- the bound class information for the Java type this serializer is operating on
-
-
Method Details
-
enableFeature
Description copied from interface:IMutableConfigurationTurn on the provided feature.- Specified by:
enableFeaturein interfaceIMutableConfiguration<CLASS extends IBoundObject>- Specified by:
enableFeaturein interfaceISerializer<CLASS extends IBoundObject>- Parameters:
feature- the feature to turn on- Returns:
- the updated configuration
- See Also:
-
disableFeature
Description copied from interface:IMutableConfigurationTurn off the provided feature.- Specified by:
disableFeaturein interfaceIMutableConfiguration<CLASS extends IBoundObject>- Specified by:
disableFeaturein interfaceISerializer<CLASS extends IBoundObject>- Parameters:
feature- the feature to turn off- Returns:
- the updated configuration
- See Also:
-
applyConfiguration
public ISerializer<CLASS> applyConfiguration(@NonNull IConfiguration<SerializationFeature<?>> other) Description copied from interface:IMutableConfigurationReplace this configuration with theotherconfiguration.- Specified by:
applyConfigurationin interfaceIMutableConfiguration<CLASS extends IBoundObject>- Specified by:
applyConfigurationin interfaceISerializer<CLASS extends IBoundObject>- Parameters:
other- the new configuration- Returns:
- the updated configuration
-
set
Description copied from interface:IMutableConfigurationSet the value of the providedfeatureto the provided value.- Specified by:
setin interfaceIMutableConfiguration<CLASS extends IBoundObject>- Specified by:
setin interfaceISerializer<CLASS extends IBoundObject>- Parameters:
feature- the feature to setvalue- the value to set- Returns:
- the updated configuration
- See Also:
-
getBindingContext
Retrieve the binding context associated with the serializer.- Returns:
- the binding context
-
getDefinition
Retrieve the bound class information associated with the assembly that the serializer/deserializer will write/read data from.- Returns:
- the class binding for the Module assembly
-
configurationChanged
Callback method invoked when the configuration has been changed.Subclasses can override this method to handle configuration changes, such as resetting cached factory instances.
- Parameters:
config- the updated configuration
-
getConfiguration
Get the current configuration of the serializer/deserializer.- Returns:
- the configuration
-
isFeatureEnabled
Description copied from interface:IConfigurationDetermines if a specific feature is enabled.- Specified by:
isFeatureEnabledin interfaceIConfiguration<T extends IConfigurationFeature<?>>- Parameters:
feature- the feature to check for- Returns:
trueif the feature is enabled, orfalseotherwise- See Also:
-
getFeatureValues
Description copied from interface:IConfigurationGet the mapping of each feature mapped to its value.- Specified by:
getFeatureValuesin interfaceIConfiguration<T extends IConfigurationFeature<?>>- Returns:
- the mapping
-
get
Description copied from interface:IConfigurationGet the configuration value of the providedfeature.- Specified by:
getin interfaceIConfiguration<T extends IConfigurationFeature<?>>- Type Parameters:
V- the value type- Parameters:
feature- the requested feature- Returns:
- the value of the feature
-