Class ImmutableSection
- All Implemented Interfaces:
ConfigureSection
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @Nullable ImmutableSectionprotected final @NotNull ConfigureSection -
Method Summary
Modifier and TypeMethodDescriptionasMap()Get this section as a map.booleanCheck if the given path is present.booleancontainsValue(@NotNull String path) Check if the value of given path is present.@NotNull ImmutableSectioncreateSection(@NotNull String path, @NotNull Map<?, ?> data) Creates a newConfigureSectionwith specified values.booleanvoidforEach(@NotNull BiConsumer<String, Object> action) Iterates over all key-values in this section (include child sections)@Nullable ObjectGet the origin value of the path.<T> Tget(@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.<T> TGet the value of the path for specific type, if the path does not exist, return null.<T> Tget(@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.<T> TGet the value of the path for specific type, if the path does not exist, return the default value.booleangetBoolean(@NotNull String path) Get the value as aBooleanfrom the specified path.@Nullable BooleangetBoolean(@NotNull String path, @Nullable Boolean def) Get the value as aBooleanfrom the specified path.@Nullable ByteGet the value as aBytefrom the specified path.@Nullable ByteGet the value as aBytefrom the specified path.getByteList(@NotNull String path) Get a list of bytes from current section@Nullable CharacterGet the value as aCharacterfrom the specified path.@Nullable CharacterGet the value as aCharacterfrom the specified path.getCharList(@NotNull String path) Get a list of char from current section<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.@Nullable DoubleGet the value as aDoublefrom the specified path.@Nullable DoubleGet the value as aDoublefrom the specified path.getDoubleList(@NotNull String path) Get a list of double from current section@Nullable FloatGet the value as aFloatfrom the specified path.@Nullable FloatGet the value as aFloatfrom the specified path.getFloatList(@NotNull String path) Get a list of floats from current section@Nullable IntegerGet the value as aIntegerfrom the specified path.@Nullable IntegerGet the value as aIntegerfrom 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.@Nullable List<?> Get the value as aListfrom the specified path.<V> @NotNull List<V> getList(@NotNull String path, @NotNull DataFunction<Object, V> parser) Get a list of values from current section@Nullable LongGet the value as aLongfrom the specified path.@Nullable LongGet the value as aLongfrom the specified path.getLongList(@NotNull String path) Get a list of long from current section@Nullable ConfigureSectiongetSection(@NotNull String path) Get the value as aConfigureSectionfrom the specified path.@NotNull List<ConfigureSection> getSectionList(@NotNull String path) Get a list ofConfigureSectionfrom current section@Nullable ShortGet the value as aShortfrom the specified path.@Nullable ShortGet the value as aShortfrom the specified path.@Nullable StringGet the value as aStringfrom the specified path.@Nullable StringGet the value as aStringfrom 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.inthashCode()booleanPredicate the value of given path is aBoolean.@Nullable BooleanPredicate the value of given path is aByte.booleanPredicate the value of given path is aCharacter.booleanPredicate the value of given path is aDouble.booleanisEmpty()Gets if this section is empty.booleanPredicate the value of given path is aFloat.booleanPredicate the value of given path is aInteger.booleanPredicate the value of given path is aList.booleanPredicate the value of given path is aLong.FbooleanisRoot()Gets if this section is a root section.booleanPredicate the value of given path is aConfigureSection.booleanPredicate the value of given path is aShort.booleanPredicate the value of given path is aString.<T> booleanPredicate the value of given path is specific type.keys()Gets a set containing all primary keys in this section.static ImmutableSectionof(@NotNull ConfigureSection section) @Nullable ImmutableSectionparent()Gets the parent section of this section.@NotNull Stringpath()Get the current section's path fromConfigureSection.parent()of this section.charGet the path separator for the section.voidRemoves the value at the given path.voidSets the value at the given path.stream()Create a stream of all values in this section.@NotNull Stream<?> Get the specific type of steam from current section.<T> @NotNull Stream<T> Get the specific type of steam from current section.values()Gets a set containing all key-values in this section.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface cc.carm.lib.configuration.source.section.ConfigureSection
computeSection, computeSection, computeSection, computeSection, createSection, createSection, createSection, fullPath, size
-
Field Details
-
parent
-
raw
-
-
Method Details
-
of
-
parent
Description copied from interface:ConfigureSectionGets the parent section of this section.For root sections, this will return null.
- Specified by:
parentin interfaceConfigureSection- Returns:
- Parent section, or null if this is a root section.
-
path
Description copied from interface:ConfigureSectionGet the current section's path fromConfigureSection.parent()of this section.- Specified by:
pathin interfaceConfigureSection- Returns:
- The current path of this section, if
ConfigureSection.isRoot(), return empty string.
-
getValues
Description copied from interface:ConfigureSectionGets a set containing all values in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSections (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.
- Specified by:
getValuesin interfaceConfigureSection- Parameters:
deep- Whether to get a deep list.- Returns:
- Map of data values contained within this Section.
-
set
Description copied from interface:ConfigureSectionSets the value at the given path.Null values will be kept, if you want to remove a value use
ConfigureSection.remove(String)Path separator depends on holder'sStandardOptions.PATH_SEPARATOR- Specified by:
setin interfaceConfigureSection- Parameters:
path- The path to set the value at.value- The value to set.
-
remove
Description copied from interface:ConfigureSectionRemoves the value at the given path.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR- Specified by:
removein interfaceConfigureSection- Parameters:
path- The path to remove the value at.
-
createSection
@NotNull public @NotNull ImmutableSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Map<?, ?> data) Description copied from interface:ConfigureSectionCreates a newConfigureSectionwith specified values.The
ConfigureSection.parent()of the new section will be this section.This section will not be saved until
ConfigureSection.set(String, Object)is called.If you want to create and use a section and set it to this section, use
ConfigureSection.computeSection(String).- Specified by:
createSectionin interfaceConfigureSection- Parameters:
data- The data to be used to create section.- Returns:
- Newly created section
-
get
Description copied from interface:ConfigureSectionGet the origin value of the path.- Specified by:
getin interfaceConfigureSection- Parameters:
path- The path to get the value from.- Returns:
- The value at the path, or null if not found.
-
getSection
Description copied from interface:ConfigureSectionGet the value as aConfigureSectionfrom the specified path.- Specified by:
getSectionin interfaceConfigureSection- Parameters:
path- The path to get the section.- Returns:
- The section if the path exists and is a section, otherwise null.
-
pathSeparator
public char pathSeparator()Description copied from interface:ConfigureSectionGet the path separator for the section.- Specified by:
pathSeparatorin interfaceConfigureSection- Returns:
- The path separator
-
isRoot
public boolean isRoot()Description copied from interface:ConfigureSectionGets if this section is a root section.- Specified by:
isRootin interfaceConfigureSection- Returns:
- True if this section is a root section, false otherwise.
-
isEmpty
public boolean isEmpty()Description copied from interface:ConfigureSectionGets if this section is empty.- Specified by:
isEmptyin interfaceConfigureSection- Returns:
- True if this section is empty, false otherwise.
-
getKeys
Description copied from interface:ConfigureSectionGets a set containing all keys in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSections (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.
- Specified by:
getKeysin interfaceConfigureSection- Parameters:
deep- Whether to get a deep list.- Returns:
- Set of keys contained within this Section.
-
keys
Description copied from interface:ConfigureSectionGets a set containing all primary keys in this section.- Specified by:
keysin interfaceConfigureSection- Returns:
- Set of keys contained within this Section.
-
values
Description copied from interface:ConfigureSectionGets a set containing all key-values in this section.- Specified by:
valuesin interfaceConfigureSection- Returns:
- Map of data values contained within this Section.
- See Also:
-
asMap
Description copied from interface:ConfigureSectionGet this section as a map.In this map, child
ConfigureSections will also be represented asMaps.- Specified by:
asMapin interfaceConfigureSection- Returns:
- Map of data values contained within this Section.
-
stream
Description copied from interface:ConfigureSectionCreate a stream of all values in this section.- Specified by:
streamin interfaceConfigureSection- Returns:
- Stream of all values in this section.
-
forEach
Description copied from interface:ConfigureSectionIterates over all key-values in this section (include child sections)- Specified by:
forEachin interfaceConfigureSection- Parameters:
action- The action to apply to each key.
-
contains
Description copied from interface:ConfigureSectionCheck if the given path is present.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR- Specified by:
containsin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present, false otherwise.
-
containsValue
Description copied from interface:ConfigureSectionCheck if the value of given path is present.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR- Specified by:
containsValuein interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present, false otherwise.
-
isType
Description copied from interface:ConfigureSectionPredicate the value of given path is specific type.- Specified by:
isTypein interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aList.- Specified by:
isListin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a list, false otherwise.
-
getList
Description copied from interface:ConfigureSectionGet the value as aListfrom the specified path.- Specified by:
getListin interfaceConfigureSection- Parameters:
path- The path to get theList.- Returns:
- The list if the path exists and is a list, otherwise null.
-
isSection
Description copied from interface:ConfigureSectionPredicate the value of given path is aConfigureSection.- Specified by:
isSectionin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a section, false otherwise.
-
get
Description copied from interface:ConfigureSectionGet the value of the path for specific type, if the path does not exist, return null.- Specified by:
getin interfaceConfigureSection- 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 public <T> T get(@NotNull @NotNull String path, @NotNull @NotNull DataFunction<@Nullable Object, T> parser) Description copied from interface:ConfigureSectionGet the value of the path using a parser function, if the path does not exist, return NULL.- Specified by:
getin interfaceConfigureSection- 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
@Nullable public <T> T get(@NotNull @NotNull String path, T defaults, @NotNull @NotNull Class<T> clazz) Description copied from interface:ConfigureSectionGet the value of the path for specific type, if the path does not exist, return the default value.- Specified by:
getin interfaceConfigureSection- 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
@Nullable public <T> T get(@NotNull @NotNull String path, T defaultValue, @NotNull @NotNull DataFunction<Object, T> parser) Description copied from interface:ConfigureSectionGet the value of the path using a parser function, if the path does not exist, return the default value.- Specified by:
getin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aBoolean.- Specified by:
isBooleanin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a boolean, false otherwise.
-
getBoolean
Description copied from interface:ConfigureSectionGet the value as aBooleanfrom the specified path.- Specified by:
getBooleanin interfaceConfigureSection- Parameters:
path- The path to get the boolean.- Returns:
- The boolean if the path exists and is a boolean, otherwise false.
-
getBoolean
@Nullable public @Nullable Boolean getBoolean(@NotNull @NotNull String path, @Nullable @Nullable Boolean def) Description copied from interface:ConfigureSectionGet the value as aBooleanfrom the specified path.- Specified by:
getBooleanin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aByte.- Specified by:
isBytein interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a byte, false otherwise.
-
getByte
Description copied from interface:ConfigureSectionGet the value as aBytefrom the specified path.- Specified by:
getBytein interfaceConfigureSection- Parameters:
path- The path to get the byte.- Returns:
- The byte if the path exists and is a byte, otherwise 0.
-
getByte
@Nullable public @Nullable Byte getByte(@NotNull @NotNull String path, @Nullable @Nullable Byte def) Description copied from interface:ConfigureSectionGet the value as aBytefrom the specified path.- Specified by:
getBytein interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aShort.- Specified by:
isShortin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a short, false otherwise.
-
getShort
Description copied from interface:ConfigureSectionGet the value as aShortfrom the specified path.- Specified by:
getShortin interfaceConfigureSection- Parameters:
path- The path to get the short.- Returns:
- The short if the path exists and is a short, otherwise 0.
-
getShort
@Nullable public @Nullable Short getShort(@NotNull @NotNull String path, @Nullable @Nullable Short def) Description copied from interface:ConfigureSectionGet the value as aShortfrom the specified path.- Specified by:
getShortin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aInteger.- Specified by:
isIntin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is an int, false otherwise.
-
getInt
Description copied from interface:ConfigureSectionGet the value as aIntegerfrom the specified path.- Specified by:
getIntin interfaceConfigureSection- Parameters:
path- The path to get the int.- Returns:
- The int if the path exists and is an int, otherwise 0.
-
getInt
@Nullable public @Nullable Integer getInt(@NotNull @NotNull String path, @Nullable @Nullable Integer def) Description copied from interface:ConfigureSectionGet the value as aIntegerfrom the specified path.- Specified by:
getIntin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aLong.F- Specified by:
isLongin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a long, false otherwise.
-
getLong
Description copied from interface:ConfigureSectionGet the value as aLongfrom the specified path.- Specified by:
getLongin interfaceConfigureSection- Parameters:
path- The path to get the long.- Returns:
- The long if the path exists and is a long, otherwise 0.
-
getLong
@Nullable public @Nullable Long getLong(@NotNull @NotNull String path, @Nullable @Nullable Long def) Description copied from interface:ConfigureSectionGet the value as aLongfrom the specified path.- Specified by:
getLongin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aFloat.- Specified by:
isFloatin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a float, false otherwise.
-
getFloat
Description copied from interface:ConfigureSectionGet the value as aFloatfrom the specified path.- Specified by:
getFloatin interfaceConfigureSection- Parameters:
path- The path to get the float.- Returns:
- The float if the path exists and is a float, otherwise 0.
-
getFloat
@Nullable public @Nullable Float getFloat(@NotNull @NotNull String path, @Nullable @Nullable Float def) Description copied from interface:ConfigureSectionGet the value as aFloatfrom the specified path.- Specified by:
getFloatin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aDouble.- Specified by:
isDoublein interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a double, false otherwise.
-
getDouble
Description copied from interface:ConfigureSectionGet the value as aDoublefrom the specified path.- Specified by:
getDoublein interfaceConfigureSection- Parameters:
path- The path to get the double.- Returns:
- The double if the path exists and is a double, otherwise 0.
-
getDouble
@Nullable public @Nullable Double getDouble(@NotNull @NotNull String path, @Nullable @Nullable Double def) Description copied from interface:ConfigureSectionGet the value as aDoublefrom the specified path.- Specified by:
getDoublein interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aCharacter.- Specified by:
isCharin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a char, false otherwise.
-
getChar
Description copied from interface:ConfigureSectionGet the value as aCharacterfrom the specified path.- Specified by:
getCharin interfaceConfigureSection- Parameters:
path- The path to get the char.- Returns:
- The char if the path exists and is a char, otherwise null.
-
getChar
@Nullable public @Nullable Character getChar(@NotNull @NotNull String path, @Nullable @Nullable Character def) Description copied from interface:ConfigureSectionGet the value as aCharacterfrom the specified path.- Specified by:
getCharin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionPredicate the value of given path is aString.- Specified by:
isStringin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present and is a string, false otherwise.
-
getString
Description copied from interface:ConfigureSectionGet the value as aStringfrom the specified path.- Specified by:
getStringin interfaceConfigureSection- Parameters:
path- The path to get the string.- Returns:
- The string if the path exists and is a string, otherwise null.
-
getString
@Nullable public @Nullable String getString(@NotNull @NotNull String path, @Nullable @Nullable String def) Description copied from interface:ConfigureSectionGet the value as aStringfrom the specified path.- Specified by:
getStringin interfaceConfigureSection- 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 public <V> @NotNull List<V> getList(@NotNull @NotNull String path, @NotNull @NotNull DataFunction<Object, V> parser) Description copied from interface:ConfigureSectionGet a list of values from current sectionIf the path does not exist, an empty list will be returned
Any changes please useConfigureSection.set(String, Object)after changes- Specified by:
getListin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionGet a list of strings from current sectionLimitations see
ConfigureSection.getList(String, DataFunction)- Specified by:
getStringListin interfaceConfigureSection- Parameters:
path- The path to get the list from- Returns:
- The list of strings
-
getIntegerList
Description copied from interface:ConfigureSectionGet a list of integer from current sectionLimitations see
ConfigureSection.getList(String, DataFunction)- Specified by:
getIntegerListin interfaceConfigureSection- Parameters:
path- The path to get the list from- Returns:
- The list of int values
-
getLongList
Description copied from interface:ConfigureSectionGet a list of long from current sectionLimitations see
ConfigureSection.getList(String, DataFunction)- Specified by:
getLongListin interfaceConfigureSection- Parameters:
path- The path to get the list from- Returns:
- The list of long values
-
getDoubleList
Description copied from interface:ConfigureSectionGet a list of double from current sectionLimitations see
ConfigureSection.getList(String, DataFunction)- Specified by:
getDoubleListin interfaceConfigureSection- Parameters:
path- The path to get the list from- Returns:
- The list of doubles
-
getFloatList
Description copied from interface:ConfigureSectionGet a list of floats from current sectionLimitations see
ConfigureSection.getList(String, DataFunction)- Specified by:
getFloatListin interfaceConfigureSection- Parameters:
path- The path to get the list from- Returns:
- The list of floats
-
getByteList
Description copied from interface:ConfigureSectionGet a list of bytes from current sectionLimitations see
ConfigureSection.getList(String, DataFunction)- Specified by:
getByteListin interfaceConfigureSection- Parameters:
path- The path to get the list from- Returns:
- The list of bytes
-
getCharList
Description copied from interface:ConfigureSectionGet a list of char from current sectionLimitations see
ConfigureSection.getList(String, DataFunction)- Specified by:
getCharListin interfaceConfigureSection- Parameters:
path- The path to get the list from- Returns:
- The list of char
-
getSectionList
Description copied from interface:ConfigureSectionGet a list ofConfigureSectionfrom current section- Specified by:
getSectionListin interfaceConfigureSection- Parameters:
path- The path to get the list from- Returns:
- The list of
ConfigureSection
-
getCollection
@NotNull public <T,C extends Collection<T>> C getCollection(@NotNull @NotNull String path, @NotNull @NotNull Supplier<C> constructor, @NotNull @NotNull DataFunction<Object, T> parser) Description copied from interface:ConfigureSectionGet the specific type of collection from current section.- Specified by:
getCollectionin interfaceConfigureSection- 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
Description copied from interface:ConfigureSectionGet the specific type of steam from current section.- Specified by:
streamin interfaceConfigureSection- Parameters:
path- The path to get the stream from- Returns:
- The stream of values
-
stream
@NotNull public <T> @NotNull Stream<T> stream(@NotNull @NotNull String path, @NotNull @NotNull Function<Object, T> parser) Description copied from interface:ConfigureSectionGet the specific type of steam from current section.- Specified by:
streamin interfaceConfigureSection- 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
- Specified by:
childPathin interfaceConfigureSection
-
hashCode
public int hashCode() -
equals
-