How do I get the class of a Matcher in Hamcrest? <p>I've got a matcher, and I want to make sue the object I have is the right type. E.g. a long or a String.</p> <pre><code>void expect(String xpath, Matcher matcher) { String actual = fromXpath(xpath); // convert actual into correct type for matcher assertThat(actual, matcher); } </code></pre> <p>I want method like <code>Matcher.getType</code>. So I could do something like</p> <pre><code>if (matcher.getType().equals(Long.class)) { long actual = Long.parseString(fromXpath(xpath)); } </code></pre> <p>But I cannot see for the life of me how I get the of the matcher.</p>