Package redempt.redlib.config.conversion
Interface StringConverter<T>
- Type Parameters:
T
- The type
- All Superinterfaces:
TypeConverter<T>
A TypeConverter which can convert data directly to and from strings
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> StringConverter<T>
Creates a StringConverter using a loading function and a saving functionfromString
(String str) Converts from a stringdefault T
loadFrom
(DataHolder section, String path, T currentValue) Attemps to load the object from configdefault void
saveTo
(T t, DataHolder section, String path) Attemps to save the object to configConverts to a stringMethods inherited from interface redempt.redlib.config.conversion.TypeConverter
saveTo
-
Method Details
-
create
Creates a StringConverter using a loading function and a saving function- Type Parameters:
T
- The type- Parameters:
loader
- A loading function which can convert from a string to the typesaver
- A saving function which can convert from the type to a string- Returns:
- The created StringConverter
-
fromString
Converts from a string- Parameters:
str
- The string- Returns:
- The resulting object
-
toString
Converts to a string- Parameters:
t
- The object to convert- Returns:
- The string representation
-
loadFrom
Description copied from interface:TypeConverter
Attemps to load the object from config- Specified by:
loadFrom
in interfaceTypeConverter<T>
- Parameters:
section
- The ConfigurationSection to load frompath
- The path to the data in the ConfigurationSectioncurrentValue
- The current value, used for collections and maps- Returns:
-
saveTo
Description copied from interface:TypeConverter
Attemps to save the object to config- Specified by:
saveTo
in interfaceTypeConverter<T>
- Parameters:
t
- The object to savesection
- The ConfigurationSection to save topath
- The path to the data that should be saved in the ConfigurationSection
-