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

19
LINES

< > BotCompany Repo | #1027622 // objectToMap_nonTransient

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

Libraryless. Click here for Pure Java version (2826L/17K).

1  
// o is either a map already (string->object) or an arbitrary object,
2  
// in which case its fields are converted into a map.
3  
static Map<S, O> objectToMap_nonTransient(O o) {
4  
  if (o == null) null;
5  
  if (o instanceof Map) ret (Map) o;
6  
  
7  
  new HashMap<S, O> map;
8  
  for (Field field : nonStaticNonTransientFieldObjects_cachedArray(o)) {
9  
    O value = fieldGet(field, o);
10  
    if (value != null)
11  
      map.put(field.getName(), value);
12  
  }
13  
  
14  
  // TODO: Should we drop fieldValues key from map?
15  
  if (o cast DynamicObject)
16  
    putAll(map, o.fieldValues);
17  
18  
  ret map;
19  
}

Author comment

Began life as a copy of #1002179

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027622
Snippet name: objectToMap_nonTransient
Eternal ID of this version: #1027622/6
Text MD5: 00e212f1b215d9dacf98cf654de33578
Transpilation MD5: 82cea4330e4d86585d6fbc7d7af52176
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-26 18:12:29
Source code size: 580 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 203 / 305
Version history: 5 change(s)
Referenced in: [show references]