Class ConvertedCommentedFileConfig

    • Constructor Detail

      • ConvertedCommentedFileConfig

        public ConvertedCommentedFileConfig​(CommentedFileConfig config,
                                            java.util.function.Function<java.lang.Object,​java.lang.Object> readConversion,
                                            java.util.function.Function<java.lang.Object,​java.lang.Object> writeConversion,
                                            java.util.function.Predicate<java.lang.Class<?>> supportPredicate)
    • Method Detail

      • getFile

        public java.io.File getFile()
        Specified by:
        getFile in interface FileConfig
        Returns:
        the config's file, as a classic File object
      • getNioPath

        public java.nio.file.Path getNioPath()
        Specified by:
        getNioPath in interface FileConfig
        Returns:
        the config's file, as a NIO Path object
      • save

        public void save()
        Description copied from interface: FileConfig
        Saves this config as soon as possible. This method may return quickly and perform the IO operations in background, or it may block until the operations are done.
        Specified by:
        save in interface FileConfig
      • load

        public void load()
        Description copied from interface: FileConfig
        (Re)loads this config from the file. This method blocks until the read operation completes.
        Specified by:
        load in interface FileConfig
      • close

        public void close()
        Description copied from interface: FileConfig
        Closes this FileConfig, releases its associated resources (if any), and ensure that the ongoing saving operations complete.

        A closed FileConfig can still be used via the Config's methods, but FileConfig.save() and FileConfig.load() will throw an IllegalStateException. Closing an aleady closed FileConfig has no effect.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface FileConfig
      • getComment

        public java.lang.String getComment​(java.util.List<java.lang.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.
      • containsComment

        public boolean containsComment​(java.util.List<java.lang.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.
      • setComment

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

        public void putAllComments​(UnmodifiableCommentedConfig commentedConfig)
        Description copied from interface: CommentedConfig
        Puts the comments in the given config to this config. Existing comments are replaced, missing comments are created.
        Specified by:
        putAllComments in interface CommentedConfig
        Parameters:
        commentedConfig - the config to copy its comments
      • commentMap

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

        public <T> T set​(java.util.List<java.lang.String> path,
                         java.lang.Object value)
        Description copied from interface: Config
        Sets a config value.
        Specified by:
        set in interface Config
        Overrides:
        set in class ConfigWrapper<C extends Config>
        Type Parameters:
        T - the type of the old value
        Parameters:
        path - the value's path, each element of the list is a different part of the path.
        value - the value to set
        Returns:
        the old value if any, or null
      • getRaw

        public <T> T getRaw​(java.util.List<java.lang.String> path)
        Description copied from interface: UnmodifiableConfig
        Gets a value from the config. Doesn't convert NullObject.NULL_OBJECT to null.
        Specified by:
        getRaw in interface UnmodifiableConfig
        Overrides:
        getRaw in class UnmodifiableConfigWrapper<C extends Config>
        Type Parameters:
        T - the value's type
        Parameters:
        path - the value's path, each element of the list is a different part of the path.
        Returns:
        the value at the given path, or null if there is no such value.