@SuppressWarnings("unchecked")
    public static <T, S extends T> Optional<S> downcast(T obj, Class<S> klass) {
        Preconditions.checkArgument(obj != null);
        if (obj.getClass().equals(Objects.requireNonNull(klass))) {
            return Optional.of((S) obj);
        } else {
            return Optional.empty();
        }
    }
@Test
    public void testDowncast() {
        Number a = Integer.valueOf(10);
        Assert.assertTrue(Util.downcast(a, Integer.class).isPresent());
        Assert.assertFalse(Util.downcast(a, String.class).isPresent());
    }