Libraryless. Click here for Pure Java version (15546L/101K).
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<O> 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); }
Began life as a copy of #1026010
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029594 |
Snippet name: | cSmartSetField_withConverter |
Eternal ID of this version: | #1029594/9 |
Text MD5: | f3a62935680f1808b74995c27fde696b |
Transpilation MD5: | 20198c5174ecbf02e9ce1265df0dad44 |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-05 18:08:41 |
Source code size: | 1511 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 277 / 404 |
Version history: | 8 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |