Class OracleJsonDurationSerde
java.lang.Object
io.micronaut.serde.oracle.jdbc.json.serde.OracleJsonDurationSerde
- All Implemented Interfaces:
Deserializer<Duration>
,Serde<Duration>
,Serializer<Duration>
@Singleton
@Order(-100)
public class OracleJsonDurationSerde
extends Object
implements Serde<Duration>
The custom serde for
Duration
for Oracle JSON. Needed because default serde in Micronaut expects number (nanos)
to deserialize from, but we are getting it as String from Oracle JSON parser.- Since:
- 2.0.0
- Author:
- radovanradic
-
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 TypeMethodDescription@NonNull Duration
deserialize
(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super Duration> type) Deserializes from the current state of theDecoder
an object of typeDeserializer
.void
serialize
(@NonNull Encoder encoder, @NonNull Serializer.EncoderContext context, @NonNull io.micronaut.core.type.Argument<? extends Duration> type, Duration 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
-
OracleJsonDurationSerde
public OracleJsonDurationSerde()
-
-
Method Details
-
deserialize
@NonNull public @NonNull Duration deserialize(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super Duration> type) throws IOException Description copied from interface:Deserializer
Deserializes from the current state of theDecoder
an object of typeDeserializer
.- Specified by:
deserialize
in interfaceDeserializer<Duration>
- 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 void serialize(@NonNull @NonNull Encoder encoder, @NonNull @NonNull Serializer.EncoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? extends Duration> type, Duration value) throws IOException Description copied from interface:Serializer
Serializes the given value using the passedEncoder
.- Specified by:
serialize
in interfaceSerializer<Duration>
- 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
-