Libraryless. Click here for Pure Java version (13113L/76K).
scope test_structure_customSerializer sclass #X { settable int i; // _serialize can now return this to request standard serialization O _serialize() { ret i < 0 ? this : i; } static X _deserialize(O o) { ret new X().i((int) o); } [stdEq] } svoid test_structure_customSerializer() { X x = new X().i(5); S s = struct(x); S nameOfX = shortClassName(X); assertEqualsVerbose("cu " + nameOfX + " 5", s); assertEqualsVerbose(x, unstructure(s)); x = new X().i(-5); s = print(struct(x)); assertEqualsVerbose(x, unstructure(s)); }
Began life as a copy of #1035332
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1035334 |
| Snippet name: | test_structure_customSerializer (_serialize and _deserialize methods) |
| Eternal ID of this version: | #1035334/6 |
| Text MD5: | e99648629ccf785646c97062fb5c2c1b |
| Transpilation MD5: | b871fe361259c69fdd201668094b3888 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-05-01 17:31:57 |
| Source code size: | 599 bytes / 28 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 372 / 508 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |