1 | // returns true if change |
2 | sbool _csetField(Concept c, S field, O value) ctex { |
3 | Field f = setOpt_findField(c.getClass(), field); |
4 | //print("cset: " + c.id + " " + field + " " + struct(value) + " " + f); |
5 | if (value instanceof RC) value = c._concepts.getConcept((RC) value); |
6 | value = deref(value); |
7 | |
8 | if (value instanceof S && l((S) value) >= concepts_internStringsLongerThan) value = intern((S) value); |
9 | |
10 | if (f == null) { |
11 | // dynamic field (undeclared) |
12 | |
13 | assertIdentifier(field); |
14 | O val2 = value instanceof Concept ? c.new Ref((Concept) value) : value; |
15 | O oldVal = mapGet(c.fieldValues, field); |
16 | if (oldVal instanceof Concept.Ref && val2 instanceof Concept.Ref) |
17 | // change existing reference |
18 | ((Concept.Ref) oldVal).set(((Concept.Ref) val2)!); |
19 | else if (val2 == null) { |
20 | // unindex & drop reference, drop dynamic field |
21 | if (oldVal != null) { |
22 | if (oldVal cast Concept.Ref) |
23 | oldVal.unindexAndDrop(); |
24 | syncMapRemove(c.fieldValues, field); |
25 | } |
26 | } else |
27 | // create new reference |
28 | c.fieldValues = syncMapPut2_createLinkedHashMap(c.fieldValues, field, val2); |
29 | c.change(); |
30 | } else if (isSubtypeOf(f.getType(), Concept.Ref.class)) { |
31 | // Concept.Ref magic |
32 | ((Concept.Ref) f.get(c)).set((Concept) derefRef(value)); |
33 | c.change(); true; |
34 | } else if (isSubtypeOf(f.getType(), Concept.RefL.class)) { |
35 | // Concept.RefL magic |
36 | ((Concept.RefL) f.get(c)).replaceWithList(lmap derefRef((L) value)); |
37 | c.change(); true; |
38 | } else { |
39 | O old = f.get(c); |
40 | if (neq(value, old)) { |
41 | f.set(c, value); |
42 | if (!isTransient(f)) c.change(); |
43 | true; |
44 | } |
45 | } |
46 | false; |
47 | } |
Began life as a copy of #1026007
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030900 |
Snippet name: | _csetField [backup] |
Eternal ID of this version: | #1030900/1 |
Text MD5: | 9f5806ce71e5a7216c7a72ef24098251 |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-04-07 23:40:39 |
Source code size: | 1707 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 193 / 225 |
Referenced in: | [show references] |