Object (Object value, Class to) { Class from = value.getClass(); if (!to.isAssignableFrom(from)) { if (to.isPrimitive()) { if (to.equals(Integer.TYPE)) { to = Integer.class; } } for (ValueTypeConverter converter : ValueTypeConverter.STANDARD) { if (from.equals(converter.getSourceType()) && to.equals(converter.getTargetType())) { return converter.from(value); } if (to.equals(converter.getSourceType()) && from.equals(converter.getTargetType())) { return converter.to(value); } } } return value; }