### Question:
CastUtils { public static <T> T as(Object obj) { return (T) obj; }  static T as(Object obj);  }### Answer:
@Test public void test() { Object obj = "foo"; String casted = CastUtils.as(obj); assertThat(casted).isEqualTo("foo"); }
@SuppressWarnings("unused") @Test(expected = ClassCastException.class) public void testFailedCast() { Object obj = "1"; Integer ignored = CastUtils.<Integer>as(obj); fail(); }