Package com.saicone.settings
Class Settings
java.lang.Object
com.saicone.settings.node.NodeValue<Map<String,SettingsNode>>
com.saicone.settings.node.NodeKey<Map<String,SettingsNode>>
com.saicone.settings.node.MapNode
com.saicone.settings.Settings
- All Implemented Interfaces:
SettingsNode,com.saicone.types.AnyObject<Object>,Iterable<Map.Entry<String,,SettingsNode>> Map<String,SettingsNode>
Class that represent flexible configuration itself.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.saicone.types.AnyObject
com.saicone.types.AnyObject.Registry -
Constructor Summary
ConstructorsConstructorDescriptionSettings()Constructs an empty settings object.
By default, key insertion order will be maintained.Settings(@Nullable SettingsMemory memory) Constructs an empty settings object with given memory.
By default, key insertion order will be maintained.Settings(@NotNull Map<String, SettingsNode> nodes) Constructs a settings object with the given map type.Settings(@NotNull Map<String, SettingsNode> nodes, @Nullable SettingsMemory memory) Constructs a settings with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Get the node associated with the given key.Get the node associated with the given key path.getIgnoreCase(@NotNull String key) Get the node associated with the given key ignoring case considerations.getIgnoreCase(@NotNull String... path) Get the node associated with the given key path ignoring case considerations.Get the instance that save path ids.Get the node whose key matches with given regex expression.
Instead ofMapNode.get(String)orMapNode.getIgnoreCase(String)this method may create a new node without any defined key.Get the node whose key path matches with given regex expressions.
Instead ofMapNode.get(String...)orMapNode.getIgnoreCase(String...)this method may create a new node without any defined key.booleanCheck if the settings instance is memorizing node path ids.protected voidremove(@NotNull SettingsNode node) Executed method when any node is deleted by the value itself.protected @NotNull SettingsNodeSave supplier value into memory or get from if it actually exists.Set a regular map memory on this instance.setMemory(@Nullable SettingsMemory memory) Replace the used settings memory on this instance.Methods inherited from class com.saicone.settings.node.MapNode
asJson, asJson, asLiteralObject, child, child, child, child, containsKey, containsValue, deepMerge, deepMerge, edit, entrySet, get, getIf, getIf, getIf, getIfType, getRoot, getSplit, isEmpty, isMap, iterator, keySet, merge, merge, merge, merge, paths, put, put, putAll, remove, removeIf, removeIf, set, setValue, size, valuesMethods inherited from class com.saicone.settings.node.NodeKey
getKey, getParent, of, setKey, setParentMethods inherited from class com.saicone.settings.node.NodeValue
as, as, asCollection, asEnum, asEnum, asOptional, equals, getFaceValue, getSideComment, getSourceValue, getTopComment, getValue, hashCode, hasSideComment, hasTopComment, of, setSideComment, setSourceValue, setTopComment, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.saicone.types.AnyObject
as, as, asArray, asArray, asArray, asArray, asBigDecimal, asBigDecimal, asBigInteger, asBigInteger, asBoolean, asBoolean, asByte, asByte, asChar, asChar, asDouble, asDouble, asFloat, asFloat, asInt, asInt, asList, asLong, asLong, asMap, asMap, asNumber, asNumber, asSet, asShort, asShort, asString, asString, asUniqueId, asUniqueIdMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface com.saicone.settings.SettingsNode
addSideComment, addTopComment, asListNode, asMapNode, asObjectNode, copy, copy, copy, delete, delete, edit, isList, isObject, isReal, isRoot, merge, mergeComment, move, moveRoot, parse, parse, replaceArgs, replaceArgs
-
Constructor Details
-
Settings
public Settings()Constructs an empty settings object.
By default, key insertion order will be maintained. -
Settings
Constructs a settings object with the given map type.- Parameters:
nodes- the map to save nodes into.
-
Settings
Constructs an empty settings object with given memory.
By default, key insertion order will be maintained.- Parameters:
memory- the memory to save node path ids.
-
Settings
public Settings(@NotNull @NotNull Map<String, SettingsNode> nodes, @Nullable @Nullable SettingsMemory memory) Constructs a settings with the given parameters.- Parameters:
nodes- the map to save nodes into.memory- the memory to save node path ids.
-
-
Method Details
-
isMemorizing
public boolean isMemorizing()Check if the settings instance is memorizing node path ids.- Returns:
- true if any memory instance is been used.
-
getMemory
Get the instance that save path ids.- Returns:
- a settings memory instance.
-
get
Description copied from class:MapNodeGet the node associated with the given key. -
get
Description copied from class:MapNodeGet the node associated with the given key path. -
getIgnoreCase
Description copied from class:MapNodeGet the node associated with the given key ignoring case considerations.- Overrides:
getIgnoreCasein classMapNode- Parameters:
key- the node key.- Returns:
- a node from the map or a newly created instead.
-
getIgnoreCase
Description copied from class:MapNodeGet the node associated with the given key path ignoring case considerations.- Overrides:
getIgnoreCasein classMapNode- Parameters:
path- the node path.- Returns:
- a node from any sub map or a newly created instead.
-
getRegex
Description copied from class:MapNodeGet the node whose key matches with given regex expression.
Instead ofMapNode.get(String)orMapNode.getIgnoreCase(String)this method may create a new node without any defined key. -
getRegex
@NotNull public @NotNull SettingsNode getRegex(@NotNull @Language("RegExp") @NotNull String... regexPath) Description copied from class:MapNodeGet the node whose key path matches with given regex expressions.
Instead ofMapNode.get(String...)orMapNode.getIgnoreCase(String...)this method may create a new node without any defined key. -
save
@NotNull protected @NotNull SettingsNode save(@NotNull @NotNull String id, @NotNull @NotNull Supplier<@NotNull SettingsNode> supplier) Save supplier value into memory or get from if it actually exists.- Parameters:
id- the value id.supplier- the supplier to get value.- Returns:
- the value from memory or the newly generated one.
-
setMemory
@NotNull @Contract("_ -> this") public @NotNull Settings setMemory(@Nullable @Nullable SettingsMemory memory) Replace the used settings memory on this instance.- Parameters:
memory- the memory to save queried values.- Returns:
- the effective settings object in this operation, normally this instance.
-
setMapMemory
Set a regular map memory on this instance.- Returns:
- the effective settings object in this operation, normally this instance.
-
remove
Description copied from class:MapNodeExecuted method when any node is deleted by the value itself. -
remove
-
clear
public void clear()
-