Class CachingMatcher<T>

    • Field Detail

      • matcher

        private final ElementMatcher<? super T> matcher
        The underlying matcher to apply for non-cached targets.
      • map

        @ValueHandling(IGNORE)
        protected final java.util.concurrent.ConcurrentMap<? super T,​java.lang.Boolean> map
        A map that serves as a cache for previous matches.
    • Constructor Detail

      • CachingMatcher

        public CachingMatcher​(ElementMatcher<? super T> matcher,
                              java.util.concurrent.ConcurrentMap<? super T,​java.lang.Boolean> map)
        Creates a new caching matcher.
        Parameters:
        matcher - The underlying matcher to apply for non-cached targets.
        map - A map that serves as a cache for previous matches. This match is strongly referenced and can cause a memory leak if it is not evicted while keeping this matcher alive.
    • Method Detail

      • matches

        public boolean matches​(T target)
        Matches a target against this element matcher.
        Parameters:
        target - The instance to be matched.
        Returns:
        true if the given element is matched by this matcher or false otherwise.
      • onCacheMiss

        protected boolean onCacheMiss​(T target)
        Invoked if the cache is not hit.
        Parameters:
        target - The element to be matched.
        Returns:
        true if the element is matched.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object