/protocolBuffer/src/com/example/tutorial/AddressBookProtos.java

http://javawing.googlecode.com/ · Java · 1228 lines · 1097 code · 110 blank · 21 comment · 113 complexity · 4c30554df46df9eff6e028cbf6c2674f MD5 · raw file

  1. // Generated by the protocol buffer compiler. DO NOT EDIT!
  2. package com.example.tutorial;
  3. public final class AddressBookProtos {
  4. private AddressBookProtos() {}
  5. public static void registerAllExtensions(
  6. com.google.protobuf.ExtensionRegistry registry) {
  7. }
  8. public static final class Person extends
  9. com.google.protobuf.GeneratedMessage {
  10. // Use Person.newBuilder() to construct.
  11. private Person() {}
  12. private static final Person defaultInstance = new Person();
  13. public static Person getDefaultInstance() {
  14. return defaultInstance;
  15. }
  16. public Person getDefaultInstanceForType() {
  17. return defaultInstance;
  18. }
  19. public static final com.google.protobuf.Descriptors.Descriptor
  20. getDescriptor() {
  21. return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_descriptor;
  22. }
  23. protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
  24. internalGetFieldAccessorTable() {
  25. return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_fieldAccessorTable;
  26. }
  27. public enum PhoneType
  28. implements com.google.protobuf.ProtocolMessageEnum {
  29. MOBILE(0, 0),
  30. HOME(1, 1),
  31. WORK(2, 2),
  32. ;
  33. public final int getNumber() { return value; }
  34. public static PhoneType valueOf(int value) {
  35. switch (value) {
  36. case 0: return MOBILE;
  37. case 1: return HOME;
  38. case 2: return WORK;
  39. default: return null;
  40. }
  41. }
  42. public static com.google.protobuf.Internal.EnumLiteMap<PhoneType>
  43. internalGetValueMap() {
  44. return internalValueMap;
  45. }
  46. private static com.google.protobuf.Internal.EnumLiteMap<PhoneType>
  47. internalValueMap =
  48. new com.google.protobuf.Internal.EnumLiteMap<PhoneType>() {
  49. public PhoneType findValueByNumber(int number) {
  50. return PhoneType.valueOf(number)
  51. ; }
  52. };
  53. public final com.google.protobuf.Descriptors.EnumValueDescriptor
  54. getValueDescriptor() {
  55. return getDescriptor().getValues().get(index);
  56. }
  57. public final com.google.protobuf.Descriptors.EnumDescriptor
  58. getDescriptorForType() {
  59. return getDescriptor();
  60. }
  61. public static final com.google.protobuf.Descriptors.EnumDescriptor
  62. getDescriptor() {
  63. return com.example.tutorial.AddressBookProtos.Person.getDescriptor().getEnumTypes().get(0);
  64. }
  65. private static final PhoneType[] VALUES = {
  66. MOBILE, HOME, WORK,
  67. };
  68. public static PhoneType valueOf(
  69. com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
  70. if (desc.getType() != getDescriptor()) {
  71. throw new java.lang.IllegalArgumentException(
  72. "EnumValueDescriptor is not for this type.");
  73. }
  74. return VALUES[desc.getIndex()];
  75. }
  76. private final int index;
  77. private final int value;
  78. private PhoneType(int index, int value) {
  79. this.index = index;
  80. this.value = value;
  81. }
  82. static {
  83. com.example.tutorial.AddressBookProtos.getDescriptor();
  84. }
  85. }
  86. public static final class PhoneNumber extends
  87. com.google.protobuf.GeneratedMessage {
  88. // Use PhoneNumber.newBuilder() to construct.
  89. private PhoneNumber() {}
  90. private static final PhoneNumber defaultInstance = new PhoneNumber();
  91. public static PhoneNumber getDefaultInstance() {
  92. return defaultInstance;
  93. }
  94. public PhoneNumber getDefaultInstanceForType() {
  95. return defaultInstance;
  96. }
  97. public static final com.google.protobuf.Descriptors.Descriptor
  98. getDescriptor() {
  99. return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_PhoneNumber_descriptor;
  100. }
  101. protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
  102. internalGetFieldAccessorTable() {
  103. return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable;
  104. }
  105. // required string number = 1;
  106. public static final int NUMBER_FIELD_NUMBER = 1;
  107. private boolean hasNumber;
  108. private java.lang.String number_ = "";
  109. public boolean hasNumber() { return hasNumber; }
  110. public java.lang.String getNumber() { return number_; }
  111. // optional .tutorial.Person.PhoneType type = 2 [default = HOME];
  112. public static final int TYPE_FIELD_NUMBER = 2;
  113. private boolean hasType;
  114. private com.example.tutorial.AddressBookProtos.Person.PhoneType type_ = com.example.tutorial.AddressBookProtos.Person.PhoneType.HOME;
  115. public boolean hasType() { return hasType; }
  116. public com.example.tutorial.AddressBookProtos.Person.PhoneType getType() { return type_; }
  117. public final boolean isInitialized() {
  118. if (!hasNumber) return false;
  119. return true;
  120. }
  121. public void writeTo(com.google.protobuf.CodedOutputStream output)
  122. throws java.io.IOException {
  123. if (hasNumber()) {
  124. output.writeString(1, getNumber());
  125. }
  126. if (hasType()) {
  127. output.writeEnum(2, getType().getNumber());
  128. }
  129. getUnknownFields().writeTo(output);
  130. }
  131. private int memoizedSerializedSize = -1;
  132. public int getSerializedSize() {
  133. int size = memoizedSerializedSize;
  134. if (size != -1) return size;
  135. size = 0;
  136. if (hasNumber()) {
  137. size += com.google.protobuf.CodedOutputStream
  138. .computeStringSize(1, getNumber());
  139. }
  140. if (hasType()) {
  141. size += com.google.protobuf.CodedOutputStream
  142. .computeEnumSize(2, getType().getNumber());
  143. }
  144. size += getUnknownFields().getSerializedSize();
  145. memoizedSerializedSize = size;
  146. return size;
  147. }
  148. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(
  149. com.google.protobuf.ByteString data)
  150. throws com.google.protobuf.InvalidProtocolBufferException {
  151. return newBuilder().mergeFrom(data).buildParsed();
  152. }
  153. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(
  154. com.google.protobuf.ByteString data,
  155. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  156. throws com.google.protobuf.InvalidProtocolBufferException {
  157. return newBuilder().mergeFrom(data, extensionRegistry)
  158. .buildParsed();
  159. }
  160. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(byte[] data)
  161. throws com.google.protobuf.InvalidProtocolBufferException {
  162. return newBuilder().mergeFrom(data).buildParsed();
  163. }
  164. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(
  165. byte[] data,
  166. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  167. throws com.google.protobuf.InvalidProtocolBufferException {
  168. return newBuilder().mergeFrom(data, extensionRegistry)
  169. .buildParsed();
  170. }
  171. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(java.io.InputStream input)
  172. throws java.io.IOException {
  173. return newBuilder().mergeFrom(input).buildParsed();
  174. }
  175. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(
  176. java.io.InputStream input,
  177. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  178. throws java.io.IOException {
  179. return newBuilder().mergeFrom(input, extensionRegistry)
  180. .buildParsed();
  181. }
  182. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseDelimitedFrom(java.io.InputStream input)
  183. throws java.io.IOException {
  184. return newBuilder().mergeDelimitedFrom(input).buildParsed();
  185. }
  186. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseDelimitedFrom(
  187. java.io.InputStream input,
  188. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  189. throws java.io.IOException {
  190. return newBuilder().mergeDelimitedFrom(input, extensionRegistry)
  191. .buildParsed();
  192. }
  193. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(
  194. com.google.protobuf.CodedInputStream input)
  195. throws java.io.IOException {
  196. return newBuilder().mergeFrom(input).buildParsed();
  197. }
  198. public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(
  199. com.google.protobuf.CodedInputStream input,
  200. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  201. throws java.io.IOException {
  202. return newBuilder().mergeFrom(input, extensionRegistry)
  203. .buildParsed();
  204. }
  205. public static Builder newBuilder() { return Builder.create(); }
  206. public Builder newBuilderForType() { return newBuilder(); }
  207. public static Builder newBuilder(com.example.tutorial.AddressBookProtos.Person.PhoneNumber prototype) {
  208. return newBuilder().mergeFrom(prototype);
  209. }
  210. public Builder toBuilder() { return newBuilder(this); }
  211. public static final class Builder extends
  212. com.google.protobuf.GeneratedMessage.Builder<Builder> {
  213. private com.example.tutorial.AddressBookProtos.Person.PhoneNumber result;
  214. // Construct using com.example.tutorial.AddressBookProtos.Person.PhoneNumber.newBuilder()
  215. private Builder() {}
  216. private static Builder create() {
  217. Builder builder = new Builder();
  218. builder.result = new com.example.tutorial.AddressBookProtos.Person.PhoneNumber();
  219. return builder;
  220. }
  221. protected com.example.tutorial.AddressBookProtos.Person.PhoneNumber internalGetResult() {
  222. return result;
  223. }
  224. public Builder clear() {
  225. if (result == null) {
  226. throw new IllegalStateException(
  227. "Cannot call clear() after build().");
  228. }
  229. result = new com.example.tutorial.AddressBookProtos.Person.PhoneNumber();
  230. return this;
  231. }
  232. public Builder clone() {
  233. return create().mergeFrom(result);
  234. }
  235. public com.google.protobuf.Descriptors.Descriptor
  236. getDescriptorForType() {
  237. return com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDescriptor();
  238. }
  239. public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getDefaultInstanceForType() {
  240. return com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDefaultInstance();
  241. }
  242. public boolean isInitialized() {
  243. return result.isInitialized();
  244. }
  245. public com.example.tutorial.AddressBookProtos.Person.PhoneNumber build() {
  246. if (result != null && !isInitialized()) {
  247. throw newUninitializedMessageException(result);
  248. }
  249. return buildPartial();
  250. }
  251. private com.example.tutorial.AddressBookProtos.Person.PhoneNumber buildParsed()
  252. throws com.google.protobuf.InvalidProtocolBufferException {
  253. if (!isInitialized()) {
  254. throw newUninitializedMessageException(
  255. result).asInvalidProtocolBufferException();
  256. }
  257. return buildPartial();
  258. }
  259. public com.example.tutorial.AddressBookProtos.Person.PhoneNumber buildPartial() {
  260. if (result == null) {
  261. throw new IllegalStateException(
  262. "build() has already been called on this Builder.");
  263. }
  264. com.example.tutorial.AddressBookProtos.Person.PhoneNumber returnMe = result;
  265. result = null;
  266. return returnMe;
  267. }
  268. public Builder mergeFrom(com.google.protobuf.Message other) {
  269. if (other instanceof com.example.tutorial.AddressBookProtos.Person.PhoneNumber) {
  270. return mergeFrom((com.example.tutorial.AddressBookProtos.Person.PhoneNumber)other);
  271. } else {
  272. super.mergeFrom(other);
  273. return this;
  274. }
  275. }
  276. public Builder mergeFrom(com.example.tutorial.AddressBookProtos.Person.PhoneNumber other) {
  277. if (other == com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDefaultInstance()) return this;
  278. if (other.hasNumber()) {
  279. setNumber(other.getNumber());
  280. }
  281. if (other.hasType()) {
  282. setType(other.getType());
  283. }
  284. this.mergeUnknownFields(other.getUnknownFields());
  285. return this;
  286. }
  287. public Builder mergeFrom(
  288. com.google.protobuf.CodedInputStream input,
  289. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  290. throws java.io.IOException {
  291. com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  292. com.google.protobuf.UnknownFieldSet.newBuilder(
  293. this.getUnknownFields());
  294. while (true) {
  295. int tag = input.readTag();
  296. switch (tag) {
  297. case 0:
  298. this.setUnknownFields(unknownFields.build());
  299. return this;
  300. default: {
  301. if (!parseUnknownField(input, unknownFields,
  302. extensionRegistry, tag)) {
  303. this.setUnknownFields(unknownFields.build());
  304. return this;
  305. }
  306. break;
  307. }
  308. case 10: {
  309. setNumber(input.readString());
  310. break;
  311. }
  312. case 16: {
  313. int rawValue = input.readEnum();
  314. com.example.tutorial.AddressBookProtos.Person.PhoneType value = com.example.tutorial.AddressBookProtos.Person.PhoneType.valueOf(rawValue);
  315. if (value == null) {
  316. unknownFields.mergeVarintField(2, rawValue);
  317. } else {
  318. setType(value);
  319. }
  320. break;
  321. }
  322. }
  323. }
  324. }
  325. // required string number = 1;
  326. public boolean hasNumber() {
  327. return result.hasNumber();
  328. }
  329. public java.lang.String getNumber() {
  330. return result.getNumber();
  331. }
  332. public Builder setNumber(java.lang.String value) {
  333. if (value == null) {
  334. throw new NullPointerException();
  335. }
  336. result.hasNumber = true;
  337. result.number_ = value;
  338. return this;
  339. }
  340. public Builder clearNumber() {
  341. result.hasNumber = false;
  342. result.number_ = getDefaultInstance().getNumber();
  343. return this;
  344. }
  345. // optional .tutorial.Person.PhoneType type = 2 [default = HOME];
  346. public boolean hasType() {
  347. return result.hasType();
  348. }
  349. public com.example.tutorial.AddressBookProtos.Person.PhoneType getType() {
  350. return result.getType();
  351. }
  352. public Builder setType(com.example.tutorial.AddressBookProtos.Person.PhoneType value) {
  353. if (value == null) {
  354. throw new NullPointerException();
  355. }
  356. result.hasType = true;
  357. result.type_ = value;
  358. return this;
  359. }
  360. public Builder clearType() {
  361. result.hasType = false;
  362. result.type_ = com.example.tutorial.AddressBookProtos.Person.PhoneType.HOME;
  363. return this;
  364. }
  365. }
  366. static {
  367. com.example.tutorial.AddressBookProtos.getDescriptor();
  368. }
  369. static {
  370. com.example.tutorial.AddressBookProtos.internalForceInit();
  371. }
  372. }
  373. // required string name = 1;
  374. public static final int NAME_FIELD_NUMBER = 1;
  375. private boolean hasName;
  376. private java.lang.String name_ = "";
  377. public boolean hasName() { return hasName; }
  378. public java.lang.String getName() { return name_; }
  379. // required int32 id = 2;
  380. public static final int ID_FIELD_NUMBER = 2;
  381. private boolean hasId;
  382. private int id_ = 0;
  383. public boolean hasId() { return hasId; }
  384. public int getId() { return id_; }
  385. // optional string email = 3;
  386. public static final int EMAIL_FIELD_NUMBER = 3;
  387. private boolean hasEmail;
  388. private java.lang.String email_ = "";
  389. public boolean hasEmail() { return hasEmail; }
  390. public java.lang.String getEmail() { return email_; }
  391. // repeated .tutorial.Person.PhoneNumber phone = 4;
  392. public static final int PHONE_FIELD_NUMBER = 4;
  393. private java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> phone_ =
  394. java.util.Collections.emptyList();
  395. public java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> getPhoneList() {
  396. return phone_;
  397. }
  398. public int getPhoneCount() { return phone_.size(); }
  399. public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getPhone(int index) {
  400. return phone_.get(index);
  401. }
  402. public final boolean isInitialized() {
  403. if (!hasName) return false;
  404. if (!hasId) return false;
  405. for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
  406. if (!element.isInitialized()) return false;
  407. }
  408. return true;
  409. }
  410. public void writeTo(com.google.protobuf.CodedOutputStream output)
  411. throws java.io.IOException {
  412. if (hasName()) {
  413. output.writeString(1, getName());
  414. }
  415. if (hasId()) {
  416. output.writeInt32(2, getId());
  417. }
  418. if (hasEmail()) {
  419. output.writeString(3, getEmail());
  420. }
  421. for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
  422. output.writeMessage(4, element);
  423. }
  424. getUnknownFields().writeTo(output);
  425. }
  426. private int memoizedSerializedSize = -1;
  427. public int getSerializedSize() {
  428. int size = memoizedSerializedSize;
  429. if (size != -1) return size;
  430. size = 0;
  431. if (hasName()) {
  432. size += com.google.protobuf.CodedOutputStream
  433. .computeStringSize(1, getName());
  434. }
  435. if (hasId()) {
  436. size += com.google.protobuf.CodedOutputStream
  437. .computeInt32Size(2, getId());
  438. }
  439. if (hasEmail()) {
  440. size += com.google.protobuf.CodedOutputStream
  441. .computeStringSize(3, getEmail());
  442. }
  443. for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
  444. size += com.google.protobuf.CodedOutputStream
  445. .computeMessageSize(4, element);
  446. }
  447. size += getUnknownFields().getSerializedSize();
  448. memoizedSerializedSize = size;
  449. return size;
  450. }
  451. public static com.example.tutorial.AddressBookProtos.Person parseFrom(
  452. com.google.protobuf.ByteString data)
  453. throws com.google.protobuf.InvalidProtocolBufferException {
  454. return newBuilder().mergeFrom(data).buildParsed();
  455. }
  456. public static com.example.tutorial.AddressBookProtos.Person parseFrom(
  457. com.google.protobuf.ByteString data,
  458. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  459. throws com.google.protobuf.InvalidProtocolBufferException {
  460. return newBuilder().mergeFrom(data, extensionRegistry)
  461. .buildParsed();
  462. }
  463. public static com.example.tutorial.AddressBookProtos.Person parseFrom(byte[] data)
  464. throws com.google.protobuf.InvalidProtocolBufferException {
  465. return newBuilder().mergeFrom(data).buildParsed();
  466. }
  467. public static com.example.tutorial.AddressBookProtos.Person parseFrom(
  468. byte[] data,
  469. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  470. throws com.google.protobuf.InvalidProtocolBufferException {
  471. return newBuilder().mergeFrom(data, extensionRegistry)
  472. .buildParsed();
  473. }
  474. public static com.example.tutorial.AddressBookProtos.Person parseFrom(java.io.InputStream input)
  475. throws java.io.IOException {
  476. return newBuilder().mergeFrom(input).buildParsed();
  477. }
  478. public static com.example.tutorial.AddressBookProtos.Person parseFrom(
  479. java.io.InputStream input,
  480. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  481. throws java.io.IOException {
  482. return newBuilder().mergeFrom(input, extensionRegistry)
  483. .buildParsed();
  484. }
  485. public static com.example.tutorial.AddressBookProtos.Person parseDelimitedFrom(java.io.InputStream input)
  486. throws java.io.IOException {
  487. return newBuilder().mergeDelimitedFrom(input).buildParsed();
  488. }
  489. public static com.example.tutorial.AddressBookProtos.Person parseDelimitedFrom(
  490. java.io.InputStream input,
  491. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  492. throws java.io.IOException {
  493. return newBuilder().mergeDelimitedFrom(input, extensionRegistry)
  494. .buildParsed();
  495. }
  496. public static com.example.tutorial.AddressBookProtos.Person parseFrom(
  497. com.google.protobuf.CodedInputStream input)
  498. throws java.io.IOException {
  499. return newBuilder().mergeFrom(input).buildParsed();
  500. }
  501. public static com.example.tutorial.AddressBookProtos.Person parseFrom(
  502. com.google.protobuf.CodedInputStream input,
  503. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  504. throws java.io.IOException {
  505. return newBuilder().mergeFrom(input, extensionRegistry)
  506. .buildParsed();
  507. }
  508. public static Builder newBuilder() { return Builder.create(); }
  509. public Builder newBuilderForType() { return newBuilder(); }
  510. public static Builder newBuilder(com.example.tutorial.AddressBookProtos.Person prototype) {
  511. return newBuilder().mergeFrom(prototype);
  512. }
  513. public Builder toBuilder() { return newBuilder(this); }
  514. public static final class Builder extends
  515. com.google.protobuf.GeneratedMessage.Builder<Builder> {
  516. private com.example.tutorial.AddressBookProtos.Person result;
  517. // Construct using com.example.tutorial.AddressBookProtos.Person.newBuilder()
  518. private Builder() {}
  519. private static Builder create() {
  520. Builder builder = new Builder();
  521. builder.result = new com.example.tutorial.AddressBookProtos.Person();
  522. return builder;
  523. }
  524. protected com.example.tutorial.AddressBookProtos.Person internalGetResult() {
  525. return result;
  526. }
  527. public Builder clear() {
  528. if (result == null) {
  529. throw new IllegalStateException(
  530. "Cannot call clear() after build().");
  531. }
  532. result = new com.example.tutorial.AddressBookProtos.Person();
  533. return this;
  534. }
  535. public Builder clone() {
  536. return create().mergeFrom(result);
  537. }
  538. public com.google.protobuf.Descriptors.Descriptor
  539. getDescriptorForType() {
  540. return com.example.tutorial.AddressBookProtos.Person.getDescriptor();
  541. }
  542. public com.example.tutorial.AddressBookProtos.Person getDefaultInstanceForType() {
  543. return com.example.tutorial.AddressBookProtos.Person.getDefaultInstance();
  544. }
  545. public boolean isInitialized() {
  546. return result.isInitialized();
  547. }
  548. public com.example.tutorial.AddressBookProtos.Person build() {
  549. if (result != null && !isInitialized()) {
  550. throw newUninitializedMessageException(result);
  551. }
  552. return buildPartial();
  553. }
  554. private com.example.tutorial.AddressBookProtos.Person buildParsed()
  555. throws com.google.protobuf.InvalidProtocolBufferException {
  556. if (!isInitialized()) {
  557. throw newUninitializedMessageException(
  558. result).asInvalidProtocolBufferException();
  559. }
  560. return buildPartial();
  561. }
  562. public com.example.tutorial.AddressBookProtos.Person buildPartial() {
  563. if (result == null) {
  564. throw new IllegalStateException(
  565. "build() has already been called on this Builder.");
  566. }
  567. if (result.phone_ != java.util.Collections.EMPTY_LIST) {
  568. result.phone_ =
  569. java.util.Collections.unmodifiableList(result.phone_);
  570. }
  571. com.example.tutorial.AddressBookProtos.Person returnMe = result;
  572. result = null;
  573. return returnMe;
  574. }
  575. public Builder mergeFrom(com.google.protobuf.Message other) {
  576. if (other instanceof com.example.tutorial.AddressBookProtos.Person) {
  577. return mergeFrom((com.example.tutorial.AddressBookProtos.Person)other);
  578. } else {
  579. super.mergeFrom(other);
  580. return this;
  581. }
  582. }
  583. public Builder mergeFrom(com.example.tutorial.AddressBookProtos.Person other) {
  584. if (other == com.example.tutorial.AddressBookProtos.Person.getDefaultInstance()) return this;
  585. if (other.hasName()) {
  586. setName(other.getName());
  587. }
  588. if (other.hasId()) {
  589. setId(other.getId());
  590. }
  591. if (other.hasEmail()) {
  592. setEmail(other.getEmail());
  593. }
  594. if (!other.phone_.isEmpty()) {
  595. if (result.phone_.isEmpty()) {
  596. result.phone_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
  597. }
  598. result.phone_.addAll(other.phone_);
  599. }
  600. this.mergeUnknownFields(other.getUnknownFields());
  601. return this;
  602. }
  603. public Builder mergeFrom(
  604. com.google.protobuf.CodedInputStream input,
  605. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  606. throws java.io.IOException {
  607. com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  608. com.google.protobuf.UnknownFieldSet.newBuilder(
  609. this.getUnknownFields());
  610. while (true) {
  611. int tag = input.readTag();
  612. switch (tag) {
  613. case 0:
  614. this.setUnknownFields(unknownFields.build());
  615. return this;
  616. default: {
  617. if (!parseUnknownField(input, unknownFields,
  618. extensionRegistry, tag)) {
  619. this.setUnknownFields(unknownFields.build());
  620. return this;
  621. }
  622. break;
  623. }
  624. case 10: {
  625. setName(input.readString());
  626. break;
  627. }
  628. case 16: {
  629. setId(input.readInt32());
  630. break;
  631. }
  632. case 26: {
  633. setEmail(input.readString());
  634. break;
  635. }
  636. case 34: {
  637. com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder subBuilder = com.example.tutorial.AddressBookProtos.Person.PhoneNumber.newBuilder();
  638. input.readMessage(subBuilder, extensionRegistry);
  639. addPhone(subBuilder.buildPartial());
  640. break;
  641. }
  642. }
  643. }
  644. }
  645. // required string name = 1;
  646. public boolean hasName() {
  647. return result.hasName();
  648. }
  649. public java.lang.String getName() {
  650. return result.getName();
  651. }
  652. public Builder setName(java.lang.String value) {
  653. if (value == null) {
  654. throw new NullPointerException();
  655. }
  656. result.hasName = true;
  657. result.name_ = value;
  658. return this;
  659. }
  660. public Builder clearName() {
  661. result.hasName = false;
  662. result.name_ = getDefaultInstance().getName();
  663. return this;
  664. }
  665. // required int32 id = 2;
  666. public boolean hasId() {
  667. return result.hasId();
  668. }
  669. public int getId() {
  670. return result.getId();
  671. }
  672. public Builder setId(int value) {
  673. result.hasId = true;
  674. result.id_ = value;
  675. return this;
  676. }
  677. public Builder clearId() {
  678. result.hasId = false;
  679. result.id_ = 0;
  680. return this;
  681. }
  682. // optional string email = 3;
  683. public boolean hasEmail() {
  684. return result.hasEmail();
  685. }
  686. public java.lang.String getEmail() {
  687. return result.getEmail();
  688. }
  689. public Builder setEmail(java.lang.String value) {
  690. if (value == null) {
  691. throw new NullPointerException();
  692. }
  693. result.hasEmail = true;
  694. result.email_ = value;
  695. return this;
  696. }
  697. public Builder clearEmail() {
  698. result.hasEmail = false;
  699. result.email_ = getDefaultInstance().getEmail();
  700. return this;
  701. }
  702. // repeated .tutorial.Person.PhoneNumber phone = 4;
  703. public java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> getPhoneList() {
  704. return java.util.Collections.unmodifiableList(result.phone_);
  705. }
  706. public int getPhoneCount() {
  707. return result.getPhoneCount();
  708. }
  709. public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getPhone(int index) {
  710. return result.getPhone(index);
  711. }
  712. public Builder setPhone(int index, com.example.tutorial.AddressBookProtos.Person.PhoneNumber value) {
  713. if (value == null) {
  714. throw new NullPointerException();
  715. }
  716. result.phone_.set(index, value);
  717. return this;
  718. }
  719. public Builder setPhone(int index, com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
  720. result.phone_.set(index, builderForValue.build());
  721. return this;
  722. }
  723. public Builder addPhone(com.example.tutorial.AddressBookProtos.Person.PhoneNumber value) {
  724. if (value == null) {
  725. throw new NullPointerException();
  726. }
  727. if (result.phone_.isEmpty()) {
  728. result.phone_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
  729. }
  730. result.phone_.add(value);
  731. return this;
  732. }
  733. public Builder addPhone(com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
  734. if (result.phone_.isEmpty()) {
  735. result.phone_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
  736. }
  737. result.phone_.add(builderForValue.build());
  738. return this;
  739. }
  740. public Builder addAllPhone(
  741. java.lang.Iterable<? extends com.example.tutorial.AddressBookProtos.Person.PhoneNumber> values) {
  742. if (result.phone_.isEmpty()) {
  743. result.phone_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
  744. }
  745. super.addAll(values, result.phone_);
  746. return this;
  747. }
  748. public Builder clearPhone() {
  749. result.phone_ = java.util.Collections.emptyList();
  750. return this;
  751. }
  752. }
  753. static {
  754. com.example.tutorial.AddressBookProtos.getDescriptor();
  755. }
  756. static {
  757. com.example.tutorial.AddressBookProtos.internalForceInit();
  758. }
  759. }
  760. public static final class AddressBook extends
  761. com.google.protobuf.GeneratedMessage {
  762. // Use AddressBook.newBuilder() to construct.
  763. private AddressBook() {}
  764. private static final AddressBook defaultInstance = new AddressBook();
  765. public static AddressBook getDefaultInstance() {
  766. return defaultInstance;
  767. }
  768. public AddressBook getDefaultInstanceForType() {
  769. return defaultInstance;
  770. }
  771. public static final com.google.protobuf.Descriptors.Descriptor
  772. getDescriptor() {
  773. return com.example.tutorial.AddressBookProtos.internal_static_tutorial_AddressBook_descriptor;
  774. }
  775. protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
  776. internalGetFieldAccessorTable() {
  777. return com.example.tutorial.AddressBookProtos.internal_static_tutorial_AddressBook_fieldAccessorTable;
  778. }
  779. // repeated .tutorial.Person person = 1;
  780. public static final int PERSON_FIELD_NUMBER = 1;
  781. private java.util.List<com.example.tutorial.AddressBookProtos.Person> person_ =
  782. java.util.Collections.emptyList();
  783. public java.util.List<com.example.tutorial.AddressBookProtos.Person> getPersonList() {
  784. return person_;
  785. }
  786. public int getPersonCount() { return person_.size(); }
  787. public com.example.tutorial.AddressBookProtos.Person getPerson(int index) {
  788. return person_.get(index);
  789. }
  790. public final boolean isInitialized() {
  791. for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
  792. if (!element.isInitialized()) return false;
  793. }
  794. return true;
  795. }
  796. public void writeTo(com.google.protobuf.CodedOutputStream output)
  797. throws java.io.IOException {
  798. for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
  799. output.writeMessage(1, element);
  800. }
  801. getUnknownFields().writeTo(output);
  802. }
  803. private int memoizedSerializedSize = -1;
  804. public int getSerializedSize() {
  805. int size = memoizedSerializedSize;
  806. if (size != -1) return size;
  807. size = 0;
  808. for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
  809. size += com.google.protobuf.CodedOutputStream
  810. .computeMessageSize(1, element);
  811. }
  812. size += getUnknownFields().getSerializedSize();
  813. memoizedSerializedSize = size;
  814. return size;
  815. }
  816. public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(
  817. com.google.protobuf.ByteString data)
  818. throws com.google.protobuf.InvalidProtocolBufferException {
  819. return newBuilder().mergeFrom(data).buildParsed();
  820. }
  821. public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(
  822. com.google.protobuf.ByteString data,
  823. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  824. throws com.google.protobuf.InvalidProtocolBufferException {
  825. return newBuilder().mergeFrom(data, extensionRegistry)
  826. .buildParsed();
  827. }
  828. public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(byte[] data)
  829. throws com.google.protobuf.InvalidProtocolBufferException {
  830. return newBuilder().mergeFrom(data).buildParsed();
  831. }
  832. public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(
  833. byte[] data,
  834. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  835. throws com.google.protobuf.InvalidProtocolBufferException {
  836. return newBuilder().mergeFrom(data, extensionRegistry)
  837. .buildParsed();
  838. }
  839. public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(java.io.InputStream input)
  840. throws java.io.IOException {
  841. return newBuilder().mergeFrom(input).buildParsed();
  842. }
  843. public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(
  844. java.io.InputStream input,
  845. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  846. throws java.io.IOException {
  847. return newBuilder().mergeFrom(input, extensionRegistry)
  848. .buildParsed();
  849. }
  850. public static com.example.tutorial.AddressBookProtos.AddressBook parseDelimitedFrom(java.io.InputStream input)
  851. throws java.io.IOException {
  852. return newBuilder().mergeDelimitedFrom(input).buildParsed();
  853. }
  854. public static com.example.tutorial.AddressBookProtos.AddressBook parseDelimitedFrom(
  855. java.io.InputStream input,
  856. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  857. throws java.io.IOException {
  858. return newBuilder().mergeDelimitedFrom(input, extensionRegistry)
  859. .buildParsed();
  860. }
  861. public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(
  862. com.google.protobuf.CodedInputStream input)
  863. throws java.io.IOException {
  864. return newBuilder().mergeFrom(input).buildParsed();
  865. }
  866. public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(
  867. com.google.protobuf.CodedInputStream input,
  868. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  869. throws java.io.IOException {
  870. return newBuilder().mergeFrom(input, extensionRegistry)
  871. .buildParsed();
  872. }
  873. public static Builder newBuilder() { return Builder.create(); }
  874. public Builder newBuilderForType() { return newBuilder(); }
  875. public static Builder newBuilder(com.example.tutorial.AddressBookProtos.AddressBook prototype) {
  876. return newBuilder().mergeFrom(prototype);
  877. }
  878. public Builder toBuilder() { return newBuilder(this); }
  879. public static final class Builder extends
  880. com.google.protobuf.GeneratedMessage.Builder<Builder> {
  881. private com.example.tutorial.AddressBookProtos.AddressBook result;
  882. // Construct using com.example.tutorial.AddressBookProtos.AddressBook.newBuilder()
  883. private Builder() {}
  884. private static Builder create() {
  885. Builder builder = new Builder();
  886. builder.result = new com.example.tutorial.AddressBookProtos.AddressBook();
  887. return builder;
  888. }
  889. protected com.example.tutorial.AddressBookProtos.AddressBook internalGetResult() {
  890. return result;
  891. }
  892. public Builder clear() {
  893. if (result == null) {
  894. throw new IllegalStateException(
  895. "Cannot call clear() after build().");
  896. }
  897. result = new com.example.tutorial.AddressBookProtos.AddressBook();
  898. return this;
  899. }
  900. public Builder clone() {
  901. return create().mergeFrom(result);
  902. }
  903. public com.google.protobuf.Descriptors.Descriptor
  904. getDescriptorForType() {
  905. return com.example.tutorial.AddressBookProtos.AddressBook.getDescriptor();
  906. }
  907. public com.example.tutorial.AddressBookProtos.AddressBook getDefaultInstanceForType() {
  908. return com.example.tutorial.AddressBookProtos.AddressBook.getDefaultInstance();
  909. }
  910. public boolean isInitialized() {
  911. return result.isInitialized();
  912. }
  913. public com.example.tutorial.AddressBookProtos.AddressBook build() {
  914. if (result != null && !isInitialized()) {
  915. throw newUninitializedMessageException(result);
  916. }
  917. return buildPartial();
  918. }
  919. private com.example.tutorial.AddressBookProtos.AddressBook buildParsed()
  920. throws com.google.protobuf.InvalidProtocolBufferException {
  921. if (!isInitialized()) {
  922. throw newUninitializedMessageException(
  923. result).asInvalidProtocolBufferException();
  924. }
  925. return buildPartial();
  926. }
  927. public com.example.tutorial.AddressBookProtos.AddressBook buildPartial() {
  928. if (result == null) {
  929. throw new IllegalStateException(
  930. "build() has already been called on this Builder.");
  931. }
  932. if (result.person_ != java.util.Collections.EMPTY_LIST) {
  933. result.person_ =
  934. java.util.Collections.unmodifiableList(result.person_);
  935. }
  936. com.example.tutorial.AddressBookProtos.AddressBook returnMe = result;
  937. result = null;
  938. return returnMe;
  939. }
  940. public Builder mergeFrom(com.google.protobuf.Message other) {
  941. if (other instanceof com.example.tutorial.AddressBookProtos.AddressBook) {
  942. return mergeFrom((com.example.tutorial.AddressBookProtos.AddressBook)other);
  943. } else {
  944. super.mergeFrom(other);
  945. return this;
  946. }
  947. }
  948. public Builder mergeFrom(com.example.tutorial.AddressBookProtos.AddressBook other) {
  949. if (other == com.example.tutorial.AddressBookProtos.AddressBook.getDefaultInstance()) return this;
  950. if (!other.person_.isEmpty()) {
  951. if (result.person_.isEmpty()) {
  952. result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
  953. }
  954. result.person_.addAll(other.person_);
  955. }
  956. this.mergeUnknownFields(other.getUnknownFields());
  957. return this;
  958. }
  959. public Builder mergeFrom(
  960. com.google.protobuf.CodedInputStream input,
  961. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  962. throws java.io.IOException {
  963. com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  964. com.google.protobuf.UnknownFieldSet.newBuilder(
  965. this.getUnknownFields());
  966. while (true) {
  967. int tag = input.readTag();
  968. switch (tag) {
  969. case 0:
  970. this.setUnknownFields(unknownFields.build());
  971. return this;
  972. default: {
  973. if (!parseUnknownField(input, unknownFields,
  974. extensionRegistry, tag)) {
  975. this.setUnknownFields(unknownFields.build());
  976. return this;
  977. }
  978. break;
  979. }
  980. case 10: {
  981. com.example.tutorial.AddressBookProtos.Person.Builder subBuilder = com.example.tutorial.AddressBookProtos.Person.newBuilder();
  982. input.readMessage(subBuilder, extensionRegistry);
  983. addPerson(subBuilder.buildPartial());
  984. break;
  985. }
  986. }
  987. }
  988. }
  989. // repeated .tutorial.Person person = 1;
  990. public java.util.List<com.example.tutorial.AddressBookProtos.Person> getPersonList() {
  991. return java.util.Collections.unmodifiableList(result.person_);
  992. }
  993. public int getPersonCount() {
  994. return result.getPersonCount();
  995. }
  996. public com.example.tutorial.AddressBookProtos.Person getPerson(int index) {
  997. return result.getPerson(index);
  998. }
  999. public Builder setPerson(int index, com.example.tutorial.AddressBookProtos.Person value) {
  1000. if (value == null) {
  1001. throw new NullPointerException();
  1002. }
  1003. result.person_.set(index, value);
  1004. return this;
  1005. }
  1006. public Builder setPerson(int index, com.example.tutorial.AddressBookProtos.Person.Builder builderForValue) {
  1007. result.person_.set(index, builderForValue.build());
  1008. return this;
  1009. }
  1010. public Builder addPerson(com.example.tutorial.AddressBookProtos.Person value) {
  1011. if (value == null) {
  1012. throw new NullPointerException();
  1013. }
  1014. if (result.person_.isEmpty()) {
  1015. result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
  1016. }
  1017. result.person_.add(value);
  1018. return this;
  1019. }
  1020. public Builder addPerson(com.example.tutorial.AddressBookProtos.Person.Builder builderForValue) {
  1021. if (result.person_.isEmpty()) {
  1022. result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
  1023. }
  1024. result.person_.add(builderForValue.build());
  1025. return this;
  1026. }
  1027. public Builder addAllPerson(
  1028. java.lang.Iterable<? extends com.example.tutorial.AddressBookProtos.Person> values) {
  1029. if (result.person_.isEmpty()) {
  1030. result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
  1031. }
  1032. super.addAll(values, result.person_);
  1033. return this;
  1034. }
  1035. public Builder clearPerson() {
  1036. result.person_ = java.util.Collections.emptyList();
  1037. return this;
  1038. }
  1039. }
  1040. static {
  1041. com.example.tutorial.AddressBookProtos.getDescriptor();
  1042. }
  1043. static {
  1044. com.example.tutorial.AddressBookProtos.internalForceInit();
  1045. }
  1046. }
  1047. private static com.google.protobuf.Descriptors.Descriptor
  1048. internal_static_tutorial_Person_descriptor;
  1049. private static
  1050. com.google.protobuf.GeneratedMessage.FieldAccessorTable
  1051. internal_static_tutorial_Person_fieldAccessorTable;
  1052. private static com.google.protobuf.Descriptors.Descriptor
  1053. internal_static_tutorial_Person_PhoneNumber_descriptor;
  1054. private static
  1055. com.google.protobuf.GeneratedMessage.FieldAccessorTable
  1056. internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable;
  1057. private static com.google.protobuf.Descriptors.Descriptor
  1058. internal_static_tutorial_AddressBook_descriptor;
  1059. private static
  1060. com.google.protobuf.GeneratedMessage.FieldAccessorTable
  1061. internal_static_tutorial_AddressBook_fieldAccessorTable;
  1062. public static com.google.protobuf.Descriptors.FileDescriptor
  1063. getDescriptor() {
  1064. return descriptor;
  1065. }
  1066. private static com.google.protobuf.Descriptors.FileDescriptor
  1067. descriptor;
  1068. static {
  1069. java.lang.String[] descriptorData = {
  1070. "\n\021addressbook.proto\022\010tutorial\"\332\001\n\006Person" +
  1071. "\022\014\n\004name\030\001 \002(\t\022\n\n\002id\030\002 \002(\005\022\r\n\005email\030\003 \001(" +
  1072. "\t\022+\n\005phone\030\004 \003(\0132\034.tutorial.Person.Phone" +
  1073. "Number\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n" +
  1074. "\004type\030\002 \001(\0162\032.tutorial.Person.PhoneType:" +
  1075. "\004HOME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001" +
  1076. "\022\010\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003(" +
  1077. "\0132\020.tutorial.PersonB)\n\024com.example.tutor" +
  1078. "ialB\021AddressBookProtos"
  1079. };
  1080. com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
  1081. new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
  1082. public com.google.protobuf.ExtensionRegistry assignDescriptors(
  1083. com.google.protobuf.Descriptors.FileDescriptor root) {
  1084. descriptor = root;
  1085. internal_static_tutorial_Person_descriptor =
  1086. getDescriptor().getMessageTypes().get(0);
  1087. internal_static_tutorial_Person_fieldAccessorTable = new
  1088. com.google.protobuf.GeneratedMessage.FieldAccessorTable(
  1089. internal_static_tutorial_Person_descriptor,
  1090. new java.lang.String[] { "Name", "Id", "Email", "Phone", },
  1091. com.example.tutorial.AddressBookProtos.Person.class,
  1092. com.example.tutorial.AddressBookProtos.Person.Builder.class);
  1093. internal_static_tutorial_Person_PhoneNumber_descriptor =
  1094. internal_static_tutorial_Person_descriptor.getNestedTypes().get(0);
  1095. internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable = new
  1096. com.google.protobuf.GeneratedMessage.FieldAccessorTable(
  1097. internal_static_tutorial_Person_PhoneNumber_descriptor,
  1098. new java.lang.String[] { "Number", "Type", },
  1099. com.example.tutorial.AddressBookProtos.Person.PhoneNumber.class,
  1100. com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder.class);
  1101. internal_static_tutorial_AddressBook_descriptor =
  1102. getDescriptor().getMessageTypes().get(1);
  1103. internal_static_tutorial_AddressBook_fieldAccessorTable = new
  1104. com.google.protobuf.GeneratedMessage.FieldAccessorTable(
  1105. internal_static_tutorial_AddressBook_descriptor,
  1106. new java.lang.String[] { "Person", },
  1107. com.example.tutorial.AddressBookProtos.AddressBook.class,
  1108. com.example.tutorial.AddressBookProtos.AddressBook.Builder.class);
  1109. return null;
  1110. }
  1111. };
  1112. com.google.protobuf.Descriptors.FileDescriptor
  1113. .internalBuildGeneratedFileFrom(descriptorData,
  1114. new com.google.protobuf.Descriptors.FileDescriptor[] {
  1115. }, assigner);
  1116. }
  1117. public static void internalForceInit() {}
  1118. }