Class ConfigLoader

java.lang.Object
dev.selena.luacore.utils.config.ConfigLoader

public class ConfigLoader extends Object
Config loader used to load and save json config files
  • Constructor Details

    • ConfigLoader

      public ConfigLoader()
  • Method Details

    • loadConfig

      Loads a provided config object from a given JSON file. If the file does not exist it also creates the file using the given object defaults
      Type Parameters:
      T - The class type you want to map to
      Parameters:
      cls - The object type you wish to load, also dictates the class of the returned object
      file - The file that is to be created/read from
      Returns:
      The object loaded from file
      Throws:
      IOException - Thrown when the file can not be found
      InstantiationException - Throwing when the class has an initialization issue
      IllegalAccessException - Thrown when trying to access a field without the correct access level
      InvocationTargetException - Thrown when the mapper class has a constructor that does not match the arguments (There should be none)
      NoSuchMethodException - Thrown when the class somehow manages not to have a constructor
    • saveConfig

      public static void saveConfig(Object config, File file) throws IOException
      Saves a config object to the specified file in JSON format
      Parameters:
      config - The object to be saved
      file - The file to which the object is saved
      Throws:
      IOException - Thrown when the file has some issue saving