Class AbstractConcurrentNullSafeMap<K,V>
java.lang.Object
com.cedarsoftware.util.AbstractConcurrentNullSafeMap<K,V>
- Type Parameters:
K- The type of keys maintained by this mapV- The type of mapped values
- All Implemented Interfaces:
ConcurrentMap<K,,V> Map<K,V>
- Direct Known Subclasses:
ConcurrentHashMapNullSafe,ConcurrentNavigableMapNullSafe
public abstract class AbstractConcurrentNullSafeMap<K,V>
extends Object
implements ConcurrentMap<K,V>
AbstractConcurrentNullSafeMap is an abstract class that provides a thread-safe implementation
of ConcurrentMap and Map interfaces, allowing null keys and null values by using sentinel objects internally.
- Author:
- John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enum -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConcurrentNullSafeMap(ConcurrentMap<Object, Object> internalMap) Constructs a new AbstractConcurrentNullSafeMap with the provided internal map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanOverrides the equals method to ensure proper comparison between two maps.getOrDefault(Object key, V defaultValue) inthashCode()Overrides the hashCode method to ensure consistency with equals.booleanisEmpty()keySet()protected ObjectmaskNullKey(K key) protected ObjectmaskNullValue(V value) voidputIfAbsent(K key, V value) booleanbooleanintsize()toString()Overrides the toString method to provide a string representation of the map.protected KunmaskNullKey(Object key) protected VunmaskNullValue(Object value) values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.ConcurrentMap
computeIfPresent, forEach, replaceAll
-
Field Details
-
internalMap
-
-
Constructor Details
-
AbstractConcurrentNullSafeMap
Constructs a new AbstractConcurrentNullSafeMap with the provided internal map.- Parameters:
internalMap- the internal ConcurrentMap to use
-
-
Method Details
-
maskNullKey
-
unmaskNullKey
-
maskNullValue
-
unmaskNullValue
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
put
-
remove
-
putAll
-
clear
-
getOrDefault
- Specified by:
getOrDefaultin interfaceConcurrentMap<K,V> - Specified by:
getOrDefaultin interfaceMap<K,V>
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
putIfAbsentin interfaceMap<K,V>
-
remove
-
replace
-
replace
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
computeIfAbsentin interfaceMap<K,V>
-
compute
-
merge
-
values
-
keySet
-
entrySet
-
equals
Overrides the equals method to ensure proper comparison between two maps. Two maps are considered equal if they contain the same key-value mappings. -
hashCode
public int hashCode()Overrides the hashCode method to ensure consistency with equals. The hash code of a map is defined to be the sum of the hash codes of each entry in the map. -
toString
Overrides the toString method to provide a string representation of the map. The string representation consists of a list of key-value mappings in the order returned by the map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space).
-