public static int compare(Object o1, Object o2) {
        return o1.getClass() != o2.getClass() && o1 instanceof Number && o2 instanceof Number ?
                asBigDecimal((Number)o1).compareTo(asBigDecimal((Number)o2)) :
                ((Comparable) o1).compareTo(o2);
    }
@Test
    public void compareWithNumbers() {
        assertThat(OperatorUtils.compare(1, 1)).isZero();
        assertThat(OperatorUtils.compare(1L, 1L)).isZero();
        assertThat(OperatorUtils.compare(1.0f, 1.0f)).isZero();
        assertThat(OperatorUtils.compare(1.0, 1.0)).isZero();

        assertThat(OperatorUtils.compare(1, 2)).isNegative();
        assertThat(OperatorUtils.compare(1L, 2L)).isNegative();
        assertThat(OperatorUtils.compare(1.0f, 2.0f)).isNegative();
        assertThat(OperatorUtils.compare(1.0, 2.0)).isNegative();

        assertThat(OperatorUtils.compare(2, 1)).isPositive();
        assertThat(OperatorUtils.compare(2L, 1L)).isPositive();
        assertThat(OperatorUtils.compare(2.0f, 1.0f)).isPositive();
        assertThat(OperatorUtils.compare(2.0, 1.0)).isPositive();

        assertThat(OperatorUtils.compare(1, new BigDecimal("0.99"))).isPositive();
        assertThat(OperatorUtils.compare(1, new BigDecimal("1.0"))).isZero();
        assertThat(OperatorUtils.compare(1, new BigDecimal("1.01"))).isNegative();

        assertThat(OperatorUtils.compare(new BigDecimal("1.00"), new BigDecimal("0.99"))).isPositive();
        assertThat(OperatorUtils.compare(new BigDecimal("1.00"), new BigDecimal("1.0"))).isZero();
        assertThat(OperatorUtils.compare(new BigDecimal("1.00"), new BigDecimal("1.01"))).isNegative();
    }