Package me.deecaad.core.file
Interface SimpleSerializer<T>
- Type Parameters:
T- The type of object to parse.
- All Superinterfaces:
Serializer<T>
- All Known Implementing Classes:
ChanceSerializer,ColorSerializer
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 Summary
Modifier and TypeMethodDescriptiondeserialize(@NotNull String data, @NotNull String errorLocation) Parses an object from a string.examples()Returns the set of all possible values that can be parsed by this serializer.@NotNull StringThe name of the type of the serializer.default Tserialize(@NotNull me.deecaad.core.file.SerializeData data) Instantiates a new Object to be added into the finalized configuration.Methods inherited from interface me.deecaad.core.file.Serializer
canUsePathTo, getKeyword, getName, getParentKeywords, getWikiLink, letPassThrough, shouldSerialize, tryPathTo, useLater
-
Method Details
-
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
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:SerializerInstantiates a new Object to be added into the finalized configuration. The object should be built off ofSerializeData.getConfig(). If there is any misconfiguration (or any other issue preventing the construction of an object), then this method should throw aSerializerException. This method may not return null.- Specified by:
serializein interfaceSerializer<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.
-