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).

svoid setOptAllDyn_pcall(DynamicObject o, MapSO fields) {
  if (fields == null || o == null) ret;
  HashMap<S, Field> fieldMap = instanceFieldsMap(o);
  for (Map.Entry<S, O> e : fields.entrySet()) pcall {
    S field = e.getKey();
    O val = e.getValue();
    Field f = fieldMap.get(field);
    if (f != null)
      smartSet(f, o, val);
    else {
      dynamicObject_setRawFieldValue(o, intern(field), val);
      ifdef setOptAllDyn_debug
        print("setOptAllDyn added dyn " + field + " to " + o + " [value: " + val + ", fieldValues = " + systemHashCode(o.fieldValues) + ", " + struct(keys(o.fieldValues)) + "]");
      endifdef
    }
  }
}

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: 179 / 267
Version history: 5 change(s)
Referenced in: [show references]