Package me.totalfreedom.config
Interface Configuration
public interface Configuration
Represents a configuration file of any type.
-
Method Summary
Modifier and TypeMethodDescription<T> TGets the value at the given path as the given type.getBoolean(String path) Gets a Boolean object from the associated path.Gets a Double from the associated path.Gets an Integer from the associated path.<T> List<T>Gets a List object from the associated path.Gets a Long from the associated path.<T> TgetOrDefault(String path, T fallback) Gets the value at the given path as the given type.Gets a String object from the associated path.getStringList(String path) Gets a List object from the associated path.voidload()Loads the configuration from the file.voidsave()Saves the configuration to the file.<T> voidSets the value at the given path to the given value.
-
Method Details
-
save
Saves the configuration to the file.- Throws:
IOException- If the operation cannot be completed.
-
load
Loads the configuration from the file.- Throws:
IOException- If the operation cannot be completed.
-
getFileName
String getFileName()- Returns:
- The name of the file.
-
getConfigurationFile
File getConfigurationFile()- Returns:
- The actual Configuration
File.
-
getString
Gets a String object from the associated path.- Parameters:
path- The path to get the String from.- Returns:
- The String object.
-
getBoolean
Gets a Boolean object from the associated path.- Parameters:
path- The path to get the Boolean from.- Returns:
- The Boolean object.
-
getList
Gets a List object from the associated path. This method will useContexts and theContextProviderto get the object types in the list. If the objects cannot be inferred, the method will return a list of genericObjects.- Type Parameters:
T- The type of the objects in the list.- Parameters:
path- The path to get the List from.- Returns:
- The List object.
-
getStringList
Gets a List object from the associated path. The List that is returned will be the String values which are stored within the configuration file at the given path.- Parameters:
path- The path to get the List from.- Returns:
- The List object.
-
getInt
Gets an Integer from the associated path.- Parameters:
path- The path to get the Integer from.- Returns:
- The Integer object.
-
getLong
Gets a Long from the associated path.- Parameters:
path- The path to get the Long from.- Returns:
- The Long object.
-
getDouble
Gets a Double from the associated path.- Parameters:
path- The path to get the Double from.- Returns:
- The Double object.
-
set
Sets the value at the given path to the given value.- Type Parameters:
T- The type of the value.- Parameters:
path- The path to set the value at.value- The value to set.
-
get
Gets the value at the given path as the given type.This method will use
Contexts and theContextProviderto get the object type. If the object type cannot be inferred, the method will return a genericObject.- Type Parameters:
T- The type of the value.- Parameters:
path- The path to get the value from.- Returns:
- The value at the given path.
-
getOrDefault
Gets the value at the given path as the given type.This method will use
Contexts and theContextProviderto get the object type. If the object type cannot be inferred, the method will return the given fallback value.- Type Parameters:
T- The type of the value.- Parameters:
path- The path to get the value from.fallback- The fallback value to return if the value at the given path is null.- Returns:
- The value at the given path.
-