Class KeySerializer<T>

java.lang.Object
org.dominokit.jacksonapt.ser.map.key.KeySerializer<T>
Direct Known Subclasses:
BooleanKeySerializer, DateKeySerializer, EnumKeySerializer, NumberKeySerializer, ObjectKeySerializer, ToStringKeySerializer, UUIDKeySerializer

public abstract class KeySerializer<T>
extends java.lang.Object
Base class for all the Map key serializer. It handles null values and exceptions. The rest is delegated to implementations.
Version:
$Id: $
Author:
Nicolas Morel
  • Constructor Summary

    Constructors
    Constructor Description
    KeySerializer()  
  • Method Summary

    Modifier and Type Method Description
    protected abstract java.lang.String doSerialize​(T value, JsonSerializationContext ctx)
    Serializes a non-null object into a String to use as map's key.
    boolean mustBeEscaped​(JsonSerializationContext ctx)
    mustBeEscaped
    java.lang.String serialize​(T value, JsonSerializationContext ctx)
    Serializes an object into a String to use as map's key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KeySerializer

      public KeySerializer()
  • Method Details

    • mustBeEscaped

      public boolean mustBeEscaped​(JsonSerializationContext ctx)

      mustBeEscaped

      Parameters:
      ctx - Context for the full serialization process
      Returns:
      true if the serialized key must be escaped
    • serialize

      public java.lang.String serialize​(T value, JsonSerializationContext ctx) throws JsonSerializationException
      Serializes an object into a String to use as map's key.
      Parameters:
      value - Object to serialize
      ctx - Context for the full serialization process
      Returns:
      the key
      Throws:
      JsonSerializationException - if an error occurs during the serialization
    • doSerialize

      protected abstract java.lang.String doSerialize​(T value, JsonSerializationContext ctx)
      Serializes a non-null object into a String to use as map's key.
      Parameters:
      value - Object to serialize
      ctx - Context for the full serialization process
      Returns:
      the key