Class DataConverter<F,T,I,O>

java.lang.Object
me.hsgamer.hscore.serializer.DataConverter<F,T,I,O>
Type Parameters:
F - the type of the raw object
T - the type of the final object
I - the type of the input of the serializer
O - the type of the output of the serializer

public abstract class DataConverter<F,T,I,O> extends Object
The data converter, which converts the raw object to the final object and vice versa
  • Constructor Details

    • DataConverter

      protected DataConverter()
      Create a new data converter
  • Method Details

    • createSerializer

      protected abstract Serializer<I,O> createSerializer()
      Create the serializer
      Returns:
      the serializer
    • convertTo

      protected abstract T convertTo(O data, F from)
      Convert the data
      Parameters:
      data - the data
      from - the object to convert from
      Returns:
      the final object
    • convertFrom

      protected abstract F convertFrom(I data, String type, T to)
      Convert the data
      Parameters:
      data - the data
      type - the type of the data
      to - the final object
      Returns:
      the raw object
    • getOutput

      protected abstract O getOutput(T to)
      Get the output from the final object
      Parameters:
      to - the final object
      Returns:
      the output
    • getInput

      protected abstract I getInput(F from)
      Get the input from the raw object
      Parameters:
      from - the raw object
      Returns:
      the input
    • getType

      protected abstract String getType(F from)
      Get the type of the raw object
      Parameters:
      from - the raw object
      Returns:
      the type
    • deserialize

      public T deserialize(F from)
      Deserialize the raw object
      Parameters:
      from - the raw object
      Returns:
      the final object
    • serialize

      public F serialize(T to)
      Serialize the final object
      Parameters:
      to - the final object
      Returns:
      the raw object
    • getSerializer

      public Serializer<I,O> getSerializer()
      Get the serializer
      Returns:
      the serializer