Package me.hsgamer.hscore.serializer
Class Serializer<I,O,D>
java.lang.Object
me.hsgamer.hscore.serializer.Serializer<I,O,D>
- Type Parameters:
I- the type of the input objectO- the type of the output objectD- the type of the data
The serializer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract IConvert the data to the inputprotected abstract OconvertOut(D data, I input) Convert the data to the outputdeserialize(I input) Deserialize the inputprotected abstract DGet the data from the outputprotected abstract StringGet the type from the inputvoidRegister a new data type, without specifying the type and the data function.voidRegister a new data type, without specifying the type.voidRegister a new data typeSerialize the outputvoidunregister(Class<? extends D> dataClass) Unregister a data typevoidunregister(String type) Unregister a data type
-
Constructor Details
-
Serializer
Create a new serializer- Parameters:
inputClass- the class of the inputoutputClass- the class of the outputdataClass- the class of the data
-
-
Method Details
-
register
Register a new data type- Parameters:
type- the typedataClass- the data classdataFunction- the data function
-
register
Register a new data type, without specifying the type. The type will be the class name, or the value ofSerializerTypeif the class is annotated with it.- Parameters:
dataClass- the data classdataFunction- the data function
-
register
Register a new data type, without specifying the type and the data function. The type will be the class name, or the value ofSerializerTypeif the class is annotated with it. The data function will be the static method annotated withSerializerFunction.- Parameters:
dataClass- the data class- Throws:
IllegalArgumentException- if the data function is not found
-
unregister
Unregister a data type- Parameters:
type- the type
-
unregister
Unregister a data type- Parameters:
dataClass- the data class
-
convertOut
Convert the data to the output- Parameters:
data- the datainput- the input- Returns:
- the output
-
convert
Convert the data to the input- Parameters:
data- the datatype- the typeoutput- the output- Returns:
- the input
-
getData
Get the data from the output- Parameters:
output- the output- Returns:
- the data
-
getType
Get the type from the input- Parameters:
input- the input- Returns:
- the type
-
deserialize
Deserialize the input- Parameters:
input- the input- Returns:
- the output
-
serialize
Serialize the output- Parameters:
to- the output- Returns:
- the input
-