Interface SimpleSerializer<T>

Type Parameters:
T - The type of object to parse.
All Superinterfaces:
Serializer<T>
All Known Implementing Classes:
ChanceSerializer, ColorSerializer

public interface SimpleSerializer<T> extends Serializer<T>
A serializer that can parse objects from strings. The serializer is "simple" because the string is expected in a human-readable format. This means no JSON, XML, or other complex formats. A value more like "DIRT" or "5" is expected.

This is a type of Serializer, but it only works on strings.

  • Method Details

    • getTypeName

      @NotNull @NotNull String getTypeName()
      The name of the type of the serializer. This is used for error messages.
    • deserialize

      @NotNull T deserialize(@NotNull @NotNull String data, @NotNull @NotNull String errorLocation) throws me.deecaad.core.file.SerializerException
      Parses an object from a string.
      Parameters:
      data - The string to parse.
      errorLocation - The location of the error in the file.
      Returns:
      The parsed object.
      Throws:
      me.deecaad.core.file.SerializerException
    • examples

      @NotNull @NotNull List<String> examples()
      Returns the set of all possible values that can be parsed by this serializer.

      The set of values will always be finite. Thus, any type that can take on an infinite number of values (like a double) will return a finite set of example values.

      Returns:
      The set of all possible values that can be parsed by this serializer.
    • serialize

      @NotNull default T serialize(@NotNull @NotNull me.deecaad.core.file.SerializeData data) throws me.deecaad.core.file.SerializerException
      Description copied from interface: Serializer
      Instantiates a new Object to be added into the finalized configuration. The object should be built off of SerializeData.getConfig(). If there is any misconfiguration (or any other issue preventing the construction of an object), then this method should throw a SerializerException. This method may not return null.
      Specified by:
      serialize in interface Serializer<T>
      Parameters:
      data - The non-null data containing config
      Returns:
      The non-null serialized data.
      Throws:
      me.deecaad.core.file.SerializerException - If there is an error in config.