Package com.cedarsoftware.io.util
Class SealableNavigableMap<K,V>
java.lang.Object
com.cedarsoftware.io.util.SealableNavigableMap<K,V>
- All Implemented Interfaces:
Map<K,,V> NavigableMap<K,,V> SortedMap<K,V>
SealableNavigableMap provides a NavigableMap or NavigableMap wrapper that can be 'sealed' and 'unsealed.'
When sealed, the Map is mutable, when unsealed it is immutable (read-only). The view methods keySet(), entrySet(),
values(), navigableKeySet(), descendingMap(), descendingKeySet(), subMap(), headMap(), and tailMap() return a view
that honors the Supplier's sealed state. The sealed state can be changed as often as needed.
NOTE: Please do not reformat this code as the current format makes it easy to see the overall structure.
NOTE: Please do not reformat this code as the current format makes it easy to see the overall structure.
- Author:
- John DeRegnaucourt
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
-
Constructor Summary
ConstructorsConstructorDescriptionSealableNavigableMap(Supplier<Boolean> sealedSupplier) Create a SealableNavigableMap.SealableNavigableMap(NavigableMap<K, V> map, Supplier<Boolean> sealedSupplier) Use this constructor to wrap a NavigableMap (any kind of NavigableMap) and make it a SealableNavigableMap.Create a NavigableSealableMap. -
Method Summary
Modifier and TypeMethodDescriptionceilingEntry(K key) ceilingKey(K key) voidclear()Comparator<? super K>booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanfirstKey()floorEntry(K key) inthashCode()higherEntry(K key) booleanisEmpty()keySet()lastKey()lowerEntry(K key) voidintsize()toString()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
SealableNavigableMap
Create a SealableNavigableMap. Since a Map is not supplied, this will use a ConcurrentSkipListMap internally. If you want a TreeMap to be used internally, use the SealableMap constructor that takes a NavigableMap and pass it the instance you want it to wrap.- Parameters:
sealedSupplier-Supplier<Boolean>that returns 'true' to indicate sealed, 'false' for mutable.
-
SealableNavigableMap
Create a NavigableSealableMap. Since NavigableMap is not supplied, the elements from the passed in SortedMap will be copied to an internal ConcurrentSkipListMap. If you want to use a TreeMap for example, use the SealableNavigableMap constructor that takes a NavigableMap and pass it the instance you want it to wrap.- Parameters:
map- SortedMap to supply initial elements. These are copied to an internal ConcurrentSkipListMap.sealedSupplier-Supplier<Boolean>that returns 'true' to indicate sealed, 'false' for mutable.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
size
public int size() -
get
-
comparator
- Specified by:
comparatorin interfaceSortedMap<K,V>
-
firstKey
-
lastKey
-
keySet
-
values
-
entrySet
-
lowerEntry
- Specified by:
lowerEntryin interfaceNavigableMap<K,V>
-
lowerKey
- Specified by:
lowerKeyin interfaceNavigableMap<K,V>
-
floorEntry
- Specified by:
floorEntryin interfaceNavigableMap<K,V>
-
floorKey
- Specified by:
floorKeyin interfaceNavigableMap<K,V>
-
ceilingEntry
- Specified by:
ceilingEntryin interfaceNavigableMap<K,V>
-
ceilingKey
- Specified by:
ceilingKeyin interfaceNavigableMap<K,V>
-
higherEntry
- Specified by:
higherEntryin interfaceNavigableMap<K,V>
-
higherKey
- Specified by:
higherKeyin interfaceNavigableMap<K,V>
-
firstEntry
- Specified by:
firstEntryin interfaceNavigableMap<K,V>
-
lastEntry
- Specified by:
lastEntryin interfaceNavigableMap<K,V>
-
descendingMap
- Specified by:
descendingMapin interfaceNavigableMap<K,V>
-
descendingKeySet
- Specified by:
descendingKeySetin interfaceNavigableMap<K,V>
-
subMap
-
subMap
- Specified by:
subMapin interfaceNavigableMap<K,V>
-
headMap
-
headMap
- Specified by:
headMapin interfaceNavigableMap<K,V>
-
tailMap
-
tailMap
- Specified by:
tailMapin interfaceNavigableMap<K,V>
-
pollFirstEntry
- Specified by:
pollFirstEntryin interfaceNavigableMap<K,V>
-
pollLastEntry
- Specified by:
pollLastEntryin interfaceNavigableMap<K,V>
-
put
-
remove
-
putAll
-
clear
public void clear()
-