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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    serialize(PercentType value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers)
    Serializes a PercentType object 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 a PercentType object into its JSON string representation. Writes the value as a string if it is non-null; otherwise, writes a JSON null.
      Specified by:
      serialize in class com.fasterxml.jackson.databind.JsonSerializer<PercentType>
      Parameters:
      value - the PercentType object to serialize; may be null
      gen - the JsonGenerator used to generate the JSON output
      serializers - the SerializerProvider that can provide serializers for serializing objects
      Throws:
      IOException - if an error occurs during JSON serialization