Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1029607 // setOptAllDyn_pcall - ignore errors

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3154L/19K).

1  
svoid setOptAllDyn_pcall(DynamicObject o, MapSO fields) {
2  
  if (fields == null || o == null) ret;
3  
  HashMap<S, Field> fieldMap = instanceFieldsMap(o);
4  
  for (Map.Entry<S, O> e : fields.entrySet()) pcall {
5  
    S field = e.getKey();
6  
    O val = e.getValue();
7  
    Field f = fieldMap.get(field);
8  
    if (f != null)
9  
      smartSet(f, o, val);
10  
    else {
11  
      dynamicObject_setRawFieldValue(o, intern(field), val);
12  
      ifdef setOptAllDyn_debug
13  
        print("setOptAllDyn added dyn " + field + " to " + o + " [value: " + val + ", fieldValues = " + systemHashCode(o.fieldValues) + ", " + struct(keys(o.fieldValues)) + "]");
14  
      endifdef
15  
    }
16  
  }
17  
}

Author comment

Began life as a copy of #1005268

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: #1029607
Snippet name: setOptAllDyn_pcall - ignore errors
Eternal ID of this version: #1029607/6
Text MD5: 16e6372adee634472f3774e8276de29c
Transpilation MD5: 0d82f4a6025f3e927d8f446cfdfa62c0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-19 23:30:59
Source code size: 662 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 183 / 271
Version history: 5 change(s)
Referenced in: [show references]