Search in sources :

Example 1 with NullableDeserializer

use of io.micronaut.serde.util.NullableDeserializer in project micronaut-serialization by micronaut-projects.

the class DefaultSerdeRegistry method registerPrimitiveSerdes.

private void registerPrimitiveSerdes() {
    this.deserializerMap.put(new TypeKey(Argument.BOOLEAN), (decoder, decoderContext, type) -> decoder.decodeBoolean());
    this.deserializerMap.put(new TypeKey(Argument.of(Boolean.class)), (NullableDeserializer<Boolean>) (decoder, decoderContext, type) -> decoder.decodeBoolean());
    this.deserializerMap.put(new TypeKey(Argument.CHAR), (decoder, decoderContext, type) -> decoder.decodeChar());
    this.deserializerMap.put(new TypeKey(Argument.of(Character.class)), (NullableDeserializer<Character>) (decoder, decoderContext, type) -> decoder.decodeChar());
}
Also used : OrderUtil(io.micronaut.core.order.OrderUtil) Arrays(java.util.Arrays) ObjectDeserializer(io.micronaut.serde.support.deserializers.ObjectDeserializer) BeanContext(io.micronaut.context.BeanContext) URL(java.net.URL) ArrayUtils(io.micronaut.core.util.ArrayUtils) SerdeRegistry(io.micronaut.serde.SerdeRegistry) BigDecimal(java.math.BigDecimal) Locale(java.util.Locale) Map(java.util.Map) SerdeIntrospections(io.micronaut.serde.SerdeIntrospections) BigInteger(java.math.BigInteger) URI(java.net.URI) TimeZone(java.util.TimeZone) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Singleton(jakarta.inject.Singleton) PropertyNamingStrategy(io.micronaut.serde.config.naming.PropertyNamingStrategy) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) StringUtils(io.micronaut.core.util.StringUtils) List(java.util.List) Stream(java.util.stream.Stream) Decoder(io.micronaut.serde.Decoder) BeanRegistration(io.micronaut.context.BeanRegistration) ObjectSerializer(io.micronaut.serde.support.serializers.ObjectSerializer) OptionalDouble(java.util.OptionalDouble) TypeKey(io.micronaut.serde.support.util.TypeKey) HashMap(java.util.HashMap) Encoder(io.micronaut.serde.Encoder) Deserializer(io.micronaut.serde.Deserializer) OptionalInt(java.util.OptionalInt) ArrayList(java.util.ArrayList) OptionalLong(java.util.OptionalLong) Serializer(io.micronaut.serde.Serializer) Charset(java.nio.charset.Charset) Nullable(io.micronaut.core.annotation.Nullable) Secondary(io.micronaut.context.annotation.Secondary) Argument(io.micronaut.core.type.Argument) NumberSerde(io.micronaut.serde.support.serdes.NumberSerde) ConfigurationException(io.micronaut.context.exceptions.ConfigurationException) Iterator(java.util.Iterator) NullableDeserializer(io.micronaut.serde.util.NullableDeserializer) IOException(java.io.IOException) ReflectionUtils(io.micronaut.core.reflect.ReflectionUtils) NonNull(io.micronaut.core.annotation.NonNull) Serde(io.micronaut.serde.Serde) CollectionUtils(io.micronaut.core.util.CollectionUtils) BeanIntrospection(io.micronaut.core.beans.BeanIntrospection) BeanDefinition(io.micronaut.inject.BeanDefinition) Collections(java.util.Collections) Order(io.micronaut.core.annotation.Order) SerdeException(io.micronaut.serde.exceptions.SerdeException) NullableSerde(io.micronaut.serde.util.NullableSerde) TypeKey(io.micronaut.serde.support.util.TypeKey)

Example 2 with NullableDeserializer

use of io.micronaut.serde.util.NullableDeserializer in project micronaut-serialization by micronaut-projects.

the class DefaultSerdeRegistry method registerBuiltInSerdes.

