Package top.focess.qq.api.util.yaml
Class YamlConfiguration
- java.lang.Object
-
- top.focess.qq.api.util.yaml.YamlConfiguration
-
- All Implemented Interfaces:
Serializable,SectionMap
- Direct Known Subclasses:
YamlConfigurationSection
public class YamlConfiguration extends Object implements SectionMap
This class is used to define a YAML configuration.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description YamlConfiguration(@Nullable Map<String,Object> values)Initializes the YamlConfiguration with existed key-value pairs
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsSection(String key)Indicate there is a section named keyYamlConfigurationSectioncreateSection(String key)Create the section named key Note: if the section named key already exists, it will be replaced by a new section<T> @Nullable Tget(String key)Get the value of the key-value pairYamlConfigurationSectiongetSection(String key)Get the section named key Note: if the section named key does not exist, it will be createdMap<String,Object>getValues()Get all the key-value pairsstatic YamlConfigurationload(@Nullable InputStream inputStream)static YamlConfigurationloadFile(@NonNull File file)Load the file as a YAML configurationvoidsave(File file)Save the YAML configuration as a filevoidset(String key, @Nullable Object value)Store the key-value pairStringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface top.focess.qq.api.util.SectionMap
compute, contains, getOrDefault, keys, remove
-
-
-
-
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
-
load
@NotNull @Contract("_ -> new") public static YamlConfiguration load(@Nullable InputStream inputStream)
-
createSection
public YamlConfigurationSection createSection(String key)
Description copied from interface:SectionMapCreate the section named key Note: if the section named key already exists, it will be replaced by a new section- Specified by:
createSectionin interfaceSectionMap- 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:SectionMapStore the key-value pair- Specified by:
setin interfaceSectionMap- Parameters:
key- the key of the key-value pairvalue- the value of the key-value pair
-
get
public <T> @Nullable T get(String key)
Description copied from interface:SectionMapGet the value of the key-value pair- Specified by:
getin interfaceSectionMap- Type Parameters:
T- the value type- Parameters:
key- the key of the key-value pair- Returns:
- the value
-
getValues
public Map<String,Object> getValues()
Description copied from interface:SectionMapGet all the key-value pairs- Specified by:
getValuesin interfaceSectionMap- Returns:
- all the key-value pairs
-
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:SectionMapGet the section named key Note: if the section named key does not exist, it will be created- Specified by:
getSectionin interfaceSectionMap- Parameters:
key- the key of the Section- Returns:
- the section named key
-
containsSection
public boolean containsSection(String key)
Description copied from interface:SectionMapIndicate there is a section named key- Specified by:
containsSectionin interfaceSectionMap- Parameters:
key- the key of the Section- Returns:
- true there is a section named key, false otherwise
-
-