Class FilterMap<K,​V>

  • All Implemented Interfaces:

    public class FilterMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    A map that allows the value to be evaluated before returning (so called filtering). For example, if you allow the value to have EL expressions and want to evaluate it before returning, then you could implement 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  FilterMap.Filter<V>
      Filters the given value (to evaluate when the value is retrieved).
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(java.lang.Object key)  
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      boolean equals​(java.lang.Object o)  
      V get​(java.lang.Object key)  
      java.util.Map<K,​V> getOrigin()
      Returns the original map being filtered.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsValue, isEmpty, keySet, put, putAll, remove, size, values
      • Methods inherited from class java.lang.Object

        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 Detail

    • Method Detail

      • getOrigin

        public java.util.Map<K,​V> getOrigin()
        Returns the original map being filtered. That is, the map passed to the constructor.
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
        get in class java.util.AbstractMap<K,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
        containsKey in class java.util.AbstractMap<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>
      • toString

        public java.lang.String toString()
        toString in class java.util.AbstractMap<K,​V>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map<K,​V>
        hashCode in class java.util.AbstractMap<K,​V>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Map<K,​V>
        equals in class java.util.AbstractMap<K,​V>