Libraryless. Click here for Pure Java version (3025L/18K).
1 | static void smartSet(Field f, O o, O value) throws Exception {
|
2 | try {
|
3 | f.set(o, value); |
4 | } catch (Exception e) {
|
5 | Class type = f.getType(); |
6 | |
7 | // take care of common case (long to int) |
8 | if (type == int.class && value instanceof Long) |
9 | ret with f.set(o, ((Long) value).intValue()); |
10 | |
11 | if (type == bool.class && value instanceof S) |
12 | ret with f.set(o, isTrueOrYes(value/S)); |
13 | |
14 | if (type == LinkedHashMap.class && value instanceof Map) |
15 | ret with f.set(o, asLinkedHashMap((Map) value)); |
16 | |
17 | ifclass Concept |
18 | try {
|
19 | if (f.getType() == Concept.Ref.class) |
20 | ret with f.set(o, ((Concept) o).new Ref((Concept) value)); |
21 | if (o instanceof Concept.Ref) |
22 | ret with f.set(o, ((Concept.Ref) o).get()); |
23 | } catch {}
|
24 | endif |
25 | throw e; |
26 | } |
27 | } |
download show line numbers debug dex old transpilations
Travelled to 23 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, dpqxeycirhfy, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, ofpaelxlmzfo, onxytkatvevr, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1001974 |
| Snippet name: | smartSet |
| Eternal ID of this version: | #1001974/14 |
| Text MD5: | a04caf4190df4d06ece4f1f5601050c2 |
| Transpilation MD5: | 9d8716e4dc064e9657dc169838545f76 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-06-22 10:23:06 |
| Source code size: | 843 bytes / 27 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1100 / 9324 |
| Version history: | 13 change(s) |
| Referenced in: | [show references] |