sbool cSmartSetField_withConverter(Concept c, S field, O value, bool verbose default false) { ret cSmartSetField_withConverter(c, field, value, new DefaultValueConverterForField, verbose); } // returns true if change sbool cSmartSetField_withConverter(Concept c, S field, O value, ValueConverterForField converter, bool verbose default false) ctex { Field f = setOpt_findField(c.getClass(), field); if (f != null) { if (verbose) print("cSmartSetField_withConverter: setting " + f + " = " + value); if (converter != null && value != null) { OrError result = converter.convertValue(c, f, value); if (result == null) fail("Unknown conversion " + className(value) + " => " + f); if (!result.ok()) fail("Unknown conversion " + className(value) + " => " + f + ": " + result.error()); value = result!; } if (verbose) print("cSmartSetField_withConverter: converted value=" + value); // convert L to RefL if (value instanceof L && f.getType() == Concept.RefL.class) { Concept.RefL l = cast f.get(c); if (verbose) print("cSmartSetField_withConverter: RefL=" + l); l.replaceWithList((L) value); if (verbose) print("cSmartSetField_withConverter: backrefs=" + c.backRefs); true; } // convert concept to Ref if (value instanceof Concept && f.getType() == Concept.Ref.class) ret ((Concept.Ref) f.get(c)).set((Concept) value); } ret _csetField(c, field, value); }