Class BaseConfigPath<T>

java.lang.Object
me.hsgamer.hscore.config.path.BaseConfigPath<T>
Type Parameters:
T - the type of the value
All Implemented Interfaces:
ConfigPath<T>
Direct Known Subclasses:
BooleanConfigPath, DoubleConfigPath, FloatConfigPath, IntegerConfigPath, LongConfigPath, SimpleConfigPath, StringConfigPath

public class BaseConfigPath<T> extends Object implements ConfigPath<T>
A simple config path
  • Constructor Details

    • BaseConfigPath

      public BaseConfigPath(@NotNull @NotNull String path, @Nullable T def, @NotNull @NotNull Function<Object,T> typeConverter)
      Create a config path
      Parameters:
      path - the path to the value
      def - the default value if it's not found
      typeConverter - how to convert the raw object to the needed type of value
  • Method Details

    • getValue

      public T getValue()
      Description copied from interface: ConfigPath
      Get the value
      Specified by:
      getValue in interface ConfigPath<T>
      Returns:
      the value
    • setValue

      public void setValue(@Nullable T value)
      Description copied from interface: ConfigPath
      Set the value
      Specified by:
      setValue in interface ConfigPath<T>
      Parameters:
      value - the value
    • getValue

      public T getValue(@NotNull @NotNull Config config)
      Description copied from interface: ConfigPath
      Get the value from the config. This is used to get the value from multiple configs.
      Specified by:
      getValue in interface ConfigPath<T>
      Parameters:
      config - the config
      Returns:
      the value
    • setValue

      public void setValue(@Nullable T value, @NotNull @NotNull Config config)
      Description copied from interface: ConfigPath
      Set the value to the config. This is used to set the value to multiple configs.
      Specified by:
      setValue in interface ConfigPath<T>
      Parameters:
      value - the value
      config - the config
    • getPath

      @NotNull public @NotNull String getPath()
      Description copied from interface: ConfigPath
      Get the path to the value
      Specified by:
      getPath in interface ConfigPath<T>
      Returns:
      the path
    • getConfig

      @Nullable public @Nullable Config getConfig()
      Description copied from interface: ConfigPath
      Get the config
      Specified by:
      getConfig in interface ConfigPath<T>
      Returns:
      the config
    • setConfig

      public void setConfig(@NotNull @NotNull Config config)
      Description copied from interface: ConfigPath
      Set the config.
      Specified by:
      setConfig in interface ConfigPath<T>
      Parameters:
      config - the config
    • migrateConfig

      public void migrateConfig(@NotNull @NotNull Config config)
      Description copied from interface: ConfigPath
      Manually update the config (Mainly used when updating new settings)
      Specified by:
      migrateConfig in interface ConfigPath<T>
      Parameters:
      config - the config