Class Configuration

java.lang.Object
de.gurkenlabs.litiengine.configuration.Configuration
Direct Known Subclasses:
GameConfiguration

public class Configuration
extends java.lang.Object
  • Constructor Summary

    Constructors 
    ConstructorDescription
    Configuration​(ConfigurationGroup... configurationGroups)
    Initializes a new instance of the Configuration class.
    Configuration​(java.lang.String fileName, ConfigurationGroup... configurationGroups)
    Initializes a new instance of the Configuration class.
  • Method Summary

    Modifier and TypeMethodDescription
    voidadd​(ConfigurationGroup group)
    Adds the specified configuration group to the configuration.
    <T extends ConfigurationGroup>
    T
    getConfigurationGroup​(java.lang.Class<T> groupClass)
    Gets the strongly typed configuration group if it was previously added to the configuration.
    ConfigurationGroupgetConfigurationGroup​(java.lang.String prefix) 
    java.util.List<ConfigurationGroup>getConfigurationGroups()
    Gets all ConfigurationGroups from the configuration.
    java.lang.StringgetFileName()
    Gets the name 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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Configuration

      public Configuration​(ConfigurationGroup... configurationGroups)
      Initializes a new instance of the Configuration class.
      Parameters:
      configurationGroups - The configuration groups managed by this instance.
    • Configuration

      public Configuration​(java.lang.String fileName, ConfigurationGroup... configurationGroups)
      Initializes a new instance of the Configuration class.
      Parameters:
      fileName - The name of the file from which to load the settings.
      configurationGroups - The configuration groups managed by this instance.
  • Method Details

    • getConfigurationGroup

      public <T extends ConfigurationGroup> T getConfigurationGroup​(java.lang.Class<T> groupClass)
      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

      public ConfigurationGroup getConfigurationGroup​(java.lang.String prefix)
    • getConfigurationGroups

      public java.util.List<ConfigurationGroup> getConfigurationGroups()
      Gets all ConfigurationGroups from the configuration.
      Returns:
      All config groups.
    • add

      public void add​(ConfigurationGroup group)
      Adds the specified configuration group to the configuration.
      Parameters:
      group - The group to add.
    • getFileName

      public java.lang.String getFileName()
      Gets the name of the file to which this configuration is saved.
      Returns:
      The name of the configuration file.
      See Also:
      save()
    • load

      public void load()
      Tries to load the configuration from file in the application folder. If none exists, it tires 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:
      getFileName(), DEFAULT_CONFIGURATION_FILE_NAME