Package com.cedarsoftware.util
Class SealableNavigableMap<K,V>
java.lang.Object
com.cedarsoftware.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) void
clear()
Comparator<? super K>
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
firstKey()
floorEntry
(K key) int
hashCode()
higherEntry
(K key) boolean
isEmpty()
keySet()
lastKey()
lowerEntry
(K key) void
int
size()
toString()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
size
public int size() -
get
-
comparator
- Specified by:
comparator
in interfaceSortedMap<K,
V>
-
firstKey
-
lastKey
-
keySet
-
values
-
entrySet
-
lowerEntry
- Specified by:
lowerEntry
in interfaceNavigableMap<K,
V>
-
lowerKey
- Specified by:
lowerKey
in interfaceNavigableMap<K,
V>
-
floorEntry
- Specified by:
floorEntry
in interfaceNavigableMap<K,
V>
-
floorKey
- Specified by:
floorKey
in interfaceNavigableMap<K,
V>
-
ceilingEntry
- Specified by:
ceilingEntry
in interfaceNavigableMap<K,
V>
-
ceilingKey
- Specified by:
ceilingKey
in interfaceNavigableMap<K,
V>
-
higherEntry
- Specified by:
higherEntry
in interfaceNavigableMap<K,
V>
-
higherKey
- Specified by:
higherKey
in interfaceNavigableMap<K,
V>
-
firstEntry
- Specified by:
firstEntry
in interfaceNavigableMap<K,
V>
-
lastEntry
- Specified by:
lastEntry
in interfaceNavigableMap<K,
V>
-
descendingMap
- Specified by:
descendingMap
in interfaceNavigableMap<K,
V>
-
descendingKeySet
- Specified by:
descendingKeySet
in interfaceNavigableMap<K,
V>
-
subMap
-
subMap
- Specified by:
subMap
in interfaceNavigableMap<K,
V>
-
headMap
-
headMap
- Specified by:
headMap
in interfaceNavigableMap<K,
V>
-
tailMap
-
tailMap
- Specified by:
tailMap
in interfaceNavigableMap<K,
V>
-
pollFirstEntry
- Specified by:
pollFirstEntry
in interfaceNavigableMap<K,
V>
-
pollLastEntry
- Specified by:
pollLastEntry
in interfaceNavigableMap<K,
V>
-
put
-
remove
-
putAll
-
clear
public void clear()
-