java.lang.Object
java.util.AbstractMap<String,LinkedHashMap<String,String>>
java.util.HashMap<String,LinkedHashMap<String,String>>
java.util.LinkedHashMap<String,LinkedHashMap<String,String>>
org.miaixz.bus.setting.magic.GroupedMap
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,,LinkedHashMap<String, String>> SequencedMap<String,LinkedHashMap<String, String>>
A thread-safe, group-based map implementation, extending
LinkedHashMap. It organizes key-value pairs into
named groups, where each group is a LinkedHashMap<String, String>.- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClears all key-value pairs from a specific group.booleancontainsKey(String group, String key) Checks if a specific group contains a given key.booleancontainsValue(String group, String value) Checks if a specific group contains a given value.entrySet()Returns a set of all key-value entries within a specific group.get(CharSequence group, CharSequence key) Gets a value for a given key within a specific group.booleanisEmpty()Checks if this grouped map contains any key-value pairs across all groups.booleanChecks if a specific group is empty.keySet()Returns a set of all keys within a specific group.Puts a key-value pair into a specific group.Puts all key-value pairs from a map into a specific group.Removes a key-value pair from a specific group.intsize()Returns the total number of key-value pairs across all groups.toString()Returns a collection of all values within a specific group.Methods inherited from class java.util.LinkedHashMap
clear, containsValue, forEach, getOrDefault, newLinkedHashMap, putFirst, putLast, removeEldestEntry, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replaceMethods inherited from class java.util.AbstractMap
equals, hashCodeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, merge, put, putAll, putIfAbsent, remove, remove, replace, replaceMethods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Constructor Details
-
GroupedMap
public GroupedMap()
-
-
Method Details
-
get
Gets a value for a given key within a specific group.- Parameters:
group- The group name.key- The key within the group.- Returns:
- The value, or null if the group or key does not exist.
-
get
- Specified by:
getin interfaceMap<String,LinkedHashMap<String, String>> - Overrides:
getin classLinkedHashMap<String,LinkedHashMap<String, String>>
-
size
public int size()Returns the total number of key-value pairs across all groups. -
put
Puts a key-value pair into a specific group.- Parameters:
group- The group name. If null or empty, the default group is used.key- The key.value- The value.- Returns:
- The previous value associated with the key, or null if there was none.
-
putAll
Puts all key-value pairs from a map into a specific group.- Parameters:
group- The group name.m- The map of key-value pairs to add.- Returns:
- This
GroupedMapinstance.
-
remove
Removes a key-value pair from a specific group.- Parameters:
group- The group name.key- The key to remove.- Returns:
- The value that was removed, or null if the key was not found.
-
isEmpty
Checks if a specific group is empty.- Parameters:
group- The group name.- Returns:
trueif the group does not exist or has no entries.
-
isEmpty
public boolean isEmpty()Checks if this grouped map contains any key-value pairs across all groups. -
containsKey
Checks if a specific group contains a given key.- Parameters:
group- The group name.key- The key to check for.- Returns:
trueif the key exists in the group.
-
containsValue
Checks if a specific group contains a given value.- Parameters:
group- The group name.value- The value to check for.- Returns:
trueif the value exists in the group.
-
clear
Clears all key-value pairs from a specific group.- Parameters:
group- The group name to clear.- Returns:
- This
GroupedMapinstance.
-
keySet
- Specified by:
keySetin interfaceMap<String,LinkedHashMap<String, String>> - Overrides:
keySetin classLinkedHashMap<String,LinkedHashMap<String, String>>
-
keySet
Returns a set of all keys within a specific group.- Parameters:
group- The group name.- Returns:
- The set of keys.
-
values
Returns a collection of all values within a specific group.- Parameters:
group- The group name.- Returns:
- The collection of values.
-
entrySet
- Specified by:
entrySetin interfaceMap<String,LinkedHashMap<String, String>> - Overrides:
entrySetin classLinkedHashMap<String,LinkedHashMap<String, String>>
-
entrySet
Returns a set of all key-value entries within a specific group.- Parameters:
group- The group name.- Returns:
- The set of entries.
-
toString
- Overrides:
toStringin classAbstractMap<String,LinkedHashMap<String, String>>
-