Class IdReferenceSerializer<T>
java.lang.Object
io.micronaut.serde.support.serializers.IdReferenceSerializer<T>
- Type Parameters:
T- The value type
- All Implemented Interfaces:
Serializer<T>
@Internal
@Singleton
public final class IdReferenceSerializer<T>
extends Object
implements Serializer<T>
Serializes a property that always references beans by their document-scoped identifier
(JAXB
@XmlIDREF, Jackson @JsonIdentityReference(alwaysAsId = true)): the referenced bean,
or each element of a referenced collection, is written as its identifier.- Since:
- 3.2
-
Nested Class Summary
Nested classes/interfaces inherited from interface Serializer
Serializer.EncoderContext -
Constructor Summary
ConstructorsConstructorDescriptionIdReferenceSerializer(SerdeIntrospections introspections) Creates the unspecialized identifier-reference serializer. -
Method Summary
Modifier and TypeMethodDescriptioncreateSpecific(Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type) Create a more specific serializer for the given definition.voidserialize(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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Serializer
isAbsent, isDefault, isEmpty
-
Constructor Details
-
IdReferenceSerializer
Creates the unspecialized identifier-reference serializer.- Parameters:
introspections- The serde introspections
-
-
Method Details
-
createSpecific
public Serializer<T> createSpecific(Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type) throws SerdeException Description copied from interface:SerializerCreate a more specific serializer for the given definition.- Specified by:
createSpecificin interfaceSerializer<T>- Parameters:
context- The encoder contexttype- The type definition including any annotation metadata- Returns:
- The more specific serializer
- Throws:
SerdeException
-
serialize
public void serialize(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type, T value) throws IOException Description copied from interface:SerializerSerializes the given value using the passedEncoder.- Specified by:
serializein interfaceSerializer<T>- Parameters:
encoder- The encoder to usecontext- The encoder context, nevernulltype- Models the generic type of the valuevalue- The value to serialize, nevernull. Callers should encode null values directly.- Throws:
IOException- If an error occurs during serialization
-