Class AbstractCommentedConfig

java.lang.Object
com.electronwill.nightconfig.core.AbstractConfig
com.electronwill.nightconfig.core.AbstractCommentedConfig
All Implemented Interfaces:
CommentedConfig, Config, UnmodifiableCommentedConfig, UnmodifiableConfig, Cloneable

public abstract class AbstractCommentedConfig extends AbstractConfig implements CommentedConfig
An abstract CommentedConfig backed by two maps: one for the values and one for the comments. The comments of the subconfigs are stored in these subconfigs.
  • Constructor Details

    • AbstractCommentedConfig

      public AbstractCommentedConfig(boolean concurrent)
    • AbstractCommentedConfig

      public AbstractCommentedConfig(Supplier<Map<String,Object>> mapCreator)
    • AbstractCommentedConfig

      public AbstractCommentedConfig(Map<String,Object> valuesMap)
      Creates an AbstractCommentedConfig backed by the specified map
      Parameters:
      valuesMap - the map containing the config's values
    • AbstractCommentedConfig

      public AbstractCommentedConfig(UnmodifiableConfig toCopy, boolean concurrent)
      Creates an AbstractCommentedConfig that is a copy of the specified config.
      Parameters:
      toCopy - the config to copy
    • AbstractCommentedConfig

      public AbstractCommentedConfig(UnmodifiableConfig toCopy, Supplier<Map<String,Object>> mapCreator)
    • AbstractCommentedConfig

      public AbstractCommentedConfig(UnmodifiableCommentedConfig toCopy, boolean concurrent)
      Creates an AbstractCommentedConfig that is a copy of the specified config.
      Parameters:
      toCopy - the config to copy
    • AbstractCommentedConfig

      public AbstractCommentedConfig(UnmodifiableCommentedConfig toCopy, Supplier<Map<String,Object>> mapCreator)
  • Method Details

    • getDefaultCommentMap

      protected static Map<String,String> getDefaultCommentMap(boolean concurrent)
    • getComment

      public String getComment(List<String> path)
      Description copied from interface: UnmodifiableCommentedConfig
      Gets a comment from the config.
      Specified by:
      getComment in interface UnmodifiableCommentedConfig
      Parameters:
      path - the comment's path, each element of the list is a different part of the path.
      Returns:
      the comment at the given path, or null if there is none.
    • setComment

      public String setComment(List<String> path, String comment)
      Description copied from interface: CommentedConfig
      Sets a config comment.
      Specified by:
      setComment in interface CommentedConfig
      Parameters:
      path - the comment's path, each element of the list is a different part of the path.
      comment - the comment to set
      Returns:
      the old comment if any, or null
    • removeComment

      public String removeComment(List<String> path)
      Description copied from interface: CommentedConfig
      Removes a comment from the config.
      Specified by:
      removeComment in interface CommentedConfig
      Parameters:
      path - the comment's path, each element of the list is a different part of the path.
      Returns:
      the old comment if any, or null
    • containsComment

      public boolean containsComment(List<String> path)
      Description copied from interface: UnmodifiableCommentedConfig
      Checks if the config contains a comment at some path.
      Specified by:
      containsComment in interface UnmodifiableCommentedConfig
      Parameters:
      path - the path to check, each element of the list is a different part of the path.
      Returns:
      true if the path is associated with a comment, false if it's not.
    • commentMap

      public Map<String,String> commentMap()
      Description copied from interface: CommentedConfig
      Returns a Map view of the config's comments. Any change to the map is reflected in the config and vice-versa.

      The comment map contains only the comments of the direct elements of the configuration, not the comments of their sub-elements.

      Specified by:
      commentMap in interface CommentedConfig
      Specified by:
      commentMap in interface UnmodifiableCommentedConfig
      Returns:
      a Map view of the config's comments.
    • entrySet

      public Set<? extends CommentedConfig.Entry> entrySet()
      Description copied from interface: Config
      Returns a Set view of the config's entries. Any change to the set or to the entries is reflected in the config, and vice-versa.
      Specified by:
      entrySet in interface CommentedConfig
      Specified by:
      entrySet in interface Config
      Specified by:
      entrySet in interface UnmodifiableCommentedConfig
      Specified by:
      entrySet in interface UnmodifiableConfig
      Overrides:
      entrySet in class AbstractConfig
      Returns:
      a Set view of the config's entries.
    • clone

      public abstract AbstractCommentedConfig clone()
      Description copied from class: AbstractConfig
      Creates and return a copy of this config.
      Specified by:
      clone in class AbstractConfig
      Returns:
      a new config that contains the same entries (including comments) as this config.
    • clear

      public void clear()
      Description copied from interface: Config
      Removes all values from the config.
      Specified by:
      clear in interface Config
      Overrides:
      clear in class AbstractConfig
    • clearComments

      public void clearComments()
      Description copied from interface: CommentedConfig
      Removes all the comments from the config.
      Specified by:
      clearComments in interface CommentedConfig