src/main/java/com/googlecode/objectify/impl/translate/IntegerTranslatorFactory.java
private Number coerceNumber(final Number value, final Class<?> type) {
		if (type == Byte.class) return value.byteValue();
		else if (type == Short.class) return value.shortValue();
		else if (type == Integer.class) return value.intValue();
		else if (type == Long.class) return value.longValue();
		else throw new IllegalArgumentException();	// should be impossible
	}
private Number coerceNumber(final Number value, final Class<?> type) {
		if (type == Byte.class) return value.byteValue();
		else if (type == Short.class) return value.shortValue();
		else if (type == Integer.class) return value.intValue();
		else if (type == Long.class) return value.longValue();
		else throw new IllegalArgumentException();	// should be impossible
	}
private Number coerceNumber ( final Number value , final Class < ? > type ) { if ( type == Byte . class ) return value . byteValue ( ) ; else if ( type == Short . class ) return value . shortValue ( ) ; else if ( type == Integer . class ) return value . intValue ( ) ; else if ( type == Long . class ) return value . longValue ( ) ; else throw new IllegalArgumentException ( ) ; // should be impossible }
Coerces the value to be a number of the specified type; needed because
all numbers come back from the datastore as Long/Double and this screws up
any type that expects something smaller. We don't need to worry about primitive
types because we wrapped the class earlier.
Coerces the value to be a number of the specified type ; needed because all numbers come back from the datastore as Long / Double and this screws up any type that expects something smaller . We don t need to worry about primitive types because we wrapped the class earlier .