1 | sS stdToStringWithFields(O o, S... fields) {
|
2 | if (o == null) ret "null"; |
3 | S name = shortClassName(o); |
4 | |
5 | // new default |
6 | if (empty(fields)) fields = asStringArray(allNonStaticFields(o)); |
7 | |
8 | if (empty(fields)) ret name; |
9 | ret name + "(" + joinWithComma(mapNonNulls(fields, field -> {
|
10 | O value = getOpt(o, field); |
11 | if (value == null) null; |
12 | ret field + "=" + str(value); |
13 | })) + ")"; |
14 | } |
Began life as a copy of #1022820
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1025941 |
| Snippet name: | stdToStringWithFields - stringify an object like a record, showing certain fields only |
| Eternal ID of this version: | #1025941/6 |
| Text MD5: | 43b7d024e6edc6833eb570a894e8fa40 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-10-11 01:02:37 |
| Source code size: | 412 bytes / 14 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 458 / 494 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |