Class PercentTypeSerializer
java.lang.Object
com.fasterxml.jackson.databind.JsonSerializer<PercentType>
dev.jcputney.elearning.parser.input.common.PercentTypeSerializer
- All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable
public class PercentTypeSerializer
extends com.fasterxml.jackson.databind.JsonSerializer<PercentType>
A custom serializer for the
PercentType class, enabling its conversion to a JSON string
representation during serialization.
This serializer ensures that the PercentType object is serialized as the string
representation of its value, while handling null values gracefully.
The intended use is to handle serialization of percentage values represented as decimals between 0 and 1 within a JSON structure.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer
com.fasterxml.jackson.databind.JsonSerializer.None -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidserialize(PercentType value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) Serializes aPercentTypeobject into its JSON string representation.Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer
acceptJsonFormatVisitor, getDelegatee, handledType, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId, withIgnoredProperties
-
Constructor Details
-
PercentTypeSerializer
public PercentTypeSerializer()
-
-
Method Details
-
serialize
public void serialize(PercentType value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) throws IOException Serializes aPercentTypeobject into its JSON string representation. Writes the value as a string if it is non-null; otherwise, writes a JSON null.- Specified by:
serializein classcom.fasterxml.jackson.databind.JsonSerializer<PercentType>- Parameters:
value- thePercentTypeobject to serialize; may be nullgen- theJsonGeneratorused to generate the JSON outputserializers- theSerializerProviderthat can provide serializers for serializing objects- Throws:
IOException- if an error occurs during JSON serialization
-