Class RecordSerializer<R extends Record>

java.lang.Object
dev.siroshun.configapi.serialization.record.RecordSerializer<R>
Type Parameters:
R - the type of the Record
All Implemented Interfaces:
dev.siroshun.serialization.core.Serializer<R,MapNode>, Function<R,MapNode>

@Experimental public final class RecordSerializer<R extends Record> extends Object implements dev.siroshun.serialization.core.Serializer<R,MapNode>
A Serializer implementation for serializing Record object to MapNode.
  • Method Details

    • serializer

      @NotNull public static <R extends Record> @NotNull RecordSerializer<R> serializer()
      Gets the default RecordSerializer.

      This serializer uses KeyGenerator.AS_IS.

      Type Parameters:
      R - the type of the Record
      Returns:
      the default RecordSerializer
    • create

      @NotNull public static <R extends Record> @NotNull RecordSerializer<R> create(@NotNull @NotNull dev.siroshun.serialization.core.key.KeyGenerator keyGenerator)
      Creates a RecordSerializer with the KeyGenerator.

      If specifying KeyGenerator.AS_IS, this method returns serializer().

      Type Parameters:
      R - the type of the Record
      Parameters:
      keyGenerator - the KeyGenerator to generate key name
      Returns:
      the RecordSerializer
    • builder

      @NotNull public static <R extends Record> @NotNull RecordSerializer.Builder<R> builder()
      Type Parameters:
      R - the type of the Record
      Returns:
      a new RecordSerializer.Builder of RecordSerializer
    • serialize

      @NotNull public @NotNull MapNode serialize(@NotNull R input) throws dev.siroshun.serialization.core.SerializationException
      Specified by:
      serialize in interface dev.siroshun.serialization.core.Serializer<R extends Record,MapNode>
      Throws:
      dev.siroshun.serialization.core.SerializationException - if Serializer for the custom objects is not found, etc
    • serializeDefault

      @NotNull public @NotNull MapNode serializeDefault(@NotNull @NotNull Class<? extends R> clazz) throws dev.siroshun.serialization.core.SerializationException
      Creates a default MapNode from the given record class.
      Parameters:
      clazz - the Record to create MapNode
      Returns:
      a default MapNode of the given record class
      Throws:
      dev.siroshun.serialization.core.SerializationException - if Serializer for the custom objects is not found, etc