Interface CommentedConfig

    • Method Detail

      • setComment

        default java.lang.String setComment​(java.lang.String path,
                                            java.lang.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

        java.lang.String setComment​(java.util.List<java.lang.String> path,
                                    java.lang.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 java.lang.String removeComment​(java.lang.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

        java.lang.String removeComment​(java.util.List<java.lang.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​(java.util.Map<java.lang.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

        java.util.Map<java.lang.String,​java.lang.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.
      • of

        static CommentedConfig of​(java.util.function.Supplier<java.util.Map<java.lang.String,​java.lang.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
      • wrap

        static CommentedConfig wrap​(java.util.Map<java.lang.String,​java.lang.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,
                                    java.util.function.Supplier<java.util.Map<java.lang.String,​java.lang.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:
        of(Supplier, ConfigFormat)
      • 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,
                                    java.util.function.Supplier<java.util.Map<java.lang.String,​java.lang.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:
        of(Supplier, ConfigFormat)
      • copy

        static CommentedConfig copy​(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 copy of the config
      • copy

        static CommentedConfig copy​(UnmodifiableCommentedConfig config,
                                    java.util.function.Supplier<java.util.Map<java.lang.String,​java.lang.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.
        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,
                                    java.util.function.Supplier<java.util.Map<java.lang.String,​java.lang.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:
        of(Supplier, ConfigFormat)
      • 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