Interface MapNode
Node implementation that represents a Map (Object - Node).
The implementing class of this interface keeps the order of keys using LinkedHashMap.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription@NotNull @UnmodifiableView MapNodeasView()Gets a view of thisMapNode.voidclear()Clears thisMapNode.@NotNull MapNodecopy()Copies thisMapNode.static @NotNull MapNodecreate()Creates a newMapNode.static @NotNull MapNode@NotNull ListNodecreateList(@NotNull Object key) Creates a newListNodeand set it to the specified key.@NotNull @Unmodifiable MapNodeCreates a newMapNodeand set it to the specified key.static @NotNull MapNodeempty()Gets aMapNodethat is always empty.default @NotNull Node<?>Gets aNodeto which the specified key is mapped, orNullNode.NULLif thisMapNodecontains no mapping for the key.default booleangetBoolean(@NotNull Object key) Gets the boolean value to which the specified key is mapped, orfalse.default booleangetBoolean(@NotNull Object key, boolean def) Gets the boolean value to which the specified key is mapped, or the specified boolean value.default byteGets the byte value to which the specified key is mapped, or0.default byteGets the byte value to which the specified key is mapped, or the specified byte value.default charGets the char value to which the specified key is mapped, orfalse.default charGets the char value to which the specified key is mapped, or the specified char value.default doubleGets the double value to which the specified key is mapped, or0.default doubleGets the double value to which the specified key is mapped, or the specified double value.default <E extends Enum<E>>
Edefault <E extends Enum<E>>
Edefault floatGets the float value to which the specified key is mapped, or0.default floatGets the float value to which the specified key is mapped, or the specified float value.default intgetInteger(@NotNull Object key) Gets the int value to which the specified key is mapped, or0.default intgetInteger(@NotNull Object key, int def) Gets the int value to which the specified key is mapped, or the specified int value.default @NotNull @UnmodifiableView ListNodeGets theListNodeto which the specified key is mapped.default longGets the long value to which the specified key is mapped, or0.default longGets the long value to which the specified key is mapped, or the specified long value.default @NotNull @Unmodifiable MapNodeGets theMapNodeto which the specified key is mapped.default @NotNull ListNodegetOrCreateList(@NotNull Object key) Gets theListNodeto which the specified key is mapped, or creates a newListNodeusingcreateList(Object).default @NotNull MapNodegetOrCreateMap(@NotNull Object key) Gets theMapNodeto which the specified key is mapped, or creates a newMapNodeusingcreateMap(Object).@NotNull Node<?>getOrDefault(@NotNull Object key, @NotNull Node<?> defaultNode) default shortGets the short value to which the specified key is mapped, or0.default shortGets the short value to which the specified key is mapped, or the specified short value.default @NotNull Stringdefault @NotNull StringGets theStringvalue to which the specified key is mapped, or the specified value.default @Nullable StringgetStringOrNull(@NotNull Object key) Gets theStringvalue to which the specified key is mapped, ornull.@NotNull Node<?>Sets aNodeto the specified key.@Nullable Node<?>setIfAbsent(@NotNull Object key, @NotNull Object value) value()Gets an object which thisNodeholdsMethods inherited from interface com.github.siroshun09.configapi.core.node.CommentableNode
getComment, getCommentOrNull, hasComment, setCommentMethods inherited from interface com.github.siroshun09.configapi.core.node.Node
accept, asOptional, hasValue
-
Field Details
-
IMPLEMENTATION_CLASS
An implementationClassof this interface.
-
-
Method Details
-
create
Creates a newMapNode.- Returns:
- a new
MapNode
-
create
-
empty
Gets aMapNodethat is always empty.The returning
MapNodecannot be modified using methods likeset(Object, Object).- Returns:
- a
MapNodethat is always empty
-
value
Description copied from interface:NodeGets an object which thisNodeholds -
get
Gets aNodeto which the specified key is mapped, orNullNode.NULLif thisMapNodecontains no mapping for the key.- Parameters:
key- the key to get- Returns:
- a
Nodeto which the specified key is mapped, orNullNode.NULLif thisMapNodecontains no mapping for the key
-
getOrDefault
@NotNull @NotNull Node<?> getOrDefault(@NotNull @NotNull Object key, @NotNull @NotNull Node<?> defaultNode) -
set
Sets aNodeto the specified key.If
nullis specified as value, the key will be removed from the map.- Parameters:
key- the key to setvalue- the value to set, ornullif removing the key- Returns:
- the
Nodeto which the specified key is mapped previously, orNullNode.NULLif the key is not mapped
-
setIfAbsent
@Nullable @Nullable Node<?> setIfAbsent(@NotNull @NotNull Object key, @NotNull @NotNull Object value) - Parameters:
key- the key to setvalue- the value to set- Returns:
- the
Nodeto which the specified key is mapped previously, ornullif the key is not mapped
-
clear
void clear()Clears thisMapNode. -
copy
Copies thisMapNode.The entries in this
MapNodewill also be copied usingNode.fromObject(Object).- Returns:
- a copied
MapNode
-
asView
Gets a view of thisMapNode.The returning
MapNodecannot be modified, but thisMapNodecan still be modified, so the entries may be changed by other codes using this instance.- Returns:
- a view of this
MapNode
-
getList
Gets theListNodeto which the specified key is mapped.The returning
ListNodeis a view, so it cannot be modified. To modifyListNode, usegetOrCreateList(Object).- Parameters:
key- the key to get- Returns:
- the view of
ListNodeto which the specified key is mapped, orListNode.empty()if the key is not mapped
-
createList
Creates a newListNodeand set it to the specified key.The
Nodeto which the specified key is mapped previously will be removed.- Parameters:
key- the key to set- Returns:
- a new
ListNodeto which the specified key is mapped
-
getOrCreateList
Gets theListNodeto which the specified key is mapped, or creates a newListNodeusingcreateList(Object).- Parameters:
key- the key to get- Returns:
- the
ListNodeto which the specified key is mapped, orcreateList(Object)if the key is not mapped
-
getMap
Gets theMapNodeto which the specified key is mapped.The returning
MapNodeis a view, so it cannot be modified. To modifyMapNode, usegetOrCreateMap(Object). -
createMap
Creates a newMapNodeand set it to the specified key.The
Nodeto which the specified key is mapped previously will be removed.- Parameters:
key- the key to set- Returns:
- a new
MapNodeto which the specified key is mapped
-
getOrCreateMap
Gets theMapNodeto which the specified key is mapped, or creates a newMapNodeusingcreateMap(Object).- Parameters:
key- the key to get- Returns:
- the
MapNodeto which the specified key is mapped, orcreateMap(Object)if the key is not mapped toMapNode
-
getString
- Parameters:
key- the key to get- Returns:
- the
Stringto which the specified key is mapped, or an emptyStringif the key is not mapped toStringValue
-
getString
@NotNull default @NotNull String getString(@NotNull @NotNull Object key, @NotNull @NotNull String def) Gets theStringvalue to which the specified key is mapped, or the specified value.- Parameters:
key- the key to getdef- the default value- Returns:
- the
Stringto which the specified key is mapped, or the specified value if the key is not mapped toStringValue
-
getStringOrNull
Gets theStringvalue to which the specified key is mapped, ornull.- Parameters:
key- the key to get- Returns:
- the
Stringto which the specified key is mapped, ornullif the key is not mapped toStringValue
-
getEnum
Gets theEnumvalue or parsesStringValuetoEnum.This method is implemented with the following specification:
- The
Nodeto which the specified key is mapped isEnumValueand it is appropriate the specified type of the enum, returnsEnumValue.value() -
The
Nodeto which the specified key is mapped isStringValue, try to parse the string toEnumusingEnum.valueOf(Class, String)- If the string value is invalid, returns the specified value
- Otherwise, returns the specified value
- The
-
getEnum
@Nullable default <E extends Enum<E>> E getEnum(@NotNull @NotNull Object key, @NotNull @NotNull Class<E> enumClass) Gets theEnumvalue or parsesStringValuetoEnum.This method is implemented with the following specification:
- The
Nodeto which the specified key is mapped isEnumValueand it is appropriate the specified type of the enum, returnsEnumValue.value() -
The
Nodeto which the specified key is mapped isStringValue, try to parse the string toEnumusingEnum.valueOf(Class, String)- If the string value is invalid, returns
null
- If the string value is invalid, returns
- Otherwise, returns
null
- The
-
getBoolean
Gets the boolean value to which the specified key is mapped, orfalse.- Parameters:
key- the key to get- Returns:
- the boolean value to which the specified key is mapped, or
falseif the key is not mapped toBooleanValue
-
getBoolean
Gets the boolean value to which the specified key is mapped, or the specified boolean value.- Parameters:
key- the key to getdef- the default value- Returns:
- the boolean value to which the specified key is mapped, or the specified value if the key is not mapped to
BooleanValue
-
getInteger
Gets the int value to which the specified key is mapped, or0.- Parameters:
key- the key to get- Returns:
- the int value to which the specified key is mapped, or
0if the key is not mapped toNumberValue
-
getInteger
Gets the int value to which the specified key is mapped, or the specified int value.- Parameters:
key- the key to getdef- the default value- Returns:
- the int value to which the specified key is mapped, or the specified value if the key is not mapped to
NumberValue
-
getLong
Gets the long value to which the specified key is mapped, or0.- Parameters:
key- the key to get- Returns:
- the long value to which the specified key is mapped, or
0if the key is not mapped toNumberValue
-
getLong
Gets the long value to which the specified key is mapped, or the specified long value.- Parameters:
key- the key to getdef- the default value- Returns:
- the long value to which the specified key is mapped, or the specified value if the key is not mapped to
NumberValue
-
getFloat
Gets the float value to which the specified key is mapped, or0.- Parameters:
key- the key to get- Returns:
- the float value to which the specified key is mapped, or
0if the key is not mapped toNumberValue
-
getFloat
Gets the float value to which the specified key is mapped, or the specified float value.- Parameters:
key- the key to getdef- the default value- Returns:
- the float value to which the specified key is mapped, or the specified value if the key is not mapped to
NumberValue
-
getDouble
Gets the double value to which the specified key is mapped, or0.- Parameters:
key- the key to get- Returns:
- the double value to which the specified key is mapped, or
0if the key is not mapped toNumberValue
-
getDouble
Gets the double value to which the specified key is mapped, or the specified double value.- Parameters:
key- the key to getdef- the default value- Returns:
- the double value to which the specified key is mapped, or the specified value if the key is not mapped to
NumberValue
-
getByte
Gets the byte value to which the specified key is mapped, or0.- Parameters:
key- the key to get- Returns:
- the byte value to which the specified key is mapped, or
0if the key is not mapped toNumberValue
-
getByte
Gets the byte value to which the specified key is mapped, or the specified byte value.- Parameters:
key- the key to getdef- the default value- Returns:
- the byte value to which the specified key is mapped, or the specified value if the key is not mapped to
NumberValue
-
getShort
Gets the short value to which the specified key is mapped, or0.- Parameters:
key- the key to get- Returns:
- the short value to which the specified key is mapped, or
0if the key is not mapped toNumberValue
-
getShort
Gets the short value to which the specified key is mapped, or the specified short value.- Parameters:
key- the key to getdef- the default value- Returns:
- the short value to which the specified key is mapped, or the specified value if the key is not mapped to
NumberValue
-
getChar
Gets the char value to which the specified key is mapped, orfalse.- Parameters:
key- the key to get- Returns:
- the char value to which the specified key is mapped, or
Character.MIN_VALUEif the key is not mapped toCharValue
-
getChar
Gets the char value to which the specified key is mapped, or the specified char value.- Parameters:
key- the key to getdef- the default value- Returns:
- the char value to which the specified key is mapped, or the specified value if the key is not mapped to
CharValue
-