001 //
002 // Generated by protoc, do not edit by hand.
003 //
004 package protobuf_unittest;
005
006
007 public final class MessageWithNoOuter extends MessageWithNoOuterBase<MessageWithNoOuter> {
008
009
010 public static enum NestedEnum {
011
012 BAZ("BAZ", 3);
013
014 private final String name;
015 private final int value;
016
017 private NestedEnum(String name, int value) {
018 this.name = name;
019 this.value = value;
020 }
021
022 public final int getNumber() {
023 return value;
024 }
025
026 public final String toString() {
027 return name;
028 }
029
030 public static NestedEnum valueOf(int value) {
031 switch (value) {
032 case 3:
033 return BAZ;
034 default:
035 return null;
036 }
037 }
038
039 }
040
041
042 static public final class NestedMessage extends NestedMessageBase<NestedMessage> {
043
044 public java.util.ArrayList<String> missingFields() {
045 java.util.ArrayList<String> missingFields = super.missingFields();
046 return missingFields;
047 }
048
049 public void clear() {
050 super.clear();
051 clearI();
052 }
053
054 public NestedMessage clone() {
055 return new NestedMessage().mergeFrom(this);
056 }
057
058 public NestedMessage mergeFrom(NestedMessage other) {
059 if (other.hasI()) {
060 setI(other.getI());
061 }
062 return this;
063 }
064
065 public int serializedSizeUnframed() {
066 if (memoizedSerializedSize != -1)
067 return memoizedSerializedSize;
068
069 int size = 0;
070 if (hasI()) {
071 size += org.apache.activemq.protobuf.CodedOutputStream.computeInt32Size(1, getI());
072 }
073 memoizedSerializedSize = size;
074 return size;
075 }
076
077 public NestedMessage mergeUnframed(org.apache.activemq.protobuf.CodedInputStream input) throws java.io.IOException {
078 while (true) {
079 int tag = input.readTag();
080 if ((tag & 0x07) == 4) {
081 return this;
082 }
083 switch (tag) {
084 case 0:
085 return this;
086 default: {
087 break;
088 }
089 case 8:
090 setI(input.readInt32());
091 break;
092 }
093 }
094 }
095 public void writeUnframed(org.apache.activemq.protobuf.CodedOutputStream output) throws java.io.IOException {
096 if (hasI()) {
097 output.writeInt32(1, getI());
098 }
099 }
100
101 public static NestedMessage parseUnframed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
102 return new NestedMessage().mergeUnframed(data).checktInitialized();
103 }
104
105 public static NestedMessage parseUnframed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
106 return new NestedMessage().mergeUnframed(data).checktInitialized();
107 }
108
109 public static NestedMessage parseUnframed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
110 return new NestedMessage().mergeUnframed(data).checktInitialized();
111 }
112
113 public static NestedMessage parseUnframed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
114 return new NestedMessage().mergeUnframed(data).checktInitialized();
115 }
116
117 public static NestedMessage parseFramed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
118 return new NestedMessage().mergeFramed(data).checktInitialized();
119 }
120
121 public static NestedMessage parseFramed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
122 return new NestedMessage().mergeFramed(data).checktInitialized();
123 }
124
125 public static NestedMessage parseFramed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
126 return new NestedMessage().mergeFramed(data).checktInitialized();
127 }
128
129 public static NestedMessage parseFramed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
130 return new NestedMessage().mergeFramed(data).checktInitialized();
131 }
132
133 public String toString() {
134 return toString(new java.lang.StringBuilder(), "").toString();
135 }
136
137 public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
138 if( hasI() ) {
139 sb.append(prefix+"i: ");
140 sb.append(getI());
141 sb.append("\n");
142 }
143 return sb;
144 }
145
146 public boolean equals(Object obj) {
147 if( obj==this )
148 return true;
149
150 if( obj==null || obj.getClass()!=NestedMessage.class )
151 return false;
152
153 return equals((NestedMessage)obj);
154 }
155
156 public boolean equals(NestedMessage obj) {
157 if (hasI() ^ obj.hasI() )
158 return false;
159 if (hasI() && ( getI()!=obj.getI() ))
160 return false;
161 return true;
162 }
163
164 public int hashCode() {
165 int rc=-132205840;
166 if (hasI()) {
167 rc ^= ( 73^getI() );
168 }
169 return rc;
170 }
171
172 }
173
174 static abstract class NestedMessageBase<T> extends org.apache.activemq.protobuf.BaseMessage<T> {
175
176 // optional int32 i = 1;
177 private int f_i = 0;
178 private boolean b_i;
179
180 public boolean hasI() {
181 return this.b_i;
182 }
183
184 public int getI() {
185 return this.f_i;
186 }
187
188 public T setI(int i) {
189 loadAndClear();
190 this.b_i = true;
191 this.f_i = i;
192 return (T)this;
193 }
194
195 public void clearI() {
196 loadAndClear();
197 this.b_i = false;
198 this.f_i = 0;
199 }
200
201 }
202
203 public java.util.ArrayList<String> missingFields() {
204 java.util.ArrayList<String> missingFields = super.missingFields();
205 if( hasNested() ) {
206 try {
207 getNested().assertInitialized();
208 } catch (org.apache.activemq.protobuf.UninitializedMessageException e){
209 missingFields.addAll(prefix(e.getMissingFields(),"nested."));
210 }
211 }
212 if( hasForeign() ) {
213 java.util.List<UnittestProto.TestAllTypes> l = getForeignList();
214 for( int i=0; i < l.size(); i++ ) {
215 try {
216 l.get(i).assertInitialized();
217 } catch (org.apache.activemq.protobuf.UninitializedMessageException e){
218 missingFields.addAll(prefix(e.getMissingFields(),"foreign["+i+"]"));
219 }
220 }
221 }
222 return missingFields;
223 }
224
225 public void clear() {
226 super.clear();
227 clearNested();
228 clearForeign();
229 clearNestedEnum();
230 clearForeignEnum();
231 }
232
233 public MessageWithNoOuter clone() {
234 return new MessageWithNoOuter().mergeFrom(this);
235 }
236
237 public MessageWithNoOuter mergeFrom(MessageWithNoOuter other) {
238 if (other.hasNested()) {
239 if (hasNested()) {
240 getNested().mergeFrom(other.getNested());
241 } else {
242 setNested(other.getNested().clone());
243 }
244 }
245 if (other.hasForeign()) {
246 for(UnittestProto.TestAllTypes element: other.getForeignList() ) {
247 getForeignList().add(element.clone());
248 }
249 }
250 if (other.hasNestedEnum()) {
251 setNestedEnum(other.getNestedEnum());
252 }
253 if (other.hasForeignEnum()) {
254 setForeignEnum(other.getForeignEnum());
255 }
256 return this;
257 }
258
259 public int serializedSizeUnframed() {
260 if (memoizedSerializedSize != -1)
261 return memoizedSerializedSize;
262
263 int size = 0;
264 if (hasNested()) {
265 size += computeMessageSize(1, getNested());
266 }
267 if (hasForeign()) {
268 for (UnittestProto.TestAllTypes i : getForeignList()) {
269 size += computeMessageSize(2, i);
270 }
271 }
272 if (hasNestedEnum()) {
273 size += org.apache.activemq.protobuf.CodedOutputStream.computeEnumSize(3, getNestedEnum().getNumber());
274 }
275 if (hasForeignEnum()) {
276 size += org.apache.activemq.protobuf.CodedOutputStream.computeEnumSize(4, getForeignEnum().getNumber());
277 }
278 memoizedSerializedSize = size;
279 return size;
280 }
281
282 public MessageWithNoOuter mergeUnframed(org.apache.activemq.protobuf.CodedInputStream input) throws java.io.IOException {
283 while (true) {
284 int tag = input.readTag();
285 if ((tag & 0x07) == 4) {
286 return this;
287 }
288 switch (tag) {
289 case 0:
290 return this;
291 default: {
292 break;
293 }
294 case 10:
295 if (hasNested()) {
296 getNested().mergeFramed(input);
297 } else {
298 setNested(new MessageWithNoOuter.NestedMessage().mergeFramed(input));
299 }
300 break;
301 case 18:
302 getForeignList().add(new UnittestProto.TestAllTypes().mergeFramed(input));
303 break;
304 case 24:
305 {
306 int t = input.readEnum();
307 MessageWithNoOuter.NestedEnum value = MessageWithNoOuter.NestedEnum.valueOf(t);
308 if( value !=null ) {
309 setNestedEnum(value);
310 }
311 }
312 break;
313 case 32:
314 {
315 int t = input.readEnum();
316 EnumWithNoOuter value = EnumWithNoOuter.valueOf(t);
317 if( value !=null ) {
318 setForeignEnum(value);
319 }
320 }
321 break;
322 }
323 }
324 }
325 public void writeUnframed(org.apache.activemq.protobuf.CodedOutputStream output) throws java.io.IOException {
326 if (hasNested()) {
327 writeMessage(output, 1, getNested());
328 }
329 if (hasForeign()) {
330 for (UnittestProto.TestAllTypes i : getForeignList()) {
331 writeMessage(output, 2, i);
332 }
333 }
334 if (hasNestedEnum()) {
335 output.writeEnum(3, getNestedEnum().getNumber());
336 }
337 if (hasForeignEnum()) {
338 output.writeEnum(4, getForeignEnum().getNumber());
339 }
340 }
341
342 public static MessageWithNoOuter parseUnframed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
343 return new MessageWithNoOuter().mergeUnframed(data).checktInitialized();
344 }
345
346 public static MessageWithNoOuter parseUnframed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
347 return new MessageWithNoOuter().mergeUnframed(data).checktInitialized();
348 }
349
350 public static MessageWithNoOuter parseUnframed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
351 return new MessageWithNoOuter().mergeUnframed(data).checktInitialized();
352 }
353
354 public static MessageWithNoOuter parseUnframed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
355 return new MessageWithNoOuter().mergeUnframed(data).checktInitialized();
356 }
357
358 public static MessageWithNoOuter parseFramed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
359 return new MessageWithNoOuter().mergeFramed(data).checktInitialized();
360 }
361
362 public static MessageWithNoOuter parseFramed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
363 return new MessageWithNoOuter().mergeFramed(data).checktInitialized();
364 }
365
366 public static MessageWithNoOuter parseFramed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
367 return new MessageWithNoOuter().mergeFramed(data).checktInitialized();
368 }
369
370 public static MessageWithNoOuter parseFramed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
371 return new MessageWithNoOuter().mergeFramed(data).checktInitialized();
372 }
373
374 public String toString() {
375 return toString(new java.lang.StringBuilder(), "").toString();
376 }
377
378 public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
379 if( hasNested() ) {
380 sb.append(prefix+"nested {\n");
381 getNested().toString(sb, prefix+" ");
382 sb.append(prefix+"}\n");
383 }
384 if( hasForeign() ) {
385 java.util.List<UnittestProto.TestAllTypes> l = getForeignList();
386 for( int i=0; i < l.size(); i++ ) {
387 sb.append(prefix+"foreign["+i+"] {\n");
388 l.get(i).toString(sb, prefix+" ");
389 sb.append(prefix+"}\n");
390 }
391 }
392 if( hasNestedEnum() ) {
393 sb.append(prefix+"nested_enum: ");
394 sb.append(getNestedEnum());
395 sb.append("\n");
396 }
397 if( hasForeignEnum() ) {
398 sb.append(prefix+"foreign_enum: ");
399 sb.append(getForeignEnum());
400 sb.append("\n");
401 }
402 return sb;
403 }
404
405 public boolean equals(Object obj) {
406 if( obj==this )
407 return true;
408
409 if( obj==null || obj.getClass()!=MessageWithNoOuter.class )
410 return false;
411
412 return equals((MessageWithNoOuter)obj);
413 }
414
415 public boolean equals(MessageWithNoOuter obj) {
416 if (hasNested() ^ obj.hasNested() )
417 return false;
418 if (hasNested() && ( !getNested().equals(obj.getNested()) ))
419 return false;
420 if (hasForeign() ^ obj.hasForeign() )
421 return false;
422 if (hasForeign() && ( !getForeignList().equals(obj.getForeignList()) ))
423 return false;
424 if (hasNestedEnum() ^ obj.hasNestedEnum() )
425 return false;
426 if (hasNestedEnum() && ( !getNestedEnum().equals(obj.getNestedEnum()) ))
427 return false;
428 if (hasForeignEnum() ^ obj.hasForeignEnum() )
429 return false;
430 if (hasForeignEnum() && ( !getForeignEnum().equals(obj.getForeignEnum()) ))
431 return false;
432 return true;
433 }
434
435 public int hashCode() {
436 int rc=1212750125;
437 if (hasNested()) {
438 rc ^= ( -1965077225^getNested().hashCode() );
439 }
440 if (hasForeign()) {
441 rc ^= ( 986978484^getForeignList().hashCode() );
442 }
443 if (hasNestedEnum()) {
444 rc ^= ( 1104540344^getNestedEnum().hashCode() );
445 }
446 if (hasForeignEnum()) {
447 rc ^= ( 219260885^getForeignEnum().hashCode() );
448 }
449 return rc;
450 }
451
452 }
453
454 abstract class MessageWithNoOuterBase<T> extends org.apache.activemq.protobuf.BaseMessage<T> {
455
456 // optional NestedMessage nested = 1;
457 private MessageWithNoOuter.NestedMessage f_nested = null;
458
459 public boolean hasNested() {
460 return this.f_nested!=null;
461 }
462
463 public MessageWithNoOuter.NestedMessage getNested() {
464 if( this.f_nested == null ) {
465 this.f_nested = new MessageWithNoOuter.NestedMessage();
466 }
467 return this.f_nested;
468 }
469
470 public T setNested(MessageWithNoOuter.NestedMessage nested) {
471 loadAndClear();
472 this.f_nested = nested;
473 return (T)this;
474 }
475
476 public void clearNested() {
477 loadAndClear();
478 this.f_nested = null;
479 }
480
481 // repeated TestAllTypes foreign = 2;
482 private java.util.List<UnittestProto.TestAllTypes> f_foreign;
483
484 public boolean hasForeign() {
485 return this.f_foreign!=null && !this.f_foreign.isEmpty();
486 }
487
488 public java.util.List<UnittestProto.TestAllTypes> getForeignList() {
489 if( this.f_foreign == null ) {
490 this.f_foreign = new java.util.ArrayList<UnittestProto.TestAllTypes>();
491 }
492 return this.f_foreign;
493 }
494
495 public T setForeignList(java.util.List<UnittestProto.TestAllTypes> foreign) {
496 loadAndClear();
497 this.f_foreign = foreign;
498 return (T)this;
499 }
500
501 public int getForeignCount() {
502 if( this.f_foreign == null ) {
503 return 0;
504 }
505 return this.f_foreign.size();
506 }
507
508 public UnittestProto.TestAllTypes getForeign(int index) {
509 if( this.f_foreign == null ) {
510 return null;
511 }
512 return this.f_foreign.get(index);
513 }
514
515 public T setForeign(int index, UnittestProto.TestAllTypes value) {
516 loadAndClear();
517 getForeignList().set(index, value);
518 return (T)this;
519 }
520
521 public T addForeign(UnittestProto.TestAllTypes value) {
522 loadAndClear();
523 getForeignList().add(value);
524 return (T)this;
525 }
526
527 public T addAllForeign(java.lang.Iterable<? extends UnittestProto.TestAllTypes> collection) {
528 loadAndClear();
529 super.addAll(collection, getForeignList());
530 return (T)this;
531 }
532
533 public void clearForeign() {
534 loadAndClear();
535 this.f_foreign = null;
536 }
537
538 // optional NestedEnum nested_enum = 3;
539 private MessageWithNoOuter.NestedEnum f_nestedEnum = null;
540 private boolean b_nestedEnum;
541
542 public boolean hasNestedEnum() {
543 return this.b_nestedEnum;
544 }
545
546 public MessageWithNoOuter.NestedEnum getNestedEnum() {
547 return this.f_nestedEnum;
548 }
549
550 public T setNestedEnum(MessageWithNoOuter.NestedEnum nestedEnum) {
551 loadAndClear();
552 this.b_nestedEnum = true;
553 this.f_nestedEnum = nestedEnum;
554 return (T)this;
555 }
556
557 public void clearNestedEnum() {
558 loadAndClear();
559 this.b_nestedEnum = false;
560 this.f_nestedEnum = null;
561 }
562
563 // optional EnumWithNoOuter foreign_enum = 4;
564 private EnumWithNoOuter f_foreignEnum = null;
565 private boolean b_foreignEnum;
566
567 public boolean hasForeignEnum() {
568 return this.b_foreignEnum;
569 }
570
571 public EnumWithNoOuter getForeignEnum() {
572 return this.f_foreignEnum;
573 }
574
575 public T setForeignEnum(EnumWithNoOuter foreignEnum) {
576 loadAndClear();
577 this.b_foreignEnum = true;
578 this.f_foreignEnum = foreignEnum;
579 return (T)this;
580 }
581
582 public void clearForeignEnum() {
583 loadAndClear();
584 this.b_foreignEnum = false;
585 this.f_foreignEnum = null;
586 }
587
588 }
589