static void smartSet(Field f, O o, O value) throws Exception { try { f.set(o, value); } catch (Exception e) { Class type = f.getType(); // take care of common case (long to int) if (type == int.class && value instanceof Long) value = ((Long) value).intValue(); if (type == LinkedHashMap.class && value instanceof Map) ret with f.set(o, asLinkedHashMap((Map) value)); ifclass IConceptIndex try { if (f.getType() == Concept.Ref.class) { f.set(o, ((Concept) o).new Ref((Concept) value)); ret; } if (o instanceof Concept.Ref) { f.set(o, ((Concept.Ref) o).get()); ret; } } catch {} endif throw e; } }