Module dev.metaschema.databind
Package dev.metaschema.databind.io
Class AbstractDeserializer<CLASS extends IBoundObject>
java.lang.Object
dev.metaschema.databind.io.AbstractDeserializer<CLASS>
- Type Parameters:
CLASS- the bound class to deserialize to
- All Implemented Interfaces:
IConfiguration<DeserializationFeature<?>>,IMutableConfiguration<DeserializationFeature<?>>,IDeserializer<CLASS>
- Direct Known Subclasses:
DefaultJsonDeserializer,DefaultXmlDeserializer
public abstract class AbstractDeserializer<CLASS extends IBoundObject>
extends Object
implements IDeserializer<CLASS>
The base class of all format-specific deserializers.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDeserializer(IBoundDefinitionModelAssembly definition) Construct a new deserializer. -
Method Summary
Modifier and TypeMethodDescriptionReplace this configuration with theotherconfiguration.protected voidCallback method invoked when the configuration has been changed.deserializeToNodeItem(Reader reader, URI documentUri) Read data from theReaderinto a node item instance.protected abstract INodeItemdeserializeToNodeItemInternal(Reader reader, URI documentUri) This abstract method delegates parsing to the concrete implementation.final CLASSdeserializeToValue(Reader reader, URI documentUri) Read data from theReaderinto a node item instance.protected abstract CLASSdeserializeToValueInternal(Reader reader, URI documentUri) This abstract method delegates parsing to the concrete implementation, returning the deserialized value directly.disableFeature(DeserializationFeature<?> feature) Turn off the provided feature.enableFeature(DeserializationFeature<?> feature) Turn on the provided feature.<V> Vget(DeserializationFeature<?> feature) Get the configuration value of the providedfeature.protected IBindingContextRetrieve the binding context associated with the serializer.protected IMutableConfiguration<DeserializationFeature<?>>Get the current configuration of the serializer/deserializer.Get the constraint validation handler configured for this deserializer, which will be used to validate loaded data.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(DeserializationFeature<?> feature) Determines if a specific feature is enabled.set(DeserializationFeature<?> feature, Object value) Set the value of the providedfeatureto the provided value.voidsetConstraintValidationHandler(IConstraintValidationHandler constraintValidationHandler) Set the constraint violation handler for constraint validation.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.IDeserializer
deserialize, deserialize, deserialize, deserialize, deserialize, deserializeToNodeItem, isValidating
-
Constructor Details
-
AbstractDeserializer
Construct a new deserializer.- Parameters:
definition- the bound class information for the Java type this deserializer is operating on
-
-
Method Details
-
getConstraintValidationHandler
Get the constraint validation handler configured for this deserializer, which will be used to validate loaded data.- Specified by:
getConstraintValidationHandlerin interfaceIDeserializer<CLASS extends IBoundObject>- Returns:
- the deserializer
-
setConstraintValidationHandler
public void setConstraintValidationHandler(@NonNull IConstraintValidationHandler constraintValidationHandler) Description copied from interface:IDeserializerSet the constraint violation handler for constraint validation.- Specified by:
setConstraintValidationHandlerin interfaceIDeserializer<CLASS extends IBoundObject>- Parameters:
constraintValidationHandler- the handler to use
-
deserializeToNodeItem
Description copied from interface:IDeserializerRead data from theReaderinto a node item instance.- Specified by:
deserializeToNodeItemin interfaceIDeserializer<CLASS extends IBoundObject>- Parameters:
reader- the reader to read fromdocumentUri- the URI of the document to read from- Returns:
- a new node item
- Throws:
IOException- if an error occurred while reading data from the stream
-
deserializeToNodeItemInternal
@NonNull protected abstract INodeItem deserializeToNodeItemInternal(@NonNull Reader reader, @NonNull URI documentUri) throws IOException This abstract method delegates parsing to the concrete implementation.- Parameters:
reader- the reader instance to read data fromdocumentUri- the URI of the document that is being read- Returns:
- a new node item containing the read contents
- Throws:
IOException- if an error occurred while reading data from the stream
-
deserializeToValue
Description copied from interface:IDeserializerRead data from theReaderinto a node item instance.- Specified by:
deserializeToValuein interfaceIDeserializer<CLASS extends IBoundObject>- Parameters:
reader- the reader to read fromdocumentUri- the URI of the document to read from- Returns:
- a new node item
- Throws:
IOException- if an error occurred while reading data from the stream
-
deserializeToValueInternal
@NonNull protected abstract CLASS deserializeToValueInternal(@NonNull Reader reader, @NonNull URI documentUri) throws IOException This abstract method delegates parsing to the concrete implementation, returning the deserialized value directly.- Parameters:
reader- the reader instance to read data fromdocumentUri- the URI of the document that is being read- Returns:
- the deserialized object
- Throws:
IOException- if an error occurred while reading data from the stream
-
enableFeature
Description copied from interface:IMutableConfigurationTurn on the provided feature.- Specified by:
enableFeaturein interfaceIDeserializer<CLASS extends IBoundObject>- Specified by:
enableFeaturein interfaceIMutableConfiguration<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 interfaceIDeserializer<CLASS extends IBoundObject>- Specified by:
disableFeaturein interfaceIMutableConfiguration<CLASS extends IBoundObject>- Parameters:
feature- the feature to turn off- Returns:
- the updated configuration
- See Also:
-
applyConfiguration
public IDeserializer<CLASS> applyConfiguration(@NonNull IConfiguration<DeserializationFeature<?>> other) Description copied from interface:IMutableConfigurationReplace this configuration with theotherconfiguration.- Specified by:
applyConfigurationin interfaceIDeserializer<CLASS extends IBoundObject>- Specified by:
applyConfigurationin interfaceIMutableConfiguration<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 interfaceIDeserializer<CLASS extends IBoundObject>- Specified by:
setin interfaceIMutableConfiguration<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
protected void configurationChanged(@NonNull IMutableConfiguration<DeserializationFeature<?>> config) 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
-