Class Adapter<Type,Output>
java.lang.Object
org.polyfrost.oneconfig.api.config.v1.serialize.adapter.Adapter<Type,Output>
- Type Parameters:
Type- the type of this adapterOutput- the output type of this adapter used to avoid unsafe casts for prettier code
- Direct Known Subclasses:
ColorAdapter,ComplexAdapter
The Config API is equipped with an automatic deserializer (see
It is not perfect and may produce ugly looking results
For this reason the Adapter API exists where you can create your own custom serializer for an object into a map of "simple" objects and string keys
ObjectSerializer.serialize(Object, boolean))
It is not perfect and may produce ugly looking results
For this reason the Adapter API exists where you can create your own custom serializer for an object into a map of "simple" objects and string keys
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Typedeserialize(Output in) Deserialize your object
The form will be identical to what you made in theserialize(Object)methodfinal booleanDue to Java type erasure this method is used to get the type of the adapter
This is used internally to get what type adapter to useDue to Java type erasure this method is used to get the type of the adapter
This is used internally to get what type adapter to usefinal inthashCode()abstract OutputConvert the given object into a serializable form
The following types can be returned by this method and nothing more Primitive wrappers (anyNumberorCharacterorBoolean) AStringliteral or any class implementingCharSequenceAnEnumAn array of the above types including primitives such asbyte[]andint[]AListof the above types AMap<String,Object>of the above types mapped to Strings which are used as keys
Note that 'class' and 'value' are reserved keys and cannot be used Lists containing lists or maps containing maps (or lists) are also supported
-
Constructor Details
-
Adapter
public Adapter()
-
-
Method Details
-
deserialize
Deserialize your object
The form will be identical to what you made in theserialize(Object)method- Parameters:
in- the object (same as deserialize) to create your object from- Returns:
- the complete object
-
serialize
Convert the given object into a serializable form
The following types can be returned by this method and nothing more- Primitive wrappers (any
NumberorCharacterorBoolean) - A
Stringliteral or any class implementingCharSequence - An
Enum - An array of the above types including primitives such as
byte[]andint[] - A
Listof the above types - A
Map<String,Object>of the above types mapped to Strings which are used as keys
Note that 'class' and 'value' are reserved keys and cannot be used - Lists containing lists or maps containing maps (or lists) are also supported
- Parameters:
in- the object to serialize
- Primitive wrappers (any
-
getTargetClass
Due to Java type erasure this method is used to get the type of the adapter
This is used internally to get what type adapter to use -
getOutputClass
Due to Java type erasure this method is used to get the type of the adapter
This is used internally to get what type adapter to use -
equals
-
hashCode
public final int hashCode()
-