Class Config

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected top.focess.util.yaml.YamlConfiguration yaml  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Config​(@Nullable File file)
      Loads the configuration from the given file Note: if the file is null or not exists, it will create an empty configuration.
      protected Config​(@Nullable InputStream stream)
      Loads the configuration from the given input stream
      protected Config​(@Nullable Map<String,​Object> values)
      Loads the configuration from the given values
      protected Config​(top.focess.util.yaml.YamlConfiguration yaml)
      Loads the configuration from the given YamlConfiguration
    • Field Detail

      • yaml

        protected final top.focess.util.yaml.YamlConfiguration yaml
    • Constructor Detail

      • Config

        protected Config​(@Nullable File file)
                  throws top.focess.util.yaml.YamlLoadException
        Loads the configuration from the given file Note: if the file is null or not exists, it will create an empty configuration.
        Parameters:
        file - the file
        Throws:
        top.focess.util.yaml.YamlLoadException - if the file is not a valid yaml file
      • Config

        protected Config​(@Nullable InputStream stream)
        Loads the configuration from the given input stream
        Parameters:
        stream - the given input stream
      • Config

        protected Config​(@Nullable Map<String,​Object> values)
        Loads the configuration from the given values
        Parameters:
        values - the given values
      • Config

        protected Config​(top.focess.util.yaml.YamlConfiguration yaml)
        Loads the configuration from the given YamlConfiguration
        Parameters:
        yaml - the given YamlConfiguration
    • Method Detail

      • getFile

        public @Nullable File getFile()
        Get the file of this configuration
        Returns:
        the file of this configuration or null if this configuration is not loaded from a file
      • get

        protected <T> @Nullable T get​(String key)
        Get the value of the specified key
        Type Parameters:
        T - the value type
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value is not the specified type
      • set

        protected void set​(String key,
                           @Nullable Object value)
        Set the value of the specified key
        Parameters:
        key - the key
        value - the value
      • save

        protected void save()
        Save the configuration to the file
        Throws:
        UnsupportedOperationException - if the configuration is not loaded from a file
      • getValues

        protected Map<String,​Object> getValues()
        Get all the configuration as a map
        Returns:
        all the configuration as a map
      • contains

        protected boolean contains​(String key)
        Indicate there is a configuration named key
        Parameters:
        key - the key
        Returns:
        true there is a configuration named key, false otherwise
      • remove

        protected void remove​(String key)
        Remove the configuration named key
        Parameters:
        key - the key
      • getSection

        protected abstract Config getSection​(String key)
        Get the section named key Note: if the section named key does not exist, it will be created
        Parameters:
        key - the key of the Section
        Returns:
        the section named key
        Throws:
        UnsupportedOperationException - if there is no section named key or the config does not support section