Interface ConfigureSection
- All Known Implementing Classes:
ConfigureSource
- Since:
- 4.0.0
- Author:
- Carm
-
Method Summary
Modifier and TypeMethodDescriptionasMap()
Get this section as a map.default String
default @NotNull ConfigureSection
computeSection
(@NotNull String path) Get or create a section at the given path.default @NotNull ConfigureSection
computeSection
(@NotNull String path, @NotNull Map<?, ?> data) Get or create a section at the given path.default @NotNull ConfigureSection
Get or create a section at the given path.default @NotNull ConfigureSection
Get or create a section at the given path.default boolean
Check if the given path is present.default boolean
containsValue
(@NotNull String path) Check if the value of given path is present.default @NotNull ConfigureSection
createSection
(@NotNull String path) Creates a new emptyConfigureSection
.@NotNull ConfigureSection
createSection
(@NotNull String path, @NotNull Map<?, ?> data) Creates a newConfigureSection
with specified values.default @NotNull ConfigureSection
Creates a newConfigureSection
with specified values.default @NotNull ConfigureSection
Creates a newConfigureSection
with specified values.default void
forEach
(@NotNull BiConsumer<String, Object> action) Iterates over all key-values in this section (include child sections)default @NotNull String
fullPath()
Get the full path of this section.@Nullable Object
Get the origin value of the path.default <T> T
get
(@NotNull String path, @NotNull DataFunction<@Nullable Object, T> parser) Get the value of the path using a parser function, if the path does not exist, return NULL.default <T> T
Get the value of the path for specific type, if the path does not exist, return null.default <T> T
get
(@NotNull String path, T defaultValue, @NotNull DataFunction<Object, T> parser) Get the value of the path using a parser function, if the path does not exist, return the default value.default <T> T
Get the value of the path for specific type, if the path does not exist, return the default value.default boolean
getBoolean
(@NotNull String path) Get the value as aBoolean
from the specified path.default @Nullable Boolean
getBoolean
(@NotNull String path, @Nullable Boolean def) Get the value as aBoolean
from the specified path.default @Nullable Byte
Get the value as aByte
from the specified path.default @Nullable Byte
Get the value as aByte
from the specified path.getByteList
(@NotNull String path) Get a list of bytes from current sectiondefault @Nullable Character
Get the value as aCharacter
from the specified path.default @Nullable Character
Get the value as aCharacter
from the specified path.getCharList
(@NotNull String path) Get a list of char from current sectiondefault <T,
C extends Collection<T>>
CgetCollection
(@NotNull String path, @NotNull Supplier<C> constructor, @NotNull DataFunction<Object, T> parser) Get the specific type of collection from current section.default @Nullable Double
Get the value as aDouble
from the specified path.default @Nullable Double
Get the value as aDouble
from the specified path.getDoubleList
(@NotNull String path) Get a list of double from current sectiondefault @Nullable Float
Get the value as aFloat
from the specified path.default @Nullable Float
Get the value as aFloat
from the specified path.getFloatList
(@NotNull String path) Get a list of floats from current sectiondefault @Nullable Integer
Get the value as aInteger
from the specified path.default @Nullable Integer
Get the value as aInteger
from the specified path.getIntegerList
(@NotNull String path) Get a list of integer from current sectiongetKeys
(boolean deep) Gets a set containing all keys in this section.default @Nullable List
<?> Get the value as aList
from the specified path.default <V> @NotNull List
<V> getList
(@NotNull String path, @NotNull DataFunction<Object, V> parser) Get a list of values from current sectiondefault @Nullable Long
Get the value as aLong
from the specified path.default @Nullable Long
Get the value as aLong
from the specified path.getLongList
(@NotNull String path) Get a list of long from current sectiondefault @Nullable ConfigureSection
getSection
(@NotNull String path) Get the value as aConfigureSection
from the specified path.default @NotNull List
<ConfigureSection> getSectionList
(@NotNull String path) Get a list ofConfigureSection
from current sectiondefault @Nullable Short
Get the value as aShort
from the specified path.default @Nullable Short
Get the value as aShort
from the specified path.default @Nullable String
Get the value as aString
from the specified path.default @Nullable String
Get the value as aString
from the specified path.getStringList
(@NotNull String path) Get a list of strings from current sectiongetValues
(boolean deep) Gets a set containing all values in this section.default boolean
Predicate the value of given path is aBoolean
.default @Nullable Boolean
Predicate the value of given path is aByte
.default boolean
Predicate the value of given path is aCharacter
.default boolean
Predicate the value of given path is aDouble
.default boolean
isEmpty()
Gets if this section is empty.default boolean
Predicate the value of given path is aFloat
.default boolean
Predicate the value of given path is aInteger
.default boolean
Predicate the value of given path is aList
.default boolean
Predicate the value of given path is aLong
.Fdefault boolean
isRoot()
Gets if this section is a root section.default boolean
Predicate the value of given path is aConfigureSection
.default boolean
Predicate the value of given path is aShort
.default boolean
Predicate the value of given path is aString
.default <T> boolean
Predicate the value of given path is specific type.keys()
Gets a set containing all primary keys in this section.@Nullable ConfigureSection
parent()
Gets the parent section of this section.static <T,
C extends Collection<T>>
CparseCollection
(@Nullable List<?> data, @NotNull Supplier<C> constructor, @NotNull DataFunction<Object, T> parser) @NotNull String
path()
Get the current section's path fromparent()
of this section.default char
Get the path separator for the section.void
Removes the value at the given path.void
Sets the value at the given path.default int
size
(boolean deep) Gets the number of keys in this section.stream()
Create a stream of all values in this section.default @NotNull Stream
<?> Get the specific type of steam from current section.default <T> @NotNull Stream
<T> Get the specific type of steam from current section.values()
Gets a set containing all key-values in this section.
-
Method Details
-
parent
Gets the parent section of this section.For root sections, this will return null.
- Returns:
- Parent section, or null if this is a root section.
-
path
Get the current section's path fromparent()
of this section.- Returns:
- The current path of this section, if
isRoot()
, return empty string.
-
fullPath
Get the full path of this section.- Returns:
- The full path of this section, if
isRoot()
, return empty string.
-
pathSeparator
default char pathSeparator()Get the path separator for the section.- Returns:
- The path separator
-
isRoot
@Contract(pure=true) default boolean isRoot()Gets if this section is a root section.- Returns:
- True if this section is a root section, false otherwise.
-
isEmpty
default boolean isEmpty()Gets if this section is empty.- Returns:
- True if this section is empty, false otherwise.
-
size
default int size(boolean deep) Gets the number of keys in this section.- Returns:
- Number of keys in this section.
-
getKeys
Gets a set containing all keys in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSection
s (and their children paths).If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
- Parameters:
deep
- Whether to get a deep list.- Returns:
- Set of keys contained within this Section.
-
keys
Gets a set containing all primary keys in this section.- Returns:
- Set of keys contained within this Section.
-
getValues
Gets a set containing all values in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSection
s (and their children paths).If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
- Parameters:
deep
- Whether to get a deep list.- Returns:
- Map of data values contained within this Section.
-
values
Gets a set containing all key-values in this section.- Returns:
- Map of data values contained within this Section.
- See Also:
-
asMap
Get this section as a map.In this map, child
ConfigureSection
s will also be represented asMap
s.- Returns:
- Map of data values contained within this Section.
-
stream
Create a stream of all values in this section.- Returns:
- Stream of all values in this section.
-
forEach
Iterates over all key-values in this section (include child sections)- Parameters:
action
- The action to apply to each key.
-
set
Sets the value at the given path.Null values will be kept, if you want to remove a value use
remove(String)
Path separator depends on holder'sStandardOptions.PATH_SEPARATOR
- Parameters:
path
- The path to set the value at.value
- The value to set.
-
remove
Removes the value at the given path.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR
- Parameters:
path
- The path to remove the value at.
-
contains
Check if the given path is present.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR
- Parameters:
path
- The path to check.- Returns:
- True if the value is present, false otherwise.
-
containsValue
Check if the value of given path is present.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR
- Parameters:
path
- The path to check.- Returns:
- True if the value is present, false otherwise.
-
isType
Predicate the value of given path is specific type.- Type Parameters:
T
- The type to check.- Parameters:
path
- The path to check.typeClass
- The type's class- Returns:
- True if the value is present and is the correct type, false otherwise.
-
isList
Predicate the value of given path is aList
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a list, false otherwise.
-
getList
Get the value as aList
from the specified path.- Parameters:
path
- The path to get theList
.- Returns:
- The list if the path exists and is a list, otherwise null.
-
isSection
Predicate the value of given path is aConfigureSection
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a section, false otherwise.
-
getSection
Get the value as aConfigureSection
from the specified path.- Parameters:
path
- The path to get the section.- Returns:
- The section if the path exists and is a section, otherwise null.
-
createSection
@NotNull @NotNull ConfigureSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Map<?, ?> data) Creates a newConfigureSection
with specified values.The
parent()
of the new section will be this section.This section will not be saved until
set(String, Object)
is called.If you want to create and use a section and set it to this section, use
computeSection(String)
.- Parameters:
data
- The data to be used to create section.- Returns:
- Newly created section
-
createSection
@NotNull default @NotNull ConfigureSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Consumer<Map<String, Object>> data) Creates a newConfigureSection
with specified values.The
parent()
of the new section will be this section.- Parameters:
data
- The data to be used to create section.- Returns:
- Newly created section
-
createSection
@NotNull default @NotNull ConfigureSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Supplier<Map<String, Object>> data) Creates a newConfigureSection
with specified values.The
parent()
of the new section will be this section.- Parameters:
data
- The data to be used to create section.- Returns:
- Newly created section
-
createSection
Creates a new emptyConfigureSection
.The
parent()
of the new section will be this section.- Returns:
- Newly created section
-
computeSection
Get or create a section at the given path.Any value previously set at this path will be replaced if it is not a section or will be returned if it is an exists
ConfigureSection
.- Parameters:
path
- The path to get the section from.- Returns:
- The section at the path, or a new section if it does not exist.
- See Also:
-
computeSection
@NotNull default @NotNull ConfigureSection computeSection(@NotNull @NotNull String path, @NotNull @NotNull Map<?, ?> data) Get or create a section at the given path.Any value previously set at this path will be replaced if it is not a section or will be returned if it is an exists
ConfigureSection
.- Parameters:
path
- The path to get the section from.- Returns:
- The section at the path, or a new section if it does not exist.
- See Also:
-
computeSection
@NotNull default @NotNull ConfigureSection computeSection(@NotNull @NotNull String path, @NotNull @NotNull Consumer<Map<String, Object>> data) Get or create a section at the given path.Any value previously set at this path will be replaced if it is not a section or will be returned if it is an exists
ConfigureSection
.- Parameters:
path
- The path to get the section from.- Returns:
- The section at the path, or a new section if it does not exist.
- See Also:
-
computeSection
@NotNull default @NotNull ConfigureSection computeSection(@NotNull @NotNull String path, @NotNull @NotNull Supplier<Map<String, Object>> data) Get or create a section at the given path.Any value previously set at this path will be replaced if it is not a section or will be returned if it is an exists
ConfigureSection
.- Parameters:
path
- The path to get the section from.- Returns:
- The section at the path, or a new section if it does not exist.
- See Also:
-
get
Get the origin value of the path.- Parameters:
path
- The path to get the value from.- Returns:
- The value at the path, or null if not found.
-
get
Get the value of the path for specific type, if the path does not exist, return null.- Type Parameters:
T
- The type of the value- Parameters:
path
- The path to get the value from.type
- The type class of the value- Returns:
- The value at the path, or the default value if not found.
-
get
@Nullable default <T> T get(@NotNull @NotNull String path, @NotNull @NotNull DataFunction<@Nullable Object, T> parser) Get the value of the path using a parser function, if the path does not exist, return NULL.- Type Parameters:
T
- The type of the value- Parameters:
path
- The path to get the value from.parser
- The function to parse the value- Returns:
- The value at the path, or null if not found.
-
get
@Contract("_,!null,_->!null") @Nullable default <T> T get(@NotNull @NotNull String path, @Nullable T defaults, @NotNull @NotNull Class<T> clazz) Get the value of the path for specific type, if the path does not exist, return the default value.- Type Parameters:
T
- The type of the value- Parameters:
path
- The path to get the value from.defaults
- The default value to return if the path does not exist.clazz
- The type class of the value- Returns:
- The value at the path, or the default value if not found.
-
get
@Contract("_,!null,_->!null") @Nullable default <T> T get(@NotNull @NotNull String path, @Nullable T defaultValue, @NotNull @NotNull DataFunction<Object, T> parser) Get the value of the path using a parser function, if the path does not exist, return the default value.- Type Parameters:
T
- The type of the value- Parameters:
path
- The path to get the value from.defaultValue
- The default value to return if the path does not exist.parser
- The function to parse the value- Returns:
- The value at the path, or the default value if not found.
-
isBoolean
Predicate the value of given path is aBoolean
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a boolean, false otherwise.
-
getBoolean
Get the value as aBoolean
from the specified path.- Parameters:
path
- The path to get the boolean.- Returns:
- The boolean if the path exists and is a boolean, otherwise false.
-
getBoolean
@Contract("_, !null -> !null") @Nullable default @Nullable Boolean getBoolean(@NotNull @NotNull String path, @Nullable @Nullable Boolean def) Get the value as aBoolean
from the specified path.- Parameters:
path
- The path to get the boolean.def
- The default value to return if the path does not exist.- Returns:
- The boolean if the path exists and is a boolean, otherwise the default value.
-
isByte
Predicate the value of given path is aByte
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a byte, false otherwise.
-
getByte
Get the value as aByte
from the specified path.- Parameters:
path
- The path to get the byte.- Returns:
- The byte if the path exists and is a byte, otherwise 0.
-
getByte
@Contract("_, !null -> !null") @Nullable default @Nullable Byte getByte(@NotNull @NotNull String path, @Nullable @Nullable Byte def) Get the value as aByte
from the specified path.- Parameters:
path
- The path to get the byte.def
- The default value to return if the path does not exist.- Returns:
- The byte if the path exists and is a byte, otherwise the default value.
-
isShort
Predicate the value of given path is aShort
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a short, false otherwise.
-
getShort
Get the value as aShort
from the specified path.- Parameters:
path
- The path to get the short.- Returns:
- The short if the path exists and is a short, otherwise 0.
-
getShort
@Contract("_, !null -> !null") @Nullable default @Nullable Short getShort(@NotNull @NotNull String path, @Nullable @Nullable Short def) Get the value as aShort
from the specified path.- Parameters:
path
- The path to get the short.def
- The default value to return if the path does not exist.- Returns:
- The short if the path exists and is a short, otherwise the default value.
-
isInt
Predicate the value of given path is aInteger
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is an int, false otherwise.
-
getInt
Get the value as aInteger
from the specified path.- Parameters:
path
- The path to get the int.- Returns:
- The int if the path exists and is an int, otherwise 0.
-
getInt
@Contract("_, !null -> !null") @Nullable default @Nullable Integer getInt(@NotNull @NotNull String path, @Nullable @Nullable Integer def) Get the value as aInteger
from the specified path.- Parameters:
path
- The path to get the int.def
- The default value to return if the path does not exist.- Returns:
- The int if the path exists and is an int, otherwise the default value.
-
isLong
Predicate the value of given path is aLong
.F- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a long, false otherwise.
-
getLong
Get the value as aLong
from the specified path.- Parameters:
path
- The path to get the long.- Returns:
- The long if the path exists and is a long, otherwise 0.
-
getLong
@Contract("_, !null -> !null") @Nullable default @Nullable Long getLong(@NotNull @NotNull String path, @Nullable @Nullable Long def) Get the value as aLong
from the specified path.- Parameters:
path
- The path to get the long.def
- The default value to return if the path does not exist.- Returns:
- The long if the path exists and is a long, otherwise the default value.
-
isFloat
Predicate the value of given path is aFloat
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a float, false otherwise.
-
getFloat
Get the value as aFloat
from the specified path.- Parameters:
path
- The path to get the float.- Returns:
- The float if the path exists and is a float, otherwise 0.
-
getFloat
@Contract("_, !null -> !null") @Nullable default @Nullable Float getFloat(@NotNull @NotNull String path, @Nullable @Nullable Float def) Get the value as aFloat
from the specified path.- Parameters:
path
- The path to get the float.def
- The default value to return if the path does not exist.- Returns:
- The float if the path exists and is a float, otherwise the default value.
-
isDouble
Predicate the value of given path is aDouble
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a double, false otherwise.
-
getDouble
Get the value as aDouble
from the specified path.- Parameters:
path
- The path to get the double.- Returns:
- The double if the path exists and is a double, otherwise 0.
-
getDouble
@Contract("_, !null -> !null") @Nullable default @Nullable Double getDouble(@NotNull @NotNull String path, @Nullable @Nullable Double def) Get the value as aDouble
from the specified path.- Parameters:
path
- The path to get the double.def
- The default value to return if the path does not exist.- Returns:
- The double if the path exists and is a double, otherwise the default value.
-
isChar
Predicate the value of given path is aCharacter
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a char, false otherwise.
-
getChar
Get the value as aCharacter
from the specified path.- Parameters:
path
- The path to get the char.- Returns:
- The char if the path exists and is a char, otherwise null.
-
getChar
@Contract("_, !null -> !null") @Nullable default @Nullable Character getChar(@NotNull @NotNull String path, @Nullable @Nullable Character def) Get the value as aCharacter
from the specified path.- Parameters:
path
- The path to get the char.def
- The default value to return if the path does not exist.- Returns:
- The char if the path exists and is a char, otherwise the default value.
-
isString
Predicate the value of given path is aString
.- Parameters:
path
- The path to check.- Returns:
- True if the value is present and is a string, false otherwise.
-
getString
Get the value as aString
from the specified path.- Parameters:
path
- The path to get the string.- Returns:
- The string if the path exists and is a string, otherwise null.
-
getString
@Contract("_, !null -> !null") @Nullable default @Nullable String getString(@NotNull @NotNull String path, @Nullable @Nullable String def) Get the value as aString
from the specified path.- Parameters:
path
- The path to get the string.def
- The default value to return if the path does not exist.- Returns:
- The string if the path exists and is a string, otherwise the default value.
-
getList
@NotNull default <V> @NotNull List<V> getList(@NotNull @NotNull String path, @NotNull @NotNull DataFunction<Object, V> parser) Get a list of values from current sectionIf the path does not exist, an empty list will be returned
Any changes please useset(String, Object)
after changes- Type Parameters:
V
- The type of the values- Parameters:
path
- The path to get the list fromparser
- The function to parse the values- Returns:
- The list of values
-
getStringList
Get a list of strings from current sectionLimitations see
getList(String, DataFunction)
- Parameters:
path
- The path to get the list from- Returns:
- The list of strings
-
getIntegerList
Get a list of integer from current sectionLimitations see
getList(String, DataFunction)
- Parameters:
path
- The path to get the list from- Returns:
- The list of int values
-
getLongList
Get a list of long from current sectionLimitations see
getList(String, DataFunction)
- Parameters:
path
- The path to get the list from- Returns:
- The list of long values
-
getDoubleList
Get a list of double from current sectionLimitations see
getList(String, DataFunction)
- Parameters:
path
- The path to get the list from- Returns:
- The list of doubles
-
getFloatList
Get a list of floats from current sectionLimitations see
getList(String, DataFunction)
- Parameters:
path
- The path to get the list from- Returns:
- The list of floats
-
getByteList
Get a list of bytes from current sectionLimitations see
getList(String, DataFunction)
- Parameters:
path
- The path to get the list from- Returns:
- The list of bytes
-
getCharList
Get a list of char from current sectionLimitations see
getList(String, DataFunction)
- Parameters:
path
- The path to get the list from- Returns:
- The list of char
-
getSectionList
Get a list ofConfigureSection
from current section- Parameters:
path
- The path to get the list from- Returns:
- The list of
ConfigureSection
-
getCollection
@NotNull default <T,C extends Collection<T>> C getCollection(@NotNull @NotNull String path, @NotNull @NotNull Supplier<C> constructor, @NotNull @NotNull DataFunction<Object, T> parser) Get the specific type of collection from current section.- Type Parameters:
T
- The type of the valuesC
- The type of the collection- Parameters:
path
- The path to get the collection fromconstructor
- The constructor of the collectionparser
- The function to parse the values- Returns:
- The collection of values
-
stream
Get the specific type of steam from current section.- Parameters:
path
- The path to get the stream from- Returns:
- The stream of values
-
stream
@NotNull default <T> @NotNull Stream<T> stream(@NotNull @NotNull String path, @NotNull @NotNull Function<Object, T> parser) Get the specific type of steam from current section.- Type Parameters:
T
- The type of the values- Parameters:
path
- The path to get the stream fromparser
- The function to parse the values- Returns:
- The stream of values
-
childPath
-
parseCollection
@NotNull static <T,C extends Collection<T>> C parseCollection(@Nullable @Nullable List<?> data, @NotNull @NotNull Supplier<C> constructor, @NotNull @NotNull DataFunction<Object, T> parser)
-