Class KeyBuilder
java.lang.Object
com.tchristofferson.configupdater.KeyBuilder
- All Implemented Interfaces:
Cloneable
-
Constructor Summary
ConstructorsConstructorDescriptionKeyBuilder(org.bukkit.configuration.file.FileConfiguration config, char separator) Constructs a new KeyBuilder instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the contents of the builder.protected KeyBuilderclone()Creates a clone of this KeyBuilder instance.Gets the last key in the builder.booleanChecks if the key path represented by this instance is a configuration section in the FileConfiguration.booleanChecks if the key path represented by this instance is a non-empty configuration section in the FileConfiguration.booleanisEmpty()Checks if the builder is empty.booleanChecks if the specified subKey is a sub-key of the key path represented by this instance.booleanisSubKeyOf(String parentKey) Checks if the full key path represented by this instance is a sub-key of the specified parent key.voidParses the line to check if it represents a valid YAML path.voidRemoves the last key from the builder.toString()Returns the current key path as a string.
-
Constructor Details
-
KeyBuilder
public KeyBuilder(org.bukkit.configuration.file.FileConfiguration config, char separator) Constructs a new KeyBuilder instance.- Parameters:
config- the FileConfiguration to work with.separator- the character used as the separator between key parts. The default separator is a dot ('.').
-
-
Method Details
-
parseLine
Parses the line to check if it represents a valid YAML path. If the config does not contain the path, it removes the last part of the line until it finds a valid path or becomes empty.- Parameters:
line- the line to check if it belongs to the current path set in thebuilder.checkIfExists- set to true to check if the path is valid in the config.
-
getLastKey
Gets the last key in the builder.- Returns:
- the last key, or an empty string if the builder is empty.
-
isEmpty
public boolean isEmpty()Checks if the builder is empty.- Returns:
- true if the builder is empty; otherwise, false.
-
clear
public void clear()Clears the contents of the builder. -
isSubKeyOf
Checks if the full key path represented by this instance is a sub-key of the specified parent key.- Parameters:
parentKey- the parent key to check against.- Returns:
- true if the full key path is a sub-key of the parentKey; otherwise, false.
-
isSubKey
Checks if the specified subKey is a sub-key of the key path represented by this instance.- Parameters:
subKey- the sub-key to check.- Returns:
- true if the subKey is a sub-key of the key path; otherwise, false.
-
isConfigSection
public boolean isConfigSection()Checks if the key path represented by this instance is a configuration section in the FileConfiguration.- Returns:
- true if the key path is a configuration section; otherwise, false.
-
isConfigSectionWithKeys
public boolean isConfigSectionWithKeys()Checks if the key path represented by this instance is a non-empty configuration section in the FileConfiguration.- Returns:
- true if the key path is a non-empty configuration section; otherwise, false.
-
removeLastKey
public void removeLastKey()Removes the last key from the builder. For example, if the input is 'key1.key2', the result will be 'key1'. -
toString
Returns the current key path as a string. -
clone
Creates a clone of this KeyBuilder instance.
-