IsNotANumber extends TypeSafeMatcher<N> { @Override protected void describeMismatchSafely(final N item, final Description mismatchDescription) { mismatchDescription.appendValue(item).appendText(" is not a number (i.e. Double.NaN or Float.NaN)"); }  static Matcher<N> notANumber(); @Override void describeTo(final Description description);  }
@Test public void testDescribeMismatchSafely() throws Exception { assertHasMismatchDescription("<0> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, (byte) 0); assertHasMismatchDescription("<0s> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, (short) 0); assertHasMismatchDescription("<0> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, 0); assertHasMismatchDescription("<0L> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, 0L); assertHasMismatchDescription("<0> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, new BigInteger("0")); assertHasMismatchDescription("<0> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, new AtomicInteger(0)); assertHasMismatchDescription("<0> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, new AtomicLong(0L)); assertHasMismatchDescription("<0.0F> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, .0F); assertHasMismatchDescription("<0.0> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, .0D); assertHasMismatchDescription("<0.0> is not a number (i.e. Double.NaN or Float.NaN)", isNotANumberMatcher, new BigDecimal(".0")); }