Class Configuration
- Direct Known Subclasses:
GameConfiguration
public class Configuration
Configuration class that manages multiple configuration groups and handles loading and saving settings.
-
Constructor Summary
ConstructorsConstructorDescriptionConfiguration(ConfigurationGroup... configurationGroups) Initializes a new instance of theConfigurationclass.Configuration(String path, ConfigurationGroup... configurationGroups) Constructs a new instance of theConfigurationclass using the specified file name.Configuration(Path path, ConfigurationGroup... configurationGroups) Initializes a new instance of theConfigurationclass. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(ConfigurationGroup group) Adds the specified configuration group to the configuration.<T extends ConfigurationGroup>
TgetConfigurationGroup(Class<T> groupClass) Gets the strongly typed configuration group if it was previously added to the configuration.getConfigurationGroup(String prefix) Gets the configuration group with the specified prefix.Gets allConfigurationGroupsfrom the configuration.getPath()Gets the path of the file to which this configuration is saved.voidload()Tries to load the configuration from file in the application folder.voidsave()Saves this configuration to a file with the specified name of this instance (config.properties is the engines default config file).
-
Constructor Details
-
Configuration
Initializes a new instance of theConfigurationclass.- Parameters:
configurationGroups- The configuration groups managed by this instance.
-
Configuration
Constructs a new instance of theConfigurationclass using the specified file name. This constructor converts the provided file name string into aPathobject and delegates the initialization to another constructor.- Parameters:
path- The path of the file from which to load the settings.configurationGroups- The configuration groups managed by this instance.
-
Configuration
Initializes a new instance of theConfigurationclass.- Parameters:
path- The path of the file from which to load the settings.configurationGroups- The configuration groups managed by this instance.
-
-
Method Details
-
getConfigurationGroup
Gets the strongly typed configuration group if it was previously added to the configuration.- Type Parameters:
T- The type of the config group.- Parameters:
groupClass- The class that provides the generic type for this method.- Returns:
- The configuration group of the specified type or null if none can be found.
-
getConfigurationGroup
Gets the configuration group with the specified prefix.- Parameters:
prefix- The prefix of the configuration group to retrieve.- Returns:
- The configuration group with the specified prefix, or null if none can be found.
-
getConfigurationGroups
Gets allConfigurationGroupsfrom the configuration.- Returns:
- All config groups.
-
add
Adds the specified configuration group to the configuration.- Parameters:
group- The group to add.
-
getPath
Gets the path of the file to which this configuration is saved.- Returns:
- The path of the configuration file.
- See Also:
-
load
public void load()Tries to load the configuration from file in the application folder. If none exists, it tries to load the file from any resource folder. If none exists, it creates a new configuration file in the application folder. -
save
public void save()Saves this configuration to a file with the specified name of this instance (config.properties is the engines default config file).- See Also:
-