0
|
1 package org.msgpack.testclasses;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.util.ArrayList;
|
|
5 import java.util.Iterator;
|
|
6 import java.util.List;
|
|
7
|
|
8 import org.junit.Ignore;
|
|
9 import org.msgpack.MessagePackable;
|
|
10 import org.msgpack.annotation.Beans;
|
|
11 import org.msgpack.annotation.Message;
|
|
12 import org.msgpack.annotation.NotNullable;
|
|
13 import org.msgpack.packer.Packer;
|
|
14 import org.msgpack.unpacker.Unpacker;
|
|
15
|
|
16
|
|
17 @Ignore @Message @Beans
|
|
18 public class MessagePackableTypeFieldsClassNotNullable {
|
|
19 @NotNullable
|
|
20 public String f0;
|
|
21
|
|
22 @NotNullable
|
|
23 public NestedClass f1;
|
|
24
|
|
25 public MessagePackableTypeFieldsClassNotNullable() {
|
|
26 }
|
|
27
|
|
28 @NotNullable
|
|
29 public String getF0() {
|
|
30 return f0;
|
|
31 }
|
|
32
|
|
33 @NotNullable
|
|
34 public void setF0(String f0) {
|
|
35 this.f0 = f0;
|
|
36 }
|
|
37
|
|
38 @NotNullable
|
|
39 public NestedClass getF1() {
|
|
40 return f1;
|
|
41 }
|
|
42
|
|
43 @NotNullable
|
|
44 public void setF1(NestedClass f1) {
|
|
45 this.f1 = f1;
|
|
46 }
|
|
47
|
|
48 @Override
|
|
49 public boolean equals(Object o) {
|
|
50 if (! (o instanceof MessagePackableTypeFieldsClassNotNullable)) {
|
|
51 return false;
|
|
52 }
|
|
53 MessagePackableTypeFieldsClassNotNullable that = (MessagePackableTypeFieldsClassNotNullable) o;
|
|
54 // f0
|
|
55 if (f0 == null) {
|
|
56 if (that.f0 != null) {
|
|
57 return false;
|
|
58 }
|
|
59 }
|
|
60 if (that.f0 != null) {
|
|
61 if (! f0.equals(that.f0)) {
|
|
62 return false;
|
|
63 }
|
|
64 }
|
|
65 // f1
|
|
66 if (f1 == null) {
|
|
67 if (that.f1 != null) {
|
|
68 return false;
|
|
69 }
|
|
70 }
|
|
71 if (that.f1 != null) {
|
|
72 if (! f1.equals(that.f1)) {
|
|
73 return false;
|
|
74 }
|
|
75 }
|
|
76 return true;
|
|
77 }
|
|
78
|
|
79 @Ignore
|
|
80 public static class NestedClass implements MessagePackable {
|
|
81 public String f0;
|
|
82
|
|
83 public int[] f1;
|
|
84
|
|
85 public List<String> f2;
|
|
86
|
|
87 public NestedClass() { }
|
|
88
|
|
89 @NotNullable
|
|
90 public String getF0() {
|
|
91 return f0;
|
|
92 }
|
|
93
|
|
94 @NotNullable
|
|
95 public void setF0(String f0) {
|
|
96 this.f0 = f0;
|
|
97 }
|
|
98
|
|
99 @NotNullable
|
|
100 public int[] getF1() {
|
|
101 return f1;
|
|
102 }
|
|
103
|
|
104 @NotNullable
|
|
105 public void setF1(int[] f1) {
|
|
106 this.f1 = f1;
|
|
107 }
|
|
108
|
|
109 @NotNullable
|
|
110 public List<String> getF2() {
|
|
111 return f2;
|
|
112 }
|
|
113
|
|
114 @NotNullable
|
|
115 public void setF2(List<String> f2) {
|
|
116 this.f2 = f2;
|
|
117 }
|
|
118
|
|
119 public void writeTo(Packer packer) throws IOException {
|
|
120 packer.writeArrayBegin(3);
|
|
121 packer.write(f0);
|
|
122 packer.writeArrayBegin(f1.length);
|
|
123 for(int e : f1) {
|
|
124 packer.write(e);
|
|
125 }
|
|
126 packer.writeArrayEnd();
|
|
127 packer.writeArrayBegin(f2.size());
|
|
128 for(String e : f2) {
|
|
129 packer.write(e);
|
|
130 }
|
|
131 packer.writeArrayEnd();
|
|
132 packer.writeArrayEnd();
|
|
133 }
|
|
134
|
|
135 public void readFrom(Unpacker uunpacker) throws IOException {
|
|
136 uunpacker.readArrayBegin();
|
|
137 f0 = uunpacker.readString();
|
|
138 int nf1 = uunpacker.readArrayBegin();
|
|
139 f1 = new int[nf1];
|
|
140 for(int i=0; i < nf1; i++) {
|
|
141 f1[i] = uunpacker.readInt();
|
|
142 }
|
|
143 uunpacker.readArrayEnd();
|
|
144 int nf2 = uunpacker.readArrayBegin();
|
|
145 f2 = new ArrayList<String>(nf2);
|
|
146 for(int i=0; i < nf2; i++) {
|
|
147 f2.add(uunpacker.readString());
|
|
148 }
|
|
149 uunpacker.readArrayEnd();
|
|
150 uunpacker.readArrayEnd();
|
|
151 }
|
|
152
|
|
153 @Override
|
|
154 public boolean equals(Object o) {
|
|
155 if (! (o instanceof NestedClass)) {
|
|
156 return false;
|
|
157 }
|
|
158 NestedClass that = (NestedClass) o;
|
|
159 // f0
|
|
160 if (f0 == null) {
|
|
161 if (that.f0 != null) {
|
|
162 return false;
|
|
163 }
|
|
164 }
|
|
165 if (that.f0 != null) {
|
|
166 if (! f0.equals(that.f0)) {
|
|
167 return false;
|
|
168 }
|
|
169 }
|
|
170 // f1
|
|
171 if (f1 == null) {
|
|
172 if (that.f1 != null) {
|
|
173 return false;
|
|
174 }
|
|
175 }
|
|
176 if (that.f1 != null) {
|
|
177 if (f1.length != that.f1.length) {
|
|
178 return false;
|
|
179 }
|
|
180 for (int i = 0; i < f1.length; ++i) {
|
|
181 if (f1[i] != that.f1[i]) {
|
|
182 return false;
|
|
183 }
|
|
184 }
|
|
185 }
|
|
186 // f2
|
|
187 if (f2 == null) {
|
|
188 if (that.f2 != null) {
|
|
189 return false;
|
|
190 }
|
|
191 }
|
|
192 if (that.f2 != null) {
|
|
193 Iterator<String> this_f2_iter = f2.iterator();
|
|
194 Iterator<String> that_f2_iter = that.f2.iterator();
|
|
195 for (; this_f2_iter.hasNext(); ) {
|
|
196 if (! this_f2_iter.next().equals(that_f2_iter.next())) {
|
|
197 return false;
|
|
198 }
|
|
199 }
|
|
200 }
|
|
201 return true;
|
|
202 }
|
|
203 }
|
|
204 }
|