class JavaToValueConverter {

	public static Value convertBoxedJavaType(Object boxed) {
		if (boxed == null) {
			return null;
		}
		
		final Class<?> clazz = boxed.getClass();
		
		if (clazz == String.class) {
			return new StringValue((String) boxed);
		}
		else if (clazz == Integer.class) {
			return new IntValue((Integer) boxed);
		}
		else if (clazz == Long.class) {
			return new LongValue((Long) boxed);
		}
		else if (clazz == Double.class) {
			return new DoubleValue((Double) boxed);
		}
		else if (clazz == Float.class) {
			return new FloatValue((Float) boxed);
		}
		else if (clazz == Boolean.class) {
			return new BooleanValue((Boolean) boxed);
		}
		else if (clazz == Byte.class) {
			return new ByteValue((Byte) boxed);
		}
		else if (clazz == Short.class) {
			return new ShortValue((Short) boxed);
		}
		else if (clazz == Character.class) {
			return new CharValue((Character) boxed);
		}
		else {
			throw new IllegalArgumentException("Object is no primitive Java type.");
		}
	}

}