-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathPrint.java
More file actions
186 lines (173 loc) · 8.67 KB
/
Print.java
File metadata and controls
186 lines (173 loc) · 8.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package examples;
import java.nio.ByteBuffer;
import java.util.EnumSet;
import com.chronoxor.test.*;
public class Print
{
public static void main(String[] args)
{
System.out.println(new StructSimple());
System.out.println();
System.out.println(new StructOptional());
System.out.println();
System.out.println(new StructNested());
System.out.println();
// Print bytes struct
var structBytes = new StructBytes();
structBytes.f1 = ByteBuffer.wrap("ABC".getBytes());
structBytes.f2 = ByteBuffer.wrap("test".getBytes());
System.out.println(structBytes);
System.out.println();
// Print array struct
var structArray = new StructArray();
structArray.f1[0] = 48;
structArray.f1[1] = 65;
structArray.f2[0] = 97;
structArray.f2[1] = null;
structArray.f3[0] = ByteBuffer.wrap("000".getBytes());
structArray.f3[1] = ByteBuffer.wrap("AAA".getBytes());
structArray.f4[0] = ByteBuffer.wrap("aaa".getBytes());
structArray.f4[1] = null;
structArray.f5[0] = EnumSimple.ENUM_VALUE_1;
structArray.f5[1] = EnumSimple.ENUM_VALUE_2;
structArray.f6[0] = EnumSimple.ENUM_VALUE_1;
structArray.f6[1] = null;
structArray.f7[0] = FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum()));
structArray.f7[1] = FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum(), FlagsSimple.FLAG_VALUE_3.getEnum()));
structArray.f8[0] = FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum()));
structArray.f8[1] = null;
structArray.f9[0] = new StructSimple();
structArray.f9[1] = new StructSimple();
structArray.f10[0] = new StructSimple();
structArray.f10[1] = null;
System.out.println(structArray);
System.out.println();
// Print vector struct
var structVector = new StructVector();
structVector.f1.add((byte)48);
structVector.f1.add((byte)65);
structVector.f2.add((byte)97);
structVector.f2.add(null);
structVector.f3.add(ByteBuffer.wrap("000".getBytes()));
structVector.f3.add(ByteBuffer.wrap("AAA".getBytes()));
structVector.f4.add(ByteBuffer.wrap("aaa".getBytes()));
structVector.f4.add(null);
structVector.f5.add(EnumSimple.ENUM_VALUE_1);
structVector.f5.add(EnumSimple.ENUM_VALUE_2);
structVector.f6.add(EnumSimple.ENUM_VALUE_1);
structVector.f6.add(null);
structVector.f7.add(FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structVector.f7.add(FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum(), FlagsSimple.FLAG_VALUE_3.getEnum())));
structVector.f8.add(FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structVector.f8.add(null);
structVector.f9.add(new StructSimple());
structVector.f9.add(new StructSimple());
structVector.f10.add(new StructSimple());
structVector.f10.add(null);
System.out.println(structVector);
System.out.println();
// Print list struct
var structList = new StructList();
structList.f1.addLast((byte)48);
structList.f1.addLast((byte)65);
structList.f2.addLast((byte)97);
structList.f2.addLast(null);
structList.f3.addLast(ByteBuffer.wrap("000".getBytes()));
structList.f3.addLast(ByteBuffer.wrap("AAA".getBytes()));
structList.f4.addLast(ByteBuffer.wrap("aaa".getBytes()));
structList.f4.addLast(null);
structList.f5.addLast(EnumSimple.ENUM_VALUE_1);
structList.f5.addLast(EnumSimple.ENUM_VALUE_2);
structList.f6.addLast(EnumSimple.ENUM_VALUE_1);
structList.f6.addLast(null);
structList.f7.addLast(FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structList.f7.addLast(FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum(), FlagsSimple.FLAG_VALUE_3.getEnum())));
structList.f8.addLast(FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structList.f8.addLast(null);
structList.f9.addLast(new StructSimple());
structList.f9.addLast(new StructSimple());
structList.f10.addLast(new StructSimple());
structList.f10.addLast(null);
System.out.println(structList);
System.out.println();
// Print set struct
var structSet = new StructSet();
structSet.f1.add((byte)48);
structSet.f1.add((byte)65);
structSet.f1.add((byte)97);
structSet.f2.add(EnumSimple.ENUM_VALUE_1);
structSet.f2.add(EnumSimple.ENUM_VALUE_2);
structSet.f3.add(FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structSet.f3.add(FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum(), FlagsSimple.FLAG_VALUE_3.getEnum())));
var s1 = new StructSimple();
s1.id = 48;
structSet.f4.add(s1);
var s2 = new StructSimple();
s2.id = 65;
structSet.f4.add(s2);
System.out.println(structSet);
System.out.println();
// Print map struct
var structMap = new StructMap();
structMap.f1.put(10, (byte)48);
structMap.f1.put(20, (byte)65);
structMap.f2.put(10, (byte)97);
structMap.f2.put(20, null);
structMap.f3.put(10, ByteBuffer.wrap("000".getBytes()));
structMap.f3.put(20, ByteBuffer.wrap("AAA".getBytes()));
structMap.f4.put(10, ByteBuffer.wrap("aaa".getBytes()));
structMap.f4.put(20, null);
structMap.f5.put(10, EnumSimple.ENUM_VALUE_1);
structMap.f5.put(20, EnumSimple.ENUM_VALUE_2);
structMap.f6.put(10, EnumSimple.ENUM_VALUE_1);
structMap.f6.put(20, null);
structMap.f7.put(10, FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structMap.f7.put(20, FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum(), FlagsSimple.FLAG_VALUE_3.getEnum())));
structMap.f8.put(10, FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structMap.f8.put(20, null);
s1.id = 48;
structMap.f9.put(10, s1);
s2.id = 65;
structMap.f9.put(20, s2);
structMap.f10.put(10, s1);
structMap.f10.put(20, null);
System.out.println(structMap);
System.out.println();
// Print hash struct
var structHash = new StructHash();
structHash.f1.put("10", (byte)48);
structHash.f1.put("20", (byte)65);
structHash.f2.put("10", (byte)97);
structHash.f2.put("20", null);
structHash.f3.put("10", ByteBuffer.wrap("000".getBytes()));
structHash.f3.put("20", ByteBuffer.wrap("AAA".getBytes()));
structHash.f4.put("10", ByteBuffer.wrap("aaa".getBytes()));
structHash.f4.put("20", null);
structHash.f5.put("10", EnumSimple.ENUM_VALUE_1);
structHash.f5.put("20", EnumSimple.ENUM_VALUE_2);
structHash.f6.put("10", EnumSimple.ENUM_VALUE_1);
structHash.f6.put("20", null);
structHash.f7.put("10", FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structHash.f7.put("20", FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum(), FlagsSimple.FLAG_VALUE_3.getEnum())));
structHash.f8.put("10", FlagsSimple.fromSet(EnumSet.of(FlagsSimple.FLAG_VALUE_1.getEnum(), FlagsSimple.FLAG_VALUE_2.getEnum())));
structHash.f8.put("20", null);
s1.id = 48;
structHash.f9.put("10", s1);
s2.id = 65;
structHash.f9.put("20", s2);
structHash.f10.put("10", s1);
structHash.f10.put("20", null);
System.out.println(structHash);
System.out.println();
// Print extended hash struct
var structHashEx = new StructHashEx();
s1.id = 48;
structHashEx.f1.put(s1, new StructNested());
s2.id = 65;
structHashEx.f1.put(s2, new StructNested());
structHashEx.f2.put(s1, new StructNested());
structHashEx.f2.put(s2, null);
System.out.println(structHashEx);
System.out.println();
}
}