Class ConfigManager.Builder<T>

java.lang.Object
net.darkhax.pricklemc.common.api.config.ConfigManager.Builder<T>
Type Parameters:
T - Type of the object being managed.
Enclosing class:
ConfigManager<T>

public static class ConfigManager.Builder<T> extends Object
A builder for ConfigManager objects.
  • Constructor Details

    • Builder

      public Builder(Path filePath)
  • Method Details

    • logger

      public ConfigManager.Builder<T> logger(org.slf4j.Logger logger)
      Sets the logger to use when outputting errors and warnings. If a logger is not set one will be created using the class of the config object.
      Parameters:
      logger - The logger to use for errors and warnings.
      Returns:
      The same builder instance.
    • adapter

      public ConfigManager.Builder<T> adapter(IPropertyAdapter<?> adapter)
      Registers a new property adapter for the config object.
      Parameters:
      adapter - The property adapter to register.
      Returns:
      The same builder instance.
    • gsonBuilder

      public ConfigManager.Builder<T> gsonBuilder(com.google.gson.GsonBuilder builder)
      Overrides the GsonBuilder with a new one. This builder will still be configured using the options from gsonConfig(Consumer).
      Parameters:
      builder - The new GSON builder.
      Returns:
      The same builder instance.
    • gsonConfig

      public ConfigManager.Builder<T> gsonConfig(Consumer<com.google.gson.GsonBuilder> config)
      Registers a consumer that can be used to set up the underlying Gson instance.
      Parameters:
      config - A consumer that accepts the GsonBuilder and configures it.
      Returns:
      The same builder instance.
    • commentResolver

      public ConfigManager.Builder<T> commentResolver(ICommentResolver resolver)
      Sets a new comment resolver that should handle creating comments.
      Parameters:
      resolver - The new comment resolver.
      Returns:
      The same builder instance.
    • build

      public ConfigManager<T> build(T cfgData)
      Builds the config manager.
      Parameters:
      cfgData - The object attach to the config manager. This object will be mapped to a config schema and its properties will be updated as the config is reloaded.
      Returns:
      The newly built config manager.