1 /* 2 * Copyright (c) 2016 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockito.internal.hamcrest; 6 7 import org.hamcrest.BaseMatcher; 8 import org.hamcrest.Matcher; 9 10 import static org.mockito.internal.util.reflection.GenericTypeExtractor.genericTypeOf; 11 12 /** 13 * Extracts generic type of matcher 14 */ 15 public class MatcherGenericTypeExtractor { 16 17 /** 18 * Gets the generic type of given matcher. For example, 19 * for matcher class that extends BaseMatcher[Integer] this method returns Integer 20 */ genericTypeOfMatcher(Class<?> matcherClass)21 public static Class<?> genericTypeOfMatcher(Class<?> matcherClass) { 22 //TODO SF check if we can reuse it for Mockito ArgumentMatcher 23 return genericTypeOf(matcherClass, BaseMatcher.class, Matcher.class); 24 } 25 } 26