1 | // union-type entry |
2 | sclass E { |
3 | S q, a, state; |
4 | bool test; // not used anymore probably |
5 | S comment; // not checked for comparison |
6 | |
7 | *() {} |
8 | *(S text, S type) { |
9 | if (eq(type, "q")) q = text; |
10 | else if (eq(type, "a")) a = text; |
11 | else state = text; |
12 | } |
13 | |
14 | // does not compare the "test" bit |
15 | bool eqTo(E y) { |
16 | E x = this; |
17 | ret eq/*ic*/(x.q, y.q) && eq/*ic*/(x.a, y.a) && eq/*ic*/(x.state, y.state); |
18 | } |
19 | |
20 | public bool equals(O o) { |
21 | ret o is a E && eqTo((E) o); |
22 | } |
23 | |
24 | public int hashCode() { |
25 | ret stdHash(this, "q", "a", "state"); |
26 | } |
27 | |
28 | static E state(S state) { |
29 | if (state == null) null; new E e; e.state = state; ret e; |
30 | } |
31 | |
32 | static E q(S q) { |
33 | if (q == null) null; new E e; e.q = q; ret e; |
34 | } |
35 | |
36 | static E a(S a) { |
37 | if (a == null) null; new E e; e.a = a; ret e; |
38 | } |
39 | |
40 | public S toString() { |
41 | ret unparsePoemLine(this); |
42 | } |
43 | |
44 | bool q() { ret q != null; } |
45 | bool a() { ret a != null; } |
46 | bool state() { ret state != null; } |
47 | S type() { ret q() ? "q" : a() ? "a" : "state"; } |
48 | S text() { ret q() ? q : a() ? a : state; } |
49 | } |
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, imzmzdywqqli, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv
No comments. add comment
Snippet ID: | #1003474 |
Snippet name: | class E (poem line) |
Eternal ID of this version: | #1003474/1 |
Text MD5: | 674547dfda2785f0abf5233e1ffc5fea |
Author: | stefan |
Category: | javax / talking robots |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-05 17:58:05 |
Source code size: | 1128 bytes / 49 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 684 / 4162 |
Referenced in: | [show references] |