Package com.cedarsoftware.util
Class TrackingMap<K,V>
- java.lang.Object
-
- com.cedarsoftware.util.TrackingMap<K,V>
-
- All Implemented Interfaces:
Map<K,V>
public class TrackingMap<K,V> extends Object implements Map<K,V>
TrackingMap- Author:
- Sean Kellner
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
http://www.apache.org/licenses/LICENSE-2.0
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.
-
-
Constructor Summary
Constructors Constructor Description TrackingMap(Map<K,V> map)
Wrap the passed in Map with a TrackingMap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<K,V>>
entrySet()
boolean
equals(Object other)
void
expungeUnused()
Remove the entries from the Map that have not been accessed by .get() or .containsKey().V
get(Object key)
Map
getWrappedMap()
Fetch the Map that this TrackingMap wraps.int
hashCode()
void
informAdditionalUsage(TrackingMap<K,V> additional)
Add the used keys from the passed in TrackingMap to this TrackingMap's keysUsed.void
informAdditionalUsage(Collection<K> additional)
Add the Collection of keys to the internal list of keys accessed.boolean
isEmpty()
Set<K>
keySet()
Set<K>
keysUsed()
Fetch the Set of keys that have been accessed via .get() or .containsKey() of the contained Map.V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
remove(Object key)
int
size()
String
toString()
Collection<V>
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
-
-
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
-
equals
public boolean equals(Object other)
-
hashCode
public int hashCode()
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
-
expungeUnused
public void expungeUnused()
Remove the entries from the Map that have not been accessed by .get() or .containsKey().
-
informAdditionalUsage
public void informAdditionalUsage(Collection<K> additional)
Add the Collection of keys to the internal list of keys accessed. If there are keys in the passed in Map that are not included in the contained Map, the readKeys will exceed the keySet() of the wrapped Map.- Parameters:
additional
- Collection of keys to add to the list of keys read.
-
informAdditionalUsage
public void informAdditionalUsage(TrackingMap<K,V> additional)
Add the used keys from the passed in TrackingMap to this TrackingMap's keysUsed. This can cause the readKeys to include entries that are not in wrapped Maps keys.- Parameters:
additional
- TrackingMap whose used keys are to be added to this maps used keys.
-
keysUsed
public Set<K> keysUsed()
Fetch the Set of keys that have been accessed via .get() or .containsKey() of the contained Map.- Returns:
- Set of the accessed (read) keys.
-
getWrappedMap
public Map getWrappedMap()
Fetch the Map that this TrackingMap wraps.- Returns:
- Map the wrapped Map
-
-