Ejemplo n.º 1
0
 /**
  * Returns an object cast to the specified type.
  *
  * @throws NullPointerException if the object is {@code null}
  * @throws IllegalArgumentException if the object is of the wrong type
  */
 private static <T> T cast(Class<T> clazz, Object o) {
   if (!clazz.isInstance(o)) throw new IllegalArgumentException(o.toString());
   return clazz.cast(o);
 }