Class ScalaCollectionDeserializer<C extends scala.collection.Iterable<?>>
- Type Parameters:
C- The declared collection type
- All Implemented Interfaces:
io.micronaut.serde.Deserializer<C>, io.micronaut.serde.util.CustomizableDeserializer<C>
Writing and reading need different shapes of bean here, which is why this is separate from
ScalaIterableSerde and ScalaMapSerde rather than part of them. A serializer is
chosen by what it can accept, so one written for scala.collection.Iterable serves every
Scala collection; a deserializer is chosen by what it can produce, and one that
produces an Iterable cannot stand in where a List was asked for.
The type parameter is what makes one bean answer for all of them. Its bound is published as a type variable rather than a fixed type, and a type variable matches any subtype -- the device Micronaut Serialization's own enum support uses, and the only alternative to naming every collection anyone might declare.
What the elements become is left to the conversion service, so the value produced is a
List, a Seq, a Set or a Vector according to the declaration
rather than one shape for all of them. Those converters are already registered for binding
configuration and injection points; this reuses them.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.serde.Deserializer
io.micronaut.serde.Deserializer.DecoderContext -
Constructor Summary
ConstructorsConstructorDescriptionScalaCollectionDeserializer(io.micronaut.core.convert.ConversionService conversionService) -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.serde.Deserializer<C> createSpecific(io.micronaut.serde.Deserializer.DecoderContext context, io.micronaut.core.type.Argument<? super C> type) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.serde.util.CustomizableDeserializer
deserialize, deserializeNullable, getDefaultValue
-
Constructor Details
-
ScalaCollectionDeserializer
public ScalaCollectionDeserializer(io.micronaut.core.convert.ConversionService conversionService) - Parameters:
conversionService- Converts the decoded elements to the declared collection type
-
-
Method Details
-
createSpecific
public io.micronaut.serde.Deserializer<C> createSpecific(io.micronaut.serde.Deserializer.DecoderContext context, io.micronaut.core.type.Argument<? super C> type) throws io.micronaut.serde.exceptions.SerdeException - Specified by:
createSpecificin interfaceio.micronaut.serde.Deserializer<C extends scala.collection.Iterable<?>>- Throws:
io.micronaut.serde.exceptions.SerdeException
-