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
      • 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