private static Object castToPrimitive(Object object, Class type) { if (type == boolean.class) { return booleanUnbox(object); } else if (type == byte.class) { return byteUnbox(object); } else if (type == char.class) { return charUnbox(object); } else if (type == short.class) { return shortUnbox(object); } else if (type == int.class) { return intUnbox(object); } else if (type == long.class) { return longUnbox(object); } else if (type == float.class) { return floatUnbox(object); } else if (type == double.class) { Double answer = doubleUnbox(object); //throw a runtime exception if conversion would be out-of-range for the type. if (!(object instanceof Double) && (answer == Double.NEGATIVE_INFINITY || answer == Double.POSITIVE_INFINITY)) { throw new GroovyRuntimeException("Automatic coercion of " + object.getClass().getName() + " value " + object + " to double failed. Value is out of range."); } return answer; } //nothing else possible throw new GroovyCastException(object, type); }
for (Iterator iter = list.iterator(); iter.hasNext(); idx++) { Object element = iter.next(); Array.setChar(array, idx, charUnbox(element));
for (Iterator iter = list.iterator(); iter.hasNext(); idx++) { Object element = iter.next(); Array.setChar(array, idx, charUnbox(element));
for (Iterator iter = list.iterator(); iter.hasNext(); idx++) { Object element = iter.next(); Array.setChar(array, idx, charUnbox(element));
for (Iterator iter = list.iterator(); iter.hasNext(); idx++) { Object element = iter.next(); Array.setChar(array, idx, charUnbox(element));
return box(byteUnbox(object)); } else if (type == char.class) { return box(charUnbox(object)); } else if (type == short.class) { return box(shortUnbox(object));
return box(byteUnbox(object)); } else if (type == char.class) { return box(charUnbox(object)); } else if (type == short.class) { return box(shortUnbox(object));
return box(byteUnbox(object)); } else if (type == char.class) { return box(charUnbox(object)); } else if (type == short.class) { return box(shortUnbox(object));
return box(byteUnbox(object)); } else if (type == char.class) { return box(charUnbox(object)); } else if (type == short.class) { return box(shortUnbox(object));