Class DecorativeConfig

java.lang.Object
me.hsgamer.hscore.config.DecorativeConfig
All Implemented Interfaces:
Config
Direct Known Subclasses:
AnnotatedConfig

public abstract class DecorativeConfig extends Object implements Config
A decorative Config for extending more features on the existing Config
  • Field Details

    • config

      protected final Config config
  • Constructor Details

    • DecorativeConfig

      protected DecorativeConfig(Config config)
      Create a new decorative config
      Parameters:
      config - the original config
  • Method Details

    • getOriginalConfig

      public Config getOriginalConfig()
      Get the original config
      Returns:
      the config
    • getOriginal

      public Object getOriginal()
      Description copied from interface: Config
      Get the original instance
      Specified by:
      getOriginal in interface Config
      Returns:
      the original instance
    • get

      public Object get(Object def, String... path)
      Description copied from interface: Config
      Get the value from the path
      Specified by:
      get in interface Config
      Parameters:
      def - the default value if the value is not found
      path - the path
      Returns:
      the value
    • set

      public void set(Object value, String... path)
      Description copied from interface: Config
      Set the value to the path
      Specified by:
      set in interface Config
      Parameters:
      value - the value
      path - the path
    • contains

      public boolean contains(String... path)
      Description copied from interface: Config
      Check if the configuration contains the path
      Specified by:
      contains in interface Config
      Parameters:
      path - the path
      Returns:
      true if it does
    • getName

      public String getName()
      Description copied from interface: Config
      Get the name of the configuration
      Specified by:
      getName in interface Config
      Returns:
      the name
    • getValues

      public Map<String[],Object> getValues(boolean deep, String... path)
      Description copied from interface: Config
      Get all values from the path
      Specified by:
      getValues in interface Config
      Parameters:
      deep - should we go deeper from the path?
      path - the path
      Returns:
      the values
    • setup

      public void setup()
      Description copied from interface: Config
      Set up the configuration
      Specified by:
      setup in interface Config
    • save

      public void save()
      Description copied from interface: Config
      Save the configuration
      Specified by:
      save in interface Config
    • reload

      public void reload()
      Description copied from interface: Config
      Reload the configuration
      Specified by:
      reload in interface Config
    • normalize

      public Object normalize(Object object)
      Description copied from interface: Config
      Normalize the library-specific object
      Specified by:
      normalize in interface Config
      Parameters:
      object - the object
      Returns:
      the normalized object
    • isNormalizable

      public boolean isNormalizable(Object object)
      Description copied from interface: Config
      Check if the object is normalizable
      Specified by:
      isNormalizable in interface Config
      Parameters:
      object - the object
      Returns:
      true if it is
    • remove

      public void remove(String... path)
      Description copied from interface: Config
      Remove the path from the configuration
      Specified by:
      remove in interface Config
      Parameters:
      path - the path
    • clear

      public void clear()
      Description copied from interface: Config
      Remove all paths from the configuration
      Specified by:
      clear in interface Config
    • get

      public Object get(String... path)
      Description copied from interface: Config
      Get the value from the path
      Specified by:
      get in interface Config
      Parameters:
      path - the path
      Returns:
      the value
    • getNormalized

      public Object getNormalized(Object def, String... path)
      Description copied from interface: Config
      Get the normalized value from the path
      Specified by:
      getNormalized in interface Config
      Parameters:
      def - the default value the default value if the value is not found
      path - the path
      Returns:
      the value
    • getNormalized

      public Object getNormalized(String... path)
      Description copied from interface: Config
      Get the normalized value from the path
      Specified by:
      getNormalized in interface Config
      Parameters:
      path - the path
      Returns:
      the value
    • getInstance

      public <T> T getInstance(Class<T> type, T def, String... path)
      Description copied from interface: Config
      Get the value from the path
      Specified by:
      getInstance in interface Config
      Type Parameters:
      T - the type of the value
      Parameters:
      type - the type class of the value
      def - the default value if the value is not found
      path - the path
      Returns:
      the value
    • getInstance

      public <T> T getInstance(Class<T> type, String... path)
      Description copied from interface: Config
      Get the value from the path
      Specified by:
      getInstance in interface Config
      Type Parameters:
      T - the type of the value
      Parameters:
      type - the type class of the value
      path - the path
      Returns:
      the value
    • isInstance

      public boolean isInstance(Class<?> type, String... path)
      Description copied from interface: Config
      Check if the value of the path matches the type
      Specified by:
      isInstance in interface Config
      Parameters:
      type - the type class of the value
      path - the path
      Returns:
      true if it does
    • getKeys

      public Set<String[]> getKeys(boolean deep, String... path)
      Description copied from interface: Config
      Get all keys from the path
      Specified by:
      getKeys in interface Config
      Parameters:
      deep - should we go deeper from the path?
      path - the path
      Returns:
      the keys
    • getNormalizedValues

      public Map<String[],Object> getNormalizedValues(boolean deep, String... path)
      Description copied from interface: Config
      Get all normalized values from the path
      Specified by:
      getNormalizedValues in interface Config
      Parameters:
      deep - should we go deeper from the path?
      path - the path
      Returns:
      the values
    • normalizeObject

      public Object normalizeObject(Object object)
      Description copied from interface: Config
      Normalize the object and its elements if it is a map or a collection
      Specified by:
      normalizeObject in interface Config
      Parameters:
      object - the object
      Returns:
      the normalized object
    • setIfAbsent

      public void setIfAbsent(Object value, String... path)
      Description copied from interface: Config
      Set the value to the path if it is not already set
      Specified by:
      setIfAbsent in interface Config
      Parameters:
      value - the value
      path - the path
    • setIfAbsent

      public void setIfAbsent(Map<String[],Object> map)
      Description copied from interface: Config
      Set the values to the path if they are not already set
      Specified by:
      setIfAbsent in interface Config
      Parameters:
      map - the map of values
    • getComment

      public List<String> getComment(CommentType type, String... path)
      Description copied from interface: Config
      Get the comment. This is a default empty method. The implementation can override this method to support comments.
      Specified by:
      getComment in interface Config
      Parameters:
      type - the comment type
      path - the path
      Returns:
      the comment
    • setComment

      public void setComment(CommentType type, List<String> value, String... path)
      Description copied from interface: Config
      Set the comment This is a default empty method. The implementation can override this method to support comments.
      Specified by:
      setComment in interface Config
      Parameters:
      type - the comment type
      value - the comment, can be null to remove the comment
      path - the path
    • getComment

      public List<String> getComment(String... path)
      Description copied from interface: Config
      Get the block comment
      Specified by:
      getComment in interface Config
      Parameters:
      path - the path
      Returns:
      the comment
      See Also:
    • setComment

      public void setComment(List<String> value, String... path)
      Description copied from interface: Config
      Set the block comment
      Specified by:
      setComment in interface Config
      Parameters:
      value - the comment, can be null to remove the comment
      path - the path
      See Also: