Class TypeSafeMatching

    • Field Detail

      • argumentTypeCache

        private static final java.util.concurrent.ConcurrentMap<java.lang.Class<?>,​java.lang.Class<?>> argumentTypeCache
        This cache is in theory unbounded. However, its max size is bounded by the number of types of argument matchers that are both in the system and being used, which is expected to bound the cache's size to a low number (<200) in all but the most contrived cases, and form a small percentage of the overall memory usage of those classes.
    • Constructor Detail

      • TypeSafeMatching

        private TypeSafeMatching()
    • Method Detail

      • apply

        public boolean apply​(ArgumentMatcher matcher,
                             java.lang.Object argument)
        Description copied from interface: ArgumentMatcherAction
        Implementations must apply the given matcher to the argument and return true if the operation was successful or false if not. In this case no more matchers and arguments will be passed by MatcherApplicationStrategy.forEachMatcherAndArgument(ArgumentMatcherAction) to this method. .
        Specified by:
        apply in interface ArgumentMatcherAction
        Parameters:
        matcher - to process the argument, never null
        argument - to be processed by the matcher, can be null
        Returns:
        • true if the matcher was successfully applied to the argument and the next pair of matcher and argument should be passed
        • false otherwise
      • isCompatible

        private static boolean isCompatible​(ArgumentMatcher<?> argumentMatcher,
                                            java.lang.Object argument)
        Returns true if the given argument can be passed to the given argumentMatcher without causing a ClassCastException.
      • getArgumentType

        private static java.lang.Class<?> getArgumentType​(ArgumentMatcher<?> matcher)
      • isMatchesMethod

        private static boolean isMatchesMethod​(java.lang.reflect.Method method)
        Returns true if the given method is ArgumentMatcher.matches(Object)