Package io.micronaut.serde.bson.custom
Class AbstractBsonSerde<T>
java.lang.Object
io.micronaut.serde.bson.custom.AbstractBsonSerde<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
Deserializer<T>
,Serde<T>
,Serializer<T>
- Direct Known Subclasses:
BsonRepresentationSerde
,CodecBsonDecoder
Abstract serializer/deserializer that needs to access Bson decoder/encoder.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.serde.Deserializer
Deserializer.DecoderContext
Nested classes/interfaces inherited from interface io.micronaut.serde.Serializer
Serializer.EncoderContext
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal T
deserialize
(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> type) Deserializes from the current state of theDecoder
an object of typeDeserializer
.protected abstract T
doDeserialize
(BsonReaderDecoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> type) protected abstract void
doSerialize
(BsonWriterEncoder encoder, Serializer.EncoderContext context, T value, io.micronaut.core.type.Argument<? extends T> type) final void
serialize
(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type, T value) Serializes the given value using the passedEncoder
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.serde.Deserializer
allowNull, createSpecific, deserializeNullable, getDefaultValue
Methods inherited from interface io.micronaut.serde.Serializer
createSpecific, isAbsent, isEmpty
-
Constructor Details
-
AbstractBsonSerde
public AbstractBsonSerde()
-
-
Method Details
-
doDeserialize
protected abstract T doDeserialize(BsonReaderDecoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> type) throws IOException - Throws:
IOException
-
doSerialize
protected abstract void doSerialize(BsonWriterEncoder encoder, Serializer.EncoderContext context, T value, io.micronaut.core.type.Argument<? extends T> type) throws IOException - Throws:
IOException
-
deserialize
public final T deserialize(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> type) throws IOException Description copied from interface:Deserializer
Deserializes from the current state of theDecoder
an object of typeDeserializer
.- Specified by:
deserialize
in interfaceDeserializer<T>
- Parameters:
decoder
- The decoder, nevernull
decoderContext
- The decoder context, nevernull
type
- The generic type to be deserialized- Returns:
- The deserialized object or
null
only ifDeserializer.allowNull()
returnstrue
- Throws:
IOException
- If an error occurs during deserialization of the object
-
serialize
public final void serialize(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type, T value) throws IOException Description copied from interface:Serializer
Serializes the given value using the passedEncoder
.- Specified by:
serialize
in interfaceSerializer<T>
- Parameters:
encoder
- The encoder to usecontext
- The encoder context, nevernull
type
- Models the generic type of the valuevalue
- The value, can benull
- Throws:
IOException
- If an error occurs during serialization
-