Transpiled version (8992L) is out of date.
1 | sclass OKOrError<A> implements IF0<A> {
|
2 | A value; |
3 | gettable Throwable error; |
4 | |
5 | *() {}
|
6 | *(A *value) {}
|
7 | *(bool dummy, Throwable *error) { assertNotNull(error); }
|
8 | |
9 | bool ok aka isOK() { ret error == null; }
|
10 | bool isError() { ret error != null; }
|
11 | |
12 | toString {
|
13 | ret ok() |
14 | ? /*"OK: " +*/ str(value) |
15 | : "Error: " + str(error); |
16 | } |
17 | |
18 | public A get() { ret !ok() ? null : value; }
|
19 | |
20 | public A getMandatory() { if (!ok()) throw rethrow(error); ret value; }
|
21 | |
22 | static <A> OKOrError<A> ok(A a) { ret new OKOrError(a); }
|
23 | static OKOrError error(Throwable error) { ret new OKOrError(false, error); }
|
24 | |
25 | void setValue(A value) {
|
26 | this.value = value; |
27 | error = null; |
28 | } |
29 | |
30 | void setError(Throwable error) {
|
31 | this.value = null; |
32 | this.error = error; |
33 | } |
34 | |
35 | void copyFrom(OKOrError<A> x) {
|
36 | value = x.value; |
37 | error = x.error; |
38 | } |
39 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1012580 |
| Snippet name: | OKOrError |
| Eternal ID of this version: | #1012580/13 |
| Text MD5: | 99e55d296718838172efbc51793c673a |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-04-02 14:58:50 |
| Source code size: | 908 bytes / 39 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 815 / 1689 |
| Version history: | 12 change(s) |
| Referenced in: | [show references] |