Class Container<C>

java.lang.Object
com.thewinterframework.configurate.Container<C>
Type Parameters:
C - the type of the configuration object

public final class Container<C> extends Object
A container for a configuration file.
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Gets the configuration object.
    org.spongepowered.configurate.ConfigurationNode
    Gets the configuration node.
    static <C> Container<C>
    load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file)
    Loads a configuration file.
    static <C> Container<C>
    load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file, Class<?> clazzLoader)
    Loads a configuration file.
    static <C> Container<C>
    load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file, UnaryOperator<org.spongepowered.configurate.ConfigurationOptions> options)
    Loads a configuration file.
    static org.spongepowered.configurate.ConfigurationNode
    loadNode(Class<?> clazz, org.slf4j.Logger logger, Path path, String file, UnaryOperator<org.spongepowered.configurate.ConfigurationOptions> options)
    Loads a configuration node.
    boolean
    Reloads the configuration file.
    boolean
    Saves the current configuration to the file.
    boolean
    Updates the configuration object using the provided updater function.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • reload

      public boolean reload()
      Reloads the configuration file.
      Returns:
      true if the save was successful, false otherwise
    • get

      @NotNull public C get()
      Gets the configuration object.
    • getNode

      public org.spongepowered.configurate.ConfigurationNode getNode()
      Gets the configuration node.
      Returns:
      the configuration node
    • update

      public boolean update(UnaryOperator<C> updater)
      Updates the configuration object using the provided updater function.
      Parameters:
      updater - the function to apply to the current config
      Returns:
      true if the update and save were successful, false otherwise
    • save

      public boolean save()
      Saves the current configuration to the file.
      Returns:
      true if the save was successful, false otherwise
    • load

      public static <C> Container<C> load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file, UnaryOperator<org.spongepowered.configurate.ConfigurationOptions> options) throws IOException
      Loads a configuration file.
      Type Parameters:
      C - the type of the configuration object
      Parameters:
      logger - the logger
      path - the path to the configuration file
      clazz - the class of the configuration object
      file - the name of the configuration file
      options - the configuration options
      Returns:
      the container
      Throws:
      IOException - if an I/O error occurs
    • loadNode

      public static org.spongepowered.configurate.ConfigurationNode loadNode(Class<?> clazz, org.slf4j.Logger logger, Path path, String file, UnaryOperator<org.spongepowered.configurate.ConfigurationOptions> options) throws IOException
      Loads a configuration node.
      Parameters:
      logger - the logger
      path - the path to the configuration file
      file - the name of the configuration file
      options - the configuration options
      Returns:
      the configuration node
      Throws:
      IOException - if an I/O error occurs
    • load

      public static <C> Container<C> load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file) throws IOException
      Loads a configuration file.
      Type Parameters:
      C - the type of the configuration object
      Parameters:
      logger - the logger
      path - the path to the configuration file
      clazz - the class of the configuration object
      file - the name of the configuration file
      Returns:
      the container
      Throws:
      IOException - if an I/O error occurs
    • load

      public static <C> Container<C> load(org.slf4j.Logger logger, Path path, Class<C> clazz, String file, Class<?> clazzLoader) throws IOException
      Loads a configuration file.
      Type Parameters:
      C - the type of the configuration object
      Parameters:
      logger - the logger
      path - the path to the configuration file
      clazz - the class of the configuration object
      file - the name of the configuration file
      clazzLoader - the class loader
      Returns:
      the container
      Throws:
      IOException