Class RecordDeserializer<R extends Record>

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

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

    • create

      @Contract("_ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer<R> create(@NotNull @NotNull Class<? extends R> recordClass)
      Creates RecordDeserializer of the specified Record class.
      Type Parameters:
      R - the type of the Record
      Parameters:
      recordClass - the class of the Record
      Returns:
      RecordDeserializer of the specified Record class
    • create

      @Contract("_, _ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer<R> create(@NotNull @NotNull Class<? extends R> recordClass, @NotNull @NotNull dev.siroshun.serialization.core.key.KeyGenerator keyGenerator)
      Creates RecordDeserializer of the specified Record class.
      Type Parameters:
      R - the type of the Record
      Parameters:
      recordClass - the class of the Record
      keyGenerator - the KeyGenerator to generate keys from field names
      Returns:
      RecordDeserializer of the specified Record class
    • create

      @Contract("_ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer<R> create(@NotNull R defaultRecord)
      Creates RecordDeserializer with the default record.
      Type Parameters:
      R - the type of the Record
      Parameters:
      defaultRecord - the default Record to get the default value if the value is not found in the MapNode
      Returns:
      RecordDeserializer of the specified Record class
    • create

      @Contract("_, _ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer<R> create(@NotNull R defaultRecord, @NotNull @NotNull dev.siroshun.serialization.core.key.KeyGenerator keyGenerator)
      Creates RecordDeserializer with the default record.
      Type Parameters:
      R - the type of the Record
      Parameters:
      defaultRecord - the default Record to get the default value if the value is not found in the MapNode
      keyGenerator - the KeyGenerator to generate keys from field names
      Returns:
      RecordDeserializer of the specified Record class
    • builder

      @Contract("_ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer.Builder<R> builder(@NotNull @NotNull Class<? extends R> recordClass)
      Creates a new RecordDeserializer.Builder of the specified Record class.
      Type Parameters:
      R - the type of the Record
      Parameters:
      recordClass - the class of the Record
      Returns:
      RecordDeserializer.Builder of the specified Record class
    • builder

      @Contract("_ -> new") @NotNull public static <R extends Record> @NotNull RecordDeserializer.Builder<R> builder(@NotNull R defaultRecord)
      Creates a new RecordDeserializer.Builder with the default record.
      Type Parameters:
      R - the type of the Record
      Parameters:
      defaultRecord - the default Record to get the default value if the value is not found in the MapNode
      Returns:
      RecordDeserializer.Builder of the specified Record class
    • deserialize

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