code: @SuppressWarnings("unchecked")
  	public static <T> T cast(Object obj, Class<T> type){
  		if(obj == null){
  			return null;
  		}
  		if(obj.getClass() == type){
  			return (T) obj;
  		}
  		if(isNativeNumberType(obj.getClass()) && isNativeNumberType(type)){
  			return castToNativeNumber((Number)obj, type);
  		}
  		return type.cast(obj);
  	}
docs: same as class.cast(obj) but with explicit casting for native numbers e.g. int i = (int) 2.3f;