@Test public void shouldReturnNumberValue() { NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(21)); assertEquals(Long.valueOf(21L), numberValue.numberValue(Long.class)); assertEquals(Integer.valueOf(21), numberValue.numberValue(Integer.class)); assertEquals(Float.valueOf(21), numberValue.numberValue(Float.class)); assertEquals(Byte.valueOf((byte) 21), numberValue.numberValue(Byte.class)); assertEquals(Short.valueOf((short) 21), numberValue.numberValue(Short.class)); assertEquals(new AtomicLong(21L).get(), numberValue.numberValue(AtomicLong.class).get()); assertEquals(new AtomicInteger(21).get(), numberValue.numberValue(AtomicInteger.class).get()); assertEquals(BigDecimal.valueOf(21L), numberValue.numberValue(BigDecimal.class)); assertEquals(BigInteger.valueOf(21L), numberValue.numberValue(BigInteger.class)); }
@SuppressWarnings("NullableProblems") @Override public int compareTo(NumberValue o) { return numberValue(BigDecimal.class).compareTo(o.numberValue(BigDecimal.class)); }