@SuppressWarnings("unchecked") public static <T>T assertCast(Object object,Class<T> klass){
  assertTrue(object == null || klass.isInstance(object));
  return (T)object;
}

@ SuppressWarnings ( "unchecked" ) public static < T > T assertCast ( Object object , Class < T > klass ) { assertTrue ( object == null || klass . isInstance ( object ) ) ; return ( T ) object ; }
asserts that given object is null or an instance of given klass . returns casted object .
