Class SingleInstanceJSONConfig<T>

  • Type Parameters:
    T - Type of object to load

    public class SingleInstanceJSONConfig<T>
    extends java.lang.Object
    SingleInstanceJSONConfig is a tool for loading a JSON file into a Java object
    • Constructor Summary

      Constructors 
      Constructor Description
      SingleInstanceJSONConfig​(java.lang.Class<T> clazz)
      Create a SingleInstanceJSONConfig with default settings
      SingleInstanceJSONConfig​(java.lang.Class<T> clazz, boolean saveToSession)
      Create a SingleInstanceJSONConfig
      SingleInstanceJSONConfig​(java.lang.Class<T> clazz, java.lang.String filename, boolean saveToSession)
      Create a SingleInstanceJSONConfig
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.io.File getBackupFilePath()
      Builds a file path for the config inside session folder
      T getConfig()
      Get an instance of the loaded config, or load the config
      boolean hasLoadedConfig()
      Get if the config has been loaded yet
      • Methods inherited from class java.lang.Object

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

      • SingleInstanceJSONConfig

        public SingleInstanceJSONConfig​(java.lang.Class<T> clazz)
        Create a SingleInstanceJSONConfig with default settings
        Parameters:
        clazz - Class of the config
      • SingleInstanceJSONConfig

        public SingleInstanceJSONConfig​(java.lang.Class<T> clazz,
                                        boolean saveToSession)
        Create a SingleInstanceJSONConfig
        Parameters:
        clazz - Class of the config
        saveToSession - Should save a copy of the config for debugging?
      • SingleInstanceJSONConfig

        public SingleInstanceJSONConfig​(java.lang.Class<T> clazz,
                                        java.lang.String filename,
                                        boolean saveToSession)
        Create a SingleInstanceJSONConfig
        Parameters:
        clazz - Class of the config
        filename - Config JSON filename
        saveToSession - Should save a copy of the config for debugging?
    • Method Detail

      • getBackupFilePath

        protected java.io.File getBackupFilePath()
        Builds a file path for the config inside session folder
        Returns:
        Path to config file backup location
      • getConfig

        public T getConfig()
                    throws java.io.IOException
        Get an instance of the loaded config, or load the config
        Returns:
        Config object
        Throws:
        java.io.IOException - Thrown if there is a read issue
      • hasLoadedConfig

        public boolean hasLoadedConfig()
        Get if the config has been loaded yet
        Returns:
        Has been loaded?