private static <T>T cast(Class<T> clazz,Object o){
  if (!clazz.isInstance(o))   throw new IllegalArgumentException(o.toString());
  return clazz.cast(o);
}

private static < T > T cast ( Class < T > clazz , Object o ) { if ( ! clazz . isInstance ( o ) ) throw new IllegalArgumentException ( o . toString ( ) ) ; return clazz . cast ( o ) ; }
returns an object cast to the specified type .
