Interface CommentedConfig

All Superinterfaces:
Config, UnmodifiableCommentedConfig, UnmodifiableConfig
All Known Subinterfaces:
CommentedFileConfig
All Known Implementing Classes:
AbstractCommentedConfig, CommentedConfigWrapper, ConvertedCommentedConfig, ConvertedCommentedFileConfig, FakeCommentedConfig

public interface CommentedConfig extends UnmodifiableCommentedConfig, Config
A modifiable config that supports comments.
  • Method Details

    • setComment

      default String setComment(String path, String comment)
      Sets a config comment.
      Parameters:
      path - the comment's path, each part separated by a dot. Example "a.b.c"
      comment - the comment to set
      Returns:
      the old comment if any, or null
    • setComment

      String setComment(List<String> path, String comment)
      Sets a config comment.
      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

      default String removeComment(String path)
      Removes a comment from the config.
      Parameters:
      path - the comment's path, each part separated by a dot. Example "a.b.c"
      Returns:
      the old comment if any, or null
    • removeComment

      String removeComment(List<String> path)
      Removes a comment from the config.
      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
    • clearComments

      void clearComments()
      Removes all the comments from the config.
    • putAllComments

      default void putAllComments(Map<String,UnmodifiableCommentedConfig.CommentNode> comments)
      Puts the comments in the given map to this config. Existing comments are replaced, missing comments are created.
      Parameters:
      comments - the comments to set
    • putAllComments

      default void putAllComments(UnmodifiableCommentedConfig commentedConfig)
      Puts the comments in the given config to this config. Existing comments are replaced, missing comments are created.
      Parameters:
      commentedConfig - the config to copy its comments
    • unmodifiable

      default UnmodifiableCommentedConfig unmodifiable()
      Description copied from interface: Config
      Returns an Unmodifiable view of the config. Any change to the original (modifiable) config is still reflected to the returned UnmodifiableConfig, so it's unmodifiable but not immutable.
      Specified by:
      unmodifiable in interface Config
      Returns:
      an Unmodifiable view of the config.
    • checked

      default CommentedConfig checked()
      Description copied from interface: Config
      Returns a checked view of the config. It checks that all the values put into the config are supported by the config's format (as per the ConfigFormat.supportsType(Class) method. Trying to insert an unsupported value throws an IllegalArgumentException.

      The values that are in the config when this method is called are also checked.

      Specified by:
      checked in interface Config
      Returns:
      a checked view of the config.
    • commentMap

      Map<String,String> commentMap()
      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 UnmodifiableCommentedConfig
      Returns:
      a Map view of the config's comments.
    • entrySet

      Set<? extends CommentedConfig.Entry> entrySet()
      Description copied from interface: UnmodifiableConfig
      Returns a Set view of the config's entries. If the config is unmodifiable then the returned set is unmodifiable too.
      Specified by:
      entrySet in interface Config
      Specified by:
      entrySet in interface UnmodifiableCommentedConfig
      Specified by:
      entrySet in interface UnmodifiableConfig
      Returns:
      a Set view of the config's entries.
    • createSubConfig

      CommentedConfig createSubConfig()
      Description copied from interface: Config
      Creates a new sub config of this config, as created when a subconfig's creation is implied by Config.set(List, Object) or Config.add(List, Object).
      Specified by:
      createSubConfig in interface Config
      Returns:
      a new sub config
    • of

      static CommentedConfig of(ConfigFormat<? extends CommentedConfig> format)
      Creates a CommentedConfig of the given format.
      Parameters:
      format - the config's format
      Returns:
      a new empty config
    • of

      static CommentedConfig of(Supplier<Map<String,Object>> mapCreator, ConfigFormat<? extends CommentedConfig> format)
      Creates a Config backed by a certain kind of map, given by a supplier.
      Parameters:
      mapCreator - a supplier which will be called to create all backing maps for this config (including sub-configs)
      format - the config's format
      Returns:
      a new empty config
    • ofConcurrent

      static CommentedConfig ofConcurrent(ConfigFormat<? extends CommentedConfig> format)
      Creates a thread-safe CommentedConfig of the given format.
      Parameters:
      format - the config's format
      Returns:
      a new empty, thread-safe config
    • inMemory

      static CommentedConfig inMemory()
      Creates a CommentedConfig with format InMemoryCommentedFormat.defaultInstance().
      Returns:
      a new empty config
    • inMemoryConcurrent

      static CommentedConfig inMemoryConcurrent()
      Creates a CommentedConfig with format InMemoryFormat.defaultInstance().
      Returns:
      a new empty config
    • wrap

      static CommentedConfig wrap(Map<String,Object> map, ConfigFormat<?> format)
      Creates a CommentedConfig backed by a Map. Any change to the map is reflected in the config and vice-versa.
      Parameters:
      map - the Map to use
      format - the config's format
      Returns:
      a new config backed by the map
    • copy

      static CommentedConfig copy(UnmodifiableConfig config)
      Creates a new CommentedConfig with the content of the given config. The returned config will have the same format as the copied config.
      Parameters:
      config - the config to copy
      Returns:
      a copy of the config
    • copy

      static CommentedConfig copy(UnmodifiableConfig config, Supplier<Map<String,Object>> mapCreator)
      Creates a new CommentedConfig with the content of the given config. The returned config will have the same format as the copied config, and be backed by the given supplier.
      Parameters:
      config - the config to copy
      mapCreator - a supplier which will be called to create all backing maps for this config (including sub-configs)
      Returns:
      a copy of the config
      See Also:
    • copy

      static CommentedConfig copy(UnmodifiableConfig config, ConfigFormat<?> format)
      Creates a new CommentedConfig with the content of the given config.
      Parameters:
      config - the config to copy
      format - the config's format
      Returns:
      a copy of the config
    • copy

      static CommentedConfig copy(UnmodifiableConfig config, Supplier<Map<String,Object>> mapCreator, ConfigFormat<?> format)
      Creates a new CommentedConfig with the content of the given config. The returned config will be backed by the given map supplier.
      Parameters:
      config - the config to copy
      mapCreator - a supplier which will be called to create all backing maps for this config (including sub-configs)
      format - the config's format
      Returns:
      a copy of the config
      See Also:
    • copy

      Creates a new CommentedConfig with the content of the given config. The returned config will have the same format as the copied config.
      Parameters:
      config - the config to copy
      Returns:
      a copy of the config
    • copy

      Creates a new CommentedConfig with the content of the given config. The returned config will have the same format as the copied config.
      Parameters:
      config - the config to copy
      mapCreator - a supplier which will be called to create all backing maps for this config (including sub-configs)
      Returns:
      a copy of the config
    • copy

      static CommentedConfig copy(UnmodifiableCommentedConfig config, ConfigFormat<?> format)
      Creates a new CommentedConfig with the content of the given config.
      Parameters:
      config - the config to copy
      format - the config's format
      Returns:
      a copy of the config
    • copy

      static CommentedConfig copy(UnmodifiableCommentedConfig config, Supplier<Map<String,Object>> mapCreator, ConfigFormat<? extends CommentedConfig> format)
      Creates a new CommentedConfig with the content of the given config. The returned config will be backed by the given map supplier.
      Parameters:
      config - the config to copy
      mapCreator - a supplier which will be called to create all backing maps for this config (including sub-configs)
      format - the config's format
      Returns:
      a copy of the config
      See Also:
    • concurrentCopy

      static CommentedConfig concurrentCopy(UnmodifiableConfig config)
      Creates a new CommentedConfig with the content of the given config. The returned config will have the same format as the copied config.
      Parameters:
      config - the config to copy
      Returns:
      a thread-safe copy of the config
    • concurrentCopy

      static CommentedConfig concurrentCopy(UnmodifiableConfig config, ConfigFormat<?> format)
      Creates a new CommentedConfig with the content of the given config.
      Parameters:
      config - the config to copy
      format - the config's format
      Returns:
      a thread-safe copy of the config
    • concurrentCopy

      static CommentedConfig concurrentCopy(UnmodifiableCommentedConfig config)
      Creates a new CommentedConfig with the content of the given config. The returned config will have the same format as the copied config.
      Parameters:
      config - the config to copy
      Returns:
      a thread-safe copy of the config
    • concurrentCopy

      static CommentedConfig concurrentCopy(UnmodifiableCommentedConfig config, ConfigFormat<?> format)
      Creates a new CommentedConfig with the content of the given config.
      Parameters:
      config - the config to copy
      format - the config's format
      Returns:
      a thread-safe copy of the config
    • fake

      static CommentedConfig fake(Config config)
      If the specified config is an instance of CommentedConfig, returns it. Else, returns a "fake" CommentedConfig instance with the same values (ie the valueMaps are equal) as the config. This fake CommentedConfig doesn't actually store nor process comments, it just provides the methods of CommentedConfig.
      Parameters:
      config - the config
      Returns:
      a CommentedConfig instance backed by the specified config