Package 

Class ConfigHandler

  • All Implemented Interfaces:

    
    public class ConfigHandler<Config>
    
                        

    Config handler for easy managing of config files with the json format.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

      • ConfigHandler

        ConfigHandler(Config defaultConfig, String path)
        Create a config handler.
        Parameters:
        defaultConfig - The default config.
        path - The path to the file with the file name and extension.
      • ConfigHandler

        ConfigHandler(Config defaultConfig, String path, Boolean writeDefaultConfigAutomatically)
        Create a config handler.
        Parameters:
        defaultConfig - The default config.
        path - The path to the file with the file name and extension.
        writeDefaultConfigAutomatically - If true the default config will be written automatically if no config exists.
    • Method Detail

      • getFile

         File getFile()

        Get the config file as an File object.

      • checkIfExists

         boolean checkIfExists()

        Check if the config file is already existing.

      • delete

         boolean delete()

        Delete the file.

      • saveDefaultConfig

         void saveDefaultConfig()

        Save the default config in the config file. WARNING: this also overrides normal configs. You should check before this if the config exists.

      • storeConfig

         void storeConfig(Config config)

        Save the config object as an JSON string in the config file.

        Parameters:
        config - Config object to save.
      • getUserConfigFolder

         static String getUserConfigFolder()

        Get an path to an folder where you can store user configurations. This function is OS optimized for Windows, Linux and Mac.

      • getUserConfigFolder

         static String getUserConfigFolder(String projectName)

        Get an path to an folder where you can store user configurations. This function is OS optimized for Windows, Linux and Mac.

        Parameters:
        projectName - The project name.
      • getSystemConfigFolder

         static String getSystemConfigFolder(String projectName)

        Get an path to an folder where you can store system wide configurations. This function is OS optimized for Windows, Linux and Mac.

        Parameters:
        projectName - The project name.