Module dev.metaschema.databind
Package dev.metaschema.databind.io
Interface ISerializer<CLASS extends IBoundObject>
- Type Parameters:
CLASS- the Java type from which data can be written
- All Superinterfaces:
IConfiguration<SerializationFeature<?>>,IMutableConfiguration<SerializationFeature<?>>
- All Known Implementing Classes:
AbstractSerializer,DefaultJsonSerializer,DefaultXmlSerializer,DefaultYamlSerializer
public interface ISerializer<CLASS extends IBoundObject>
extends IMutableConfiguration<SerializationFeature<?>>
Implementations of this interface are able to write data in a bound object
instance of the parameterized type to a structured data format.
-
Method Summary
Modifier and TypeMethodDescriptionapplyConfiguration(IConfiguration<SerializationFeature<?>> other) Replace this configuration with theotherconfiguration.disableFeature(SerializationFeature<?> feature) Turn off the provided feature.enableFeature(SerializationFeature<?> feature) Turn on the provided feature.default voidserialize(IBoundObject data, File file) Write data from a bound class instance to theFile.default voidserialize(IBoundObject data, OutputStream os) Write data from a bound class instance to theOutputStream.voidserialize(IBoundObject data, Writer writer) Write data from a bound class instance to theWriter.default voidserialize(IBoundObject data, Path path, OpenOption... openOptions) Write data from a bound class instance to theFile.set(SerializationFeature<?> feature, Object value) Set the value of the providedfeatureto the provided value.Methods inherited from interface dev.metaschema.core.configuration.IConfiguration
get, getFeatureValues, isFeatureEnabled
-
Method Details
-
enableFeature
Description copied from interface:IMutableConfigurationTurn on the provided feature.- 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 interfaceIMutableConfiguration<CLASS extends IBoundObject>- Parameters:
feature- the feature to turn off- Returns:
- the updated configuration
- See Also:
-
applyConfiguration
Description copied from interface:IMutableConfigurationReplace this configuration with theotherconfiguration.- 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 interfaceIMutableConfiguration<CLASS extends IBoundObject>- Parameters:
feature- the feature to setvalue- the value to set- Returns:
- the updated configuration
- See Also:
-
serialize
Write data from a bound class instance to theOutputStream.This method does not have ownership of the the provided output stream and will not close it.
- Parameters:
data- the instance dataos- the output stream to write to- Throws:
IOException- if an error occurred while writing data to the stream
-
serialize
default void serialize(@NonNull IBoundObject data, @NonNull Path path, OpenOption... openOptions) throws IOException Write data from a bound class instance to theFile.- Parameters:
data- the instance datapath- the file to write toopenOptions- options specifying how the file is opened- Throws:
IOException- if an error occurred while writing data to the file indicated by thepathparameter
-
serialize
Write data from a bound class instance to theFile.- Parameters:
data- the instance datafile- the file to write to- Throws:
IOException- if an error occurred while writing data to the stream
-
serialize
Write data from a bound class instance to theWriter.- Parameters:
data- the instance datawriter- the writer to write to- Throws:
IOException- if an error occurred while writing data to the stream
-