public class FilterMap<K,V> extends AbstractMap<K,V>
FilterMap.Filter to evaluate the value when the value
is retrieved. Then, encapsulate the original map with this class. For example,
return new FilterMap(map,
new FilterMap.Filter() {
public Object filter(Object key, Object value) {
//evaluate the value and return the result
}
});
Notice that this map is readonly, and it is thread-safe if the give map and the filter are both thread safe.
| Modifier and Type | Class and Description |
|---|---|
static interface |
FilterMap.Filter<V>
Filters the given value (to evaluate when the value is retrieved).
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
FilterMap(Map<K,V> map,
FilterMap.Filter<V> filter) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(Object key) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object o) |
V |
get(Object key) |
Map<K,V> |
getOrigin()
Returns the original map being filtered.
|
int |
hashCode() |
String |
toString() |
clear, clone, containsValue, isEmpty, keySet, put, putAll, remove, size, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic FilterMap(Map<K,V> map, FilterMap.Filter<V> filter)
public Map<K,V> getOrigin()
public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>public String toString()
toString in class AbstractMap<K,V>public int hashCode()
Copyright © 2018. All rights reserved.