Class YamlConfiguration

    • Constructor Detail

      • YamlConfiguration

        public YamlConfiguration​(@Nullable Map<String,​Object> values)
        Initializes the YamlConfiguration with existed key-value pairs
        Parameters:
        values - the YAML configuration key-value pairs
    • Method Detail

      • loadFile

        @NotNull
        public static YamlConfiguration loadFile​(@NonNull File file)
                                          throws YamlLoadException
        Load the file as a YAML configuration
        Parameters:
        file - where to load
        Returns:
        YAML configuration
        Throws:
        YamlLoadException - if there is any io exception in loading the file
      • createSection

        public YamlConfigurationSection createSection​(String key)
        Description copied from interface: SectionMap
        Create the section named key Note: if the section named key already exists, it will be replaced by a new section
        Specified by:
        createSection in interface SectionMap
        Parameters:
        key - the key of the Section
        Returns:
        a section named key
      • set

        public void set​(String key,
                        @Nullable Object value)
        Description copied from interface: SectionMap
        Store the key-value pair
        Specified by:
        set in interface SectionMap
        Parameters:
        key - the key of the key-value pair
        value - the value of the key-value pair
      • getList

        public <T> @Nullable List<T> getList​(String key)
        Get the value of the key-value pair as list
        Parameters:
        key - the key
        Returns:
        the value of the key-value pair as list, or null if the key does not exist
      • getListOrEmpty

        public <T> List<T> getListOrEmpty​(String key)
        Get the value of the key-value pair as list
        Parameters:
        key - the key
        Returns:
        the value of the key-value pair as list or an empty list if the key-value pair does not exist
      • setList

        public void setList​(String key,
                            List<?> value)
        Set the list value of the key-value pair
        Parameters:
        key - the key
        value - the list value
      • get

        public <T> @Nullable T get​(String key)
        Description copied from interface: SectionMap
        Get the value of the key-value pair
        Specified by:
        get in interface SectionMap
        Type Parameters:
        T - the value type
        Parameters:
        key - the key of the key-value pair
        Returns:
        the value
      • save

        public void save​(File file)
        Save the YAML configuration as a file
        Parameters:
        file - where to save
      • getSection

        public YamlConfigurationSection getSection​(String key)
        Description copied from interface: SectionMap
        Get the section named key Note: if the section named key does not exist, it will be created
        Specified by:
        getSection in interface SectionMap
        Parameters:
        key - the key of the Section
        Returns:
        the section named key
      • containsSection

        public boolean containsSection​(String key)
        Description copied from interface: SectionMap
        Indicate there is a section named key
        Specified by:
        containsSection in interface SectionMap
        Parameters:
        key - the key of the Section
        Returns:
        true there is a section named key, false otherwise