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

11
LINES

< > BotCompany Repo | #1022820 // standard_toString - stringify an object like a record

JavaX fragment (include)

sS standard_toString(O o) {
  if (o == null) ret "null";
  S name = shortClassName(o);
  Set<S> fields = fieldNames(o);
  if (empty(fields)) ret name;
  ret name + "(" + joinWithComma(mapNonNulls(fields, field -> {
    O value = get(o, field);
    if (value == null) null;
    ret field + "=" + str(value);
  })) + ")";
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1022820
Snippet name: standard_toString - stringify an object like a record
Eternal ID of this version: #1022820/1
Text MD5: 37634ac479b23399e3dc1e9dcafe7455
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-09 11:05:36
Source code size: 331 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 290 / 353
Referenced in: [show references]