Class CachingMatcher<T>

    • Constructor Detail

      • CachingMatcher

        public CachingMatcher​(ElementMatcher<? super T> matcher,
                              ConcurrentMap<? super T,​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.