Interface Configuration


public interface Configuration
Represents a configuration file of any type.
  • Method Details

    • save

      void save() throws IOException
      Saves the configuration to the file.
      Throws:
      IOException - If the operation cannot be completed.
    • load

      void load() throws IOException
      Loads the configuration from the file.
      Throws:
      IOException - If the operation cannot be completed.
    • getFileName

      String getFileName()
      Returns:
      The name of the file.
    • getConfigurationFile

      File getConfigurationFile()
      Returns:
      The actual Configuration File.
    • getString

      String getString(String path)
      Gets a String object from the associated path.
      Parameters:
      path - The path to get the String from.
      Returns:
      The String object.
    • getBoolean

      Boolean getBoolean(String path)
      Gets a Boolean object from the associated path.
      Parameters:
      path - The path to get the Boolean from.
      Returns:
      The Boolean object.
    • getList

      <T> List<T> getList(String path)
      Gets a List object from the associated path. This method will use Contexts and the ContextProvider to get the object types in the list. If the objects cannot be inferred, the method will return a list of generic Objects.
      Type Parameters:
      T - The type of the objects in the list.
      Parameters:
      path - The path to get the List from.
      Returns:
      The List object.
    • getStringList

      List<String> getStringList(String path)
      Gets a List object from the associated path. The List that is returned will be the String values which are stored within the configuration file at the given path.
      Parameters:
      path - The path to get the List from.
      Returns:
      The List object.
    • getInt

      Integer getInt(String path)
      Gets an Integer from the associated path.
      Parameters:
      path - The path to get the Integer from.
      Returns:
      The Integer object.
    • getLong

      Long getLong(String path)
      Gets a Long from the associated path.
      Parameters:
      path - The path to get the Long from.
      Returns:
      The Long object.
    • getDouble

      Double getDouble(String path)
      Gets a Double from the associated path.
      Parameters:
      path - The path to get the Double from.
      Returns:
      The Double object.
    • set

      <T> void set(String path, T value)
      Sets the value at the given path to the given value.
      Type Parameters:
      T - The type of the value.
      Parameters:
      path - The path to set the value at.
      value - The value to set.
    • get

      <T> T get(String path)
      Gets the value at the given path as the given type.

      This method will use Contexts and the ContextProvider to get the object type. If the object type cannot be inferred, the method will return a generic Object.

      Type Parameters:
      T - The type of the value.
      Parameters:
      path - The path to get the value from.
      Returns:
      The value at the given path.
    • getOrDefault

      <T> T getOrDefault(String path, T fallback)
      Gets the value at the given path as the given type.

      This method will use Contexts and the ContextProvider to get the object type. If the object type cannot be inferred, the method will return the given fallback value.

      Type Parameters:
      T - The type of the value.
      Parameters:
      path - The path to get the value from.
      fallback - The fallback value to return if the value at the given path is null.
      Returns:
      The value at the given path.