Class ScriptSettings


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

      Constructors 
      Constructor Description
      ScriptSettings()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> boolean exists​(@Nullable java.lang.Class<T> clazz, java.lang.String... fileLocationSteps)
      Checks if a saved file exists at the provided file location steps and (if provided) checks if it can be loaded as the provided class
      static <T> T load​(java.lang.Class<T> clazz, java.lang.String... fileLocationSteps)
      Loads a given class from a settings object, location base is scripts.path
      static boolean save​(java.lang.Object obj, java.lang.String... fileLocationSteps)
      Saves a given object using GSON pretty print to the given file.
      • Methods inherited from class java.lang.Object

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

      • ScriptSettings

        public ScriptSettings()
    • Method Detail

      • load

        public static <T> T load​(java.lang.Class<T> clazz,
                                 java.lang.String... fileLocationSteps)
        Loads a given class from a settings object, location base is scripts.path
        Parameters:
        clazz - Class of the object you're loading, must have empty constructor
        fileLocationSteps - Steps in the file location, eg: "MyScript","SubFolder","MySettings.json"
        Returns:
        A new instance of your object created from the file settings
      • save

        public static boolean save​(java.lang.Object obj,
                                   java.lang.String... fileLocationSteps)
        Saves a given object using GSON pretty print to the given file.
        Parameters:
        obj - Object instance to save.
        fileLocationSteps - Steps in the file location, eg: "MyScript","SubFolder","MySettings.json"
        Returns:
        true if it saves with no exceptions, false if it fails to create folders or throws exceptions
      • exists

        public static <T> boolean exists​(@Nullable java.lang.Class<T> clazz,
                                         java.lang.String... fileLocationSteps)
        Checks if a saved file exists at the provided file location steps and (if provided) checks if it can be loaded as the provided class
        Parameters:
        clazz - Class of the object you want to check exists, if null this method will only check if a file exists at the given location
        fileLocationSteps - Steps in the file location, eg: "MyScript","SubFolder","MySettings.json"
        Returns:
        true if the file exists and can be loaded as the class (if provided), false otherwise