List of utility methods to do Object Type Case
A | cast(Object object, Class targetClass) cast return targetClass.cast(object);
|
T | cast(Object source) cast try { return source == null ? null : (T) source; } catch (Exception e) { throw new IllegalArgumentException("Cannot convert to type"); |
Object | cast(Object val, Class type) cast if (val == null) return null; if (type == Boolean.class || type == Boolean.TYPE) { return ((Boolean) val).booleanValue(); } else if (type == Character.class || type == Character.TYPE) { return ((Character) val).charValue(); } else if (type == Byte.class || type == Byte.TYPE) { return ((Byte) val).byteValue(); ... |
String | cast(Object value, String sqlType) cast return "cast(" + value + " as " + sqlType + ")"; |
T | cast(Object x) Use this function to eliminate silly "unchecked" warnings that cannot be fixed in Java otherwise. return (T) x;
|
T | cast(Object x) cast return (T) x;
|
Object[] | cast(Object[] parameters, Class>[] types) cast for (int i = 0; i < parameters.length; i++) { parameters[i] = types[i].cast(parameters[i]); return parameters; |
String | cast(String type) cast if (type == null) { return type; if (type.equals(Object.class.getName())) { return ""; return "(" + type + ")"; |
void | castAndThrow(Throwable e) cast And Throw throw (T) e;
|
T[] | castArray(Object[] array, T[] targetArray) cast Array for (int i = 0; i < array.length; i++) { targetArray[i] = (T) array[i]; return targetArray; |