src/org/kocakosm/pitaya/util/Parameters.java
public static <T> T checkType(Object ref, Class<T> type, String msg,
		Object... args)
	{
		if (type.isInstance(ref)) {
			return type.cast(ref);
		}
		throw new ClassCastException(format(msg, args));
	}
public static <T> T checkType(Object ref, Class<T> type, String msg,
		Object... args)
	{
		if (type.isInstance(ref)) {
			return type.cast(ref);
		}
		throw new ClassCastException(format(msg, args));
	}
public static < T > T checkType ( Object ref , Class < T > type , String msg , Object ... args ) { if ( type . isInstance ( ref ) ) { return type . cast ( ref ) ; } throw new ClassCastException ( format ( msg , args ) ) ; }
Checks the type of the given reference and, in case of success, casts
and returns it.

@param <T> the expected type of the given reference.
@param ref the reference to test.
@param type the expected type of the given reference.
@param msg the error message format string.
@param args the error message arguments.

@return the given reference in the expected type.

@throws NullPointerException if {@code type} is {@code null}.
@throws ClassCastException if the given reference doesn't represent
an instance of the given class.
Checks the type of the given reference and in case of success casts and returns it .