Libraryless. Click here for Pure Java version (6597L/38K).
1 | persistable sclass PersistableOKOrError<A> implements IF0<A> { |
2 | A value; |
3 | gettable PersistableThrowable error; |
4 | |
5 | *() {} |
6 | *(A *value) {} |
7 | *(bool dummy, PersistableThrowable *error) { assertNotNull(error); } |
8 | |
9 | bool ok aka isOK() { ret error == null; } |
10 | |
11 | toString { |
12 | ret ok() |
13 | ? /*"OK: " +*/ str(value) |
14 | : "Error: " + str(error); |
15 | } |
16 | |
17 | public A get() { ret !ok() ? null : value; } |
18 | |
19 | public A getMandatory() { if (!ok()) throw error.asRuntimeException(); ret value; } |
20 | |
21 | static <A> PersistableOKOrError<A> ok(A a) { ret new PersistableOKOrError(a); } |
22 | static PersistableOKOrError error(PersistableThrowable error) { ret new PersistableOKOrError(false, error); } |
23 | } |
Began life as a copy of #1012580
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034654 |
Snippet name: | PersistableOKOrError |
Eternal ID of this version: | #1034654/2 |
Text MD5: | e969cd941218345afa4cc4bb9fbfcd61 |
Transpilation MD5: | 5cea877cbd07cc7736102aebed167a73 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-28 20:37:06 |
Source code size: | 716 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 181 / 259 |
Version history: | 1 change(s) |
Referenced in: | [show references] |