1 | sS standard_toString(O o) { |
2 | if (o == null) ret "null"; |
3 | S name = shortClassName(o); |
4 | Set<S> fields = fieldNames(o); |
5 | if (empty(fields)) ret name; |
6 | ret name + "(" + joinWithComma(mapNonNulls(fields, field -> { |
7 | O value = get(o, field); |
8 | if (value == null) null; |
9 | ret field + "=" + str(value); |
10 | })) + ")"; |
11 | } |
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: | 353 / 421 |
Referenced in: | [show references] |