private void registerBuiltInSerdes() {
    this.deserializerMap.put(new TypeKey(Argument.STRING), (NullableDeserializer<String>) (decoder, decoderContext, type) -> decoder.decodeString());
    Stream.of(new IntegerSerde(), new LongSerde(), new ShortSerde(), new FloatSerde(), new ByteSerde(), new DoubleSerde(), new OptionalIntSerde(), new OptionalDoubleSerde(), new OptionalLongSerde(), new BigDecimalSerde(), new BigIntegerSerde(), new UUIDSerde(), new URLSerde(), new URISerde(), new CharsetSerde(), new TimeZoneSerde(), new LocaleSerde(), new IntArraySerde(), new LongArraySerde(), new FloatArraySerde(), new ShortArraySerde(), new DoubleArraySerde(), new BooleanArraySerde(), new ByteArraySerde(), new CharArraySerde()).forEach(this::register);
}
Also used : OrderUtil(io.micronaut.core.order.OrderUtil) Arrays(java.util.Arrays) ObjectDeserializer(io.micronaut.serde.support.deserializers.ObjectDeserializer) BeanContext(io.micronaut.context.BeanContext) URL(java.net.URL) ArrayUtils(io.micronaut.core.util.ArrayUtils) SerdeRegistry(io.micronaut.serde.SerdeRegistry) BigDecimal(java.math.BigDecimal) Locale(java.util.Locale) Map(java.util.Map) SerdeIntrospections(io.micronaut.serde.SerdeIntrospections) BigInteger(java.math.BigInteger) URI(java.net.URI) TimeZone(java.util.TimeZone) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Singleton(jakarta.inject.Singleton) PropertyNamingStrategy(io.micronaut.serde.config.naming.PropertyNamingStrategy) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) StringUtils(io.micronaut.core.util.StringUtils) List(java.util.List) Stream(java.util.stream.Stream) Decoder(io.micronaut.serde.Decoder) BeanRegistration(io.micronaut.context.BeanRegistration) ObjectSerializer(io.micronaut.serde.support.serializers.ObjectSerializer) OptionalDouble(java.util.OptionalDouble) TypeKey(io.micronaut.serde.support.util.TypeKey) HashMap(java.util.HashMap) Encoder(io.micronaut.serde.Encoder) Deserializer(io.micronaut.serde.Deserializer) OptionalInt(java.util.OptionalInt) ArrayList(java.util.ArrayList) OptionalLong(java.util.OptionalLong) Serializer(io.micronaut.serde.Serializer) Charset(java.nio.charset.Charset) Nullable(io.micronaut.core.annotation.Nullable) Secondary(io.micronaut.context.annotation.Secondary) Argument(io.micronaut.core.type.Argument) NumberSerde(io.micronaut.serde.support.serdes.NumberSerde) ConfigurationException(io.micronaut.context.exceptions.ConfigurationException) Iterator(java.util.Iterator) NullableDeserializer(io.micronaut.serde.util.NullableDeserializer) IOException(java.io.IOException) ReflectionUtils(io.micronaut.core.reflect.ReflectionUtils) NonNull(io.micronaut.core.annotation.NonNull) Serde(io.micronaut.serde.Serde) CollectionUtils(io.micronaut.core.util.CollectionUtils) BeanIntrospection(io.micronaut.core.beans.BeanIntrospection) BeanDefinition(io.micronaut.inject.BeanDefinition) Collections(java.util.Collections) Order(io.micronaut.core.annotation.Order) SerdeException(io.micronaut.serde.exceptions.SerdeException) NullableSerde(io.micronaut.serde.util.NullableSerde) TypeKey(io.micronaut.serde.support.util.TypeKey)

Aggregations

BeanContext (io.micronaut.context.BeanContext)2 BeanRegistration (io.micronaut.context.BeanRegistration)2 Secondary (io.micronaut.context.annotation.Secondary)2 ConfigurationException (io.micronaut.context.exceptions.ConfigurationException)2 NonNull (io.micronaut.core.annotation.NonNull)2 Nullable (io.micronaut.core.annotation.Nullable)2 Order (io.micronaut.core.annotation.Order)2 BeanIntrospection (io.micronaut.core.beans.BeanIntrospection)2 OrderUtil (io.micronaut.core.order.OrderUtil)2 ReflectionUtils (io.micronaut.core.reflect.ReflectionUtils)2 Argument (io.micronaut.core.type.Argument)2 ArrayUtils (io.micronaut.core.util.ArrayUtils)2 CollectionUtils (io.micronaut.core.util.CollectionUtils)2 StringUtils (io.micronaut.core.util.StringUtils)2 BeanDefinition (io.micronaut.inject.BeanDefinition)2 Decoder (io.micronaut.serde.Decoder)2 Deserializer (io.micronaut.serde.Deserializer)2 Encoder (io.micronaut.serde.Encoder)2 Serde (io.micronaut.serde.Serde)2 SerdeIntrospections (io.micronaut.serde.SerdeIntrospections)2