@SuppressWarnings("unchecked")
    public static int compare(Comparable lhs, Comparable rhs) {
        assert lhs != null;
        assert rhs != null;

        if (lhs.getClass() == rhs.getClass()) {
            return lhs.compareTo(rhs);
        }

        if (lhs instanceof Number && rhs instanceof Number) {
            return Numbers.compare(lhs, rhs);
        }

        return lhs.compareTo(rhs);
    }
@Test
    public void testCompare() {
        assertNotEquals(0, compare(0, 1));
        assertNotEquals(0, compare("foo", "bar"));

        assertEquals(0, compare(0, 0));
        assertEquals(0, compare(1.0, 1.0));
        assertEquals(0, compare("foo", "foo"));

        assertThat(compare(0, 1)).isNegative();
        assertThat(compare(1, 0)).isPositive();

        assertThat(compare("a", "b")).isNegative();
        assertThat(compare("b", "a")).isPositive();
    }