diff --git a/build.gradle b/build.gradle index 7b972382a..1aea643c1 100644 --- a/build.gradle +++ b/build.gradle @@ -52,6 +52,7 @@ dependencies { compile group: 'com.uber.m3', name: 'tally-core', version: '0.2.3' compile group: 'com.google.guava', name: 'guava', version: '27.0.1-jre' compile group: 'com.cronutils', name: 'cron-utils', version: '8.0.0' + compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.6.1' testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'com.googlecode.junit-toolbox', name: 'junit-toolbox', version: '2.4' testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' @@ -66,7 +67,7 @@ compileJava { dependsOn 'googleJavaFormat' options.encoding = 'UTF-8' options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-XepExcludedPaths:" + - ".*/generated-sources/.*" << "-Werror" + ".*/generated-sources/.*" } // Generation version.properties for value to be included into the request header @@ -91,7 +92,7 @@ classes { compileTestJava { options.encoding = 'UTF-8' options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-XepExcludedPaths:" + - ".*/generated-sources/.*" << "-Werror" + ".*/generated-sources/.*" } if (JavaVersion.current().isJava8Compatible()) { diff --git a/src/main/java/com/uber/cadence/converter/JsonDataConverter.java b/src/main/java/com/uber/cadence/converter/JsonDataConverter.java index 91497dfcc..b71b2ab0c 100644 --- a/src/main/java/com/uber/cadence/converter/JsonDataConverter.java +++ b/src/main/java/com/uber/cadence/converter/JsonDataConverter.java @@ -28,7 +28,9 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.google.protobuf.GeneratedMessageV3; import java.io.IOException; +import java.lang.reflect.Method; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.util.function.Function; @@ -88,6 +90,11 @@ public byte[] toData(Object... values) throws DataConverterException { try { if (values.length == 1) { Object value = values[0]; + if (value instanceof GeneratedMessageV3) { + GeneratedMessageV3 protoObj = (GeneratedMessageV3) value; + return protoObj.toByteArray(); + } + String json = gson.toJson(value); return json.getBytes(StandardCharsets.UTF_8); } @@ -101,12 +108,18 @@ public byte[] toData(Object... values) throws DataConverterException { } @Override + @SuppressWarnings("unchecked") public T fromData(byte[] content, Class valueClass, Type valueType) throws DataConverterException { if (content == null) { return null; } try { + if (GeneratedMessageV3.class.isAssignableFrom(valueClass)) { + Method m = valueClass.getMethod("parseFrom", byte[].class); + return (T) m.invoke(null, content); + } + return gson.fromJson(new String(content, StandardCharsets.UTF_8), valueType); } catch (Exception e) { throw new DataConverterException(content, new Type[] {valueType}, e); diff --git a/src/test/java/com/uber/cadence/converter/JsonDataConverterTest.java b/src/test/java/com/uber/cadence/converter/JsonDataConverterTest.java index 1dfffd4e1..355b94276 100644 --- a/src/test/java/com/uber/cadence/converter/JsonDataConverterTest.java +++ b/src/test/java/com/uber/cadence/converter/JsonDataConverterTest.java @@ -17,7 +17,8 @@ package com.uber.cadence.converter; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import com.uber.cadence.EventType; import com.uber.cadence.History; @@ -163,6 +164,23 @@ public void testThriftFieldsInPOJOArray() { assertEquals(new String(converted, StandardCharsets.UTF_8), testData, fromConverted[1]); } + @Test + public void testProto() { + TestProtos.Person person = + TestProtos.Person.newBuilder() + .setName("abc") + .setId(1) + .setEmail("abc@def.com") + .addPhones(TestProtos.Person.PhoneNumber.newBuilder().setNumber("123456").build()) + .build(); + TestProtos.AddressBook book = TestProtos.AddressBook.newBuilder().addPeople(person).build(); + byte[] converted = converter.toData(book); + + TestProtos.AddressBook fromConverted = + converter.fromData(converted, TestProtos.AddressBook.class, TestProtos.AddressBook.class); + assertEquals(book, fromConverted); + } + public static void foo(List arg) {} @Test diff --git a/src/test/java/com/uber/cadence/converter/TestProtos.java b/src/test/java/com/uber/cadence/converter/TestProtos.java new file mode 100644 index 000000000..e301d4c8d --- /dev/null +++ b/src/test/java/com/uber/cadence/converter/TestProtos.java @@ -0,0 +1,2718 @@ +/* + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: addressbook.proto + +package com.uber.cadence.converter; + +public final class TestProtos { + private TestProtos() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface PersonOrBuilder + extends + // @@protoc_insertion_point(interface_extends:tutorial.Person) + com.google.protobuf.MessageOrBuilder { + + /** required string name = 1; */ + boolean hasName(); + /** required string name = 1; */ + java.lang.String getName(); + /** required string name = 1; */ + com.google.protobuf.ByteString getNameBytes(); + + /** required int32 id = 2; */ + boolean hasId(); + /** required int32 id = 2; */ + int getId(); + + /** optional string email = 3; */ + boolean hasEmail(); + /** optional string email = 3; */ + java.lang.String getEmail(); + /** optional string email = 3; */ + com.google.protobuf.ByteString getEmailBytes(); + + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + java.util.List getPhonesList(); + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + com.uber.cadence.converter.TestProtos.Person.PhoneNumber getPhones(int index); + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + int getPhonesCount(); + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + java.util.List + getPhonesOrBuilderList(); + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder getPhonesOrBuilder(int index); + } + /** Protobuf type {@code tutorial.Person} */ + public static final class Person extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:tutorial.Person) + PersonOrBuilder { + private static final long serialVersionUID = 0L; + // Use Person.newBuilder() to construct. + private Person(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Person() { + name_ = ""; + email_ = ""; + phones_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Person( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000001; + name_ = bs; + break; + } + case 16: + { + bitField0_ |= 0x00000002; + id_ = input.readInt32(); + break; + } + case 26: + { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000004; + email_ = bs; + break; + } + case 34: + { + if (!((mutable_bitField0_ & 0x00000008) != 0)) { + phones_ = + new java.util.ArrayList< + com.uber.cadence.converter.TestProtos.Person.PhoneNumber>(); + mutable_bitField0_ |= 0x00000008; + } + phones_.add( + input.readMessage( + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.PARSER, + extensionRegistry)); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000008) != 0)) { + phones_ = java.util.Collections.unmodifiableList(phones_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.uber.cadence.converter.TestProtos.internal_static_tutorial_Person_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_Person_fieldAccessorTable.ensureFieldAccessorsInitialized( + com.uber.cadence.converter.TestProtos.Person.class, + com.uber.cadence.converter.TestProtos.Person.Builder.class); + } + + /** Protobuf enum {@code tutorial.Person.PhoneType} */ + public enum PhoneType implements com.google.protobuf.ProtocolMessageEnum { + /** MOBILE = 0; */ + MOBILE(0), + /** HOME = 1; */ + HOME(1), + /** WORK = 2; */ + WORK(2), + ; + + /** MOBILE = 0; */ + public static final int MOBILE_VALUE = 0; + /** HOME = 1; */ + public static final int HOME_VALUE = 1; + /** WORK = 2; */ + public static final int WORK_VALUE = 2; + + public final int getNumber() { + return value; + } + + /** @deprecated Use {@link #forNumber(int)} instead. */ + @java.lang.Deprecated + public static PhoneType valueOf(int value) { + return forNumber(value); + } + + public static PhoneType forNumber(int value) { + switch (value) { + case 0: + return MOBILE; + case 1: + return HOME; + case 2: + return WORK; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public PhoneType findValueByNumber(int number) { + return PhoneType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.uber.cadence.converter.TestProtos.Person.getDescriptor().getEnumTypes().get(0); + } + + private static final PhoneType[] VALUES = values(); + + public static PhoneType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private PhoneType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:tutorial.Person.PhoneType) + } + + public interface PhoneNumberOrBuilder + extends + // @@protoc_insertion_point(interface_extends:tutorial.Person.PhoneNumber) + com.google.protobuf.MessageOrBuilder { + + /** required string number = 1; */ + boolean hasNumber(); + /** required string number = 1; */ + java.lang.String getNumber(); + /** required string number = 1; */ + com.google.protobuf.ByteString getNumberBytes(); + + /** optional .tutorial.Person.PhoneType type = 2 [default = HOME]; */ + boolean hasType(); + /** optional .tutorial.Person.PhoneType type = 2 [default = HOME]; */ + com.uber.cadence.converter.TestProtos.Person.PhoneType getType(); + } + /** Protobuf type {@code tutorial.Person.PhoneNumber} */ + public static final class PhoneNumber extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:tutorial.Person.PhoneNumber) + PhoneNumberOrBuilder { + private static final long serialVersionUID = 0L; + // Use PhoneNumber.newBuilder() to construct. + private PhoneNumber(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PhoneNumber() { + number_ = ""; + type_ = 1; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private PhoneNumber( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000001; + number_ = bs; + break; + } + case 16: + { + int rawValue = input.readEnum(); + @SuppressWarnings("deprecation") + com.uber.cadence.converter.TestProtos.Person.PhoneType value = + com.uber.cadence.converter.TestProtos.Person.PhoneType.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(2, rawValue); + } else { + bitField0_ |= 0x00000002; + type_ = rawValue; + } + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_Person_PhoneNumber_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.class, + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder.class); + } + + private int bitField0_; + public static final int NUMBER_FIELD_NUMBER = 1; + private volatile java.lang.Object number_; + /** required string number = 1; */ + public boolean hasNumber() { + return ((bitField0_ & 0x00000001) != 0); + } + /** required string number = 1; */ + public java.lang.String getNumber() { + java.lang.Object ref = number_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + number_ = s; + } + return s; + } + } + /** required string number = 1; */ + public com.google.protobuf.ByteString getNumberBytes() { + java.lang.Object ref = number_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + number_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 2; + private int type_; + /** optional .tutorial.Person.PhoneType type = 2 [default = HOME]; */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) != 0); + } + /** optional .tutorial.Person.PhoneType type = 2 [default = HOME]; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneType getType() { + @SuppressWarnings("deprecation") + com.uber.cadence.converter.TestProtos.Person.PhoneType result = + com.uber.cadence.converter.TestProtos.Person.PhoneType.valueOf(type_); + return result == null + ? com.uber.cadence.converter.TestProtos.Person.PhoneType.HOME + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasNumber()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, number_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeEnum(2, type_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, number_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, type_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.uber.cadence.converter.TestProtos.Person.PhoneNumber)) { + return super.equals(obj); + } + com.uber.cadence.converter.TestProtos.Person.PhoneNumber other = + (com.uber.cadence.converter.TestProtos.Person.PhoneNumber) obj; + + if (hasNumber() != other.hasNumber()) return false; + if (hasNumber()) { + if (!getNumber().equals(other.getNumber())) return false; + } + if (hasType() != other.hasType()) return false; + if (hasType()) { + if (type_ != other.type_) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasNumber()) { + hash = (37 * hash) + NUMBER_FIELD_NUMBER; + hash = (53 * hash) + getNumber().hashCode(); + } + if (hasType()) { + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.uber.cadence.converter.TestProtos.Person.PhoneNumber prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** Protobuf type {@code tutorial.Person.PhoneNumber} */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:tutorial.Person.PhoneNumber) + com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_Person_PhoneNumber_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.class, + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder.class); + } + + // Construct using com.uber.cadence.converter.TestProtos.Person.PhoneNumber.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + number_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + type_ = 1; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_Person_PhoneNumber_descriptor; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber + getDefaultInstanceForType() { + return com.uber.cadence.converter.TestProtos.Person.PhoneNumber.getDefaultInstance(); + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber build() { + com.uber.cadence.converter.TestProtos.Person.PhoneNumber result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber buildPartial() { + com.uber.cadence.converter.TestProtos.Person.PhoneNumber result = + new com.uber.cadence.converter.TestProtos.Person.PhoneNumber(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + to_bitField0_ |= 0x00000001; + } + result.number_ = number_; + if (((from_bitField0_ & 0x00000002) != 0)) { + to_bitField0_ |= 0x00000002; + } + result.type_ = type_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.uber.cadence.converter.TestProtos.Person.PhoneNumber) { + return mergeFrom((com.uber.cadence.converter.TestProtos.Person.PhoneNumber) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.uber.cadence.converter.TestProtos.Person.PhoneNumber other) { + if (other + == com.uber.cadence.converter.TestProtos.Person.PhoneNumber.getDefaultInstance()) + return this; + if (other.hasNumber()) { + bitField0_ |= 0x00000001; + number_ = other.number_; + onChanged(); + } + if (other.hasType()) { + setType(other.getType()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + if (!hasNumber()) { + return false; + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.uber.cadence.converter.TestProtos.Person.PhoneNumber parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.uber.cadence.converter.TestProtos.Person.PhoneNumber) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.lang.Object number_ = ""; + /** required string number = 1; */ + public boolean hasNumber() { + return ((bitField0_ & 0x00000001) != 0); + } + /** required string number = 1; */ + public java.lang.String getNumber() { + java.lang.Object ref = number_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + number_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** required string number = 1; */ + public com.google.protobuf.ByteString getNumberBytes() { + java.lang.Object ref = number_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + number_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** required string number = 1; */ + public Builder setNumber(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + number_ = value; + onChanged(); + return this; + } + /** required string number = 1; */ + public Builder clearNumber() { + bitField0_ = (bitField0_ & ~0x00000001); + number_ = getDefaultInstance().getNumber(); + onChanged(); + return this; + } + /** required string number = 1; */ + public Builder setNumberBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + number_ = value; + onChanged(); + return this; + } + + private int type_ = 1; + /** optional .tutorial.Person.PhoneType type = 2 [default = HOME]; */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) != 0); + } + /** optional .tutorial.Person.PhoneType type = 2 [default = HOME]; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneType getType() { + @SuppressWarnings("deprecation") + com.uber.cadence.converter.TestProtos.Person.PhoneType result = + com.uber.cadence.converter.TestProtos.Person.PhoneType.valueOf(type_); + return result == null + ? com.uber.cadence.converter.TestProtos.Person.PhoneType.HOME + : result; + } + /** optional .tutorial.Person.PhoneType type = 2 [default = HOME]; */ + public Builder setType(com.uber.cadence.converter.TestProtos.Person.PhoneType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + type_ = value.getNumber(); + onChanged(); + return this; + } + /** optional .tutorial.Person.PhoneType type = 2 [default = HOME]; */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000002); + type_ = 1; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:tutorial.Person.PhoneNumber) + } + + // @@protoc_insertion_point(class_scope:tutorial.Person.PhoneNumber) + private static final com.uber.cadence.converter.TestProtos.Person.PhoneNumber + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.uber.cadence.converter.TestProtos.Person.PhoneNumber(); + } + + public static com.uber.cadence.converter.TestProtos.Person.PhoneNumber getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated + public static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PhoneNumber parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PhoneNumber(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** required string name = 1; */ + public boolean hasName() { + return ((bitField0_ & 0x00000001) != 0); + } + /** required string name = 1; */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } + } + /** required string name = 1; */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ID_FIELD_NUMBER = 2; + private int id_; + /** required int32 id = 2; */ + public boolean hasId() { + return ((bitField0_ & 0x00000002) != 0); + } + /** required int32 id = 2; */ + public int getId() { + return id_; + } + + public static final int EMAIL_FIELD_NUMBER = 3; + private volatile java.lang.Object email_; + /** optional string email = 3; */ + public boolean hasEmail() { + return ((bitField0_ & 0x00000004) != 0); + } + /** optional string email = 3; */ + public java.lang.String getEmail() { + java.lang.Object ref = email_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + email_ = s; + } + return s; + } + } + /** optional string email = 3; */ + public com.google.protobuf.ByteString getEmailBytes() { + java.lang.Object ref = email_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + email_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PHONES_FIELD_NUMBER = 4; + private java.util.List phones_; + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public java.util.List + getPhonesList() { + return phones_; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public java.util.List< + ? extends com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder> + getPhonesOrBuilderList() { + return phones_; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public int getPhonesCount() { + return phones_.size(); + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber getPhones(int index) { + return phones_.get(index); + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder getPhonesOrBuilder( + int index) { + return phones_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasName()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasId()) { + memoizedIsInitialized = 0; + return false; + } + for (int i = 0; i < getPhonesCount(); i++) { + if (!getPhones(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeInt32(2, id_); + } + if (((bitField0_ & 0x00000004) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, email_); + } + for (int i = 0; i < phones_.size(); i++) { + output.writeMessage(4, phones_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, id_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, email_); + } + for (int i = 0; i < phones_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, phones_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.uber.cadence.converter.TestProtos.Person)) { + return super.equals(obj); + } + com.uber.cadence.converter.TestProtos.Person other = + (com.uber.cadence.converter.TestProtos.Person) obj; + + if (hasName() != other.hasName()) return false; + if (hasName()) { + if (!getName().equals(other.getName())) return false; + } + if (hasId() != other.hasId()) return false; + if (hasId()) { + if (getId() != other.getId()) return false; + } + if (hasEmail() != other.hasEmail()) return false; + if (hasEmail()) { + if (!getEmail().equals(other.getEmail())) return false; + } + if (!getPhonesList().equals(other.getPhonesList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasName()) { + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + } + if (hasId()) { + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId(); + } + if (hasEmail()) { + hash = (37 * hash) + EMAIL_FIELD_NUMBER; + hash = (53 * hash) + getEmail().hashCode(); + } + if (getPhonesCount() > 0) { + hash = (37 * hash) + PHONES_FIELD_NUMBER; + hash = (53 * hash) + getPhonesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.Person parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.Person parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.uber.cadence.converter.TestProtos.Person prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** Protobuf type {@code tutorial.Person} */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:tutorial.Person) + com.uber.cadence.converter.TestProtos.PersonOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.uber.cadence.converter.TestProtos.internal_static_tutorial_Person_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_Person_fieldAccessorTable.ensureFieldAccessorsInitialized( + com.uber.cadence.converter.TestProtos.Person.class, + com.uber.cadence.converter.TestProtos.Person.Builder.class); + } + + // Construct using com.uber.cadence.converter.TestProtos.Person.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPhonesFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + id_ = 0; + bitField0_ = (bitField0_ & ~0x00000002); + email_ = ""; + bitField0_ = (bitField0_ & ~0x00000004); + if (phonesBuilder_ == null) { + phones_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + phonesBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.uber.cadence.converter.TestProtos.internal_static_tutorial_Person_descriptor; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.Person getDefaultInstanceForType() { + return com.uber.cadence.converter.TestProtos.Person.getDefaultInstance(); + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.Person build() { + com.uber.cadence.converter.TestProtos.Person result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.Person buildPartial() { + com.uber.cadence.converter.TestProtos.Person result = + new com.uber.cadence.converter.TestProtos.Person(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + to_bitField0_ |= 0x00000001; + } + result.name_ = name_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.id_ = id_; + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + to_bitField0_ |= 0x00000004; + } + result.email_ = email_; + if (phonesBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + phones_ = java.util.Collections.unmodifiableList(phones_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.phones_ = phones_; + } else { + result.phones_ = phonesBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.uber.cadence.converter.TestProtos.Person) { + return mergeFrom((com.uber.cadence.converter.TestProtos.Person) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.uber.cadence.converter.TestProtos.Person other) { + if (other == com.uber.cadence.converter.TestProtos.Person.getDefaultInstance()) return this; + if (other.hasName()) { + bitField0_ |= 0x00000001; + name_ = other.name_; + onChanged(); + } + if (other.hasId()) { + setId(other.getId()); + } + if (other.hasEmail()) { + bitField0_ |= 0x00000004; + email_ = other.email_; + onChanged(); + } + if (phonesBuilder_ == null) { + if (!other.phones_.isEmpty()) { + if (phones_.isEmpty()) { + phones_ = other.phones_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensurePhonesIsMutable(); + phones_.addAll(other.phones_); + } + onChanged(); + } + } else { + if (!other.phones_.isEmpty()) { + if (phonesBuilder_.isEmpty()) { + phonesBuilder_.dispose(); + phonesBuilder_ = null; + phones_ = other.phones_; + bitField0_ = (bitField0_ & ~0x00000008); + phonesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getPhonesFieldBuilder() + : null; + } else { + phonesBuilder_.addAllMessages(other.phones_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + if (!hasName()) { + return false; + } + if (!hasId()) { + return false; + } + for (int i = 0; i < getPhonesCount(); i++) { + if (!getPhones(i).isInitialized()) { + return false; + } + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.uber.cadence.converter.TestProtos.Person parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.uber.cadence.converter.TestProtos.Person) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** required string name = 1; */ + public boolean hasName() { + return ((bitField0_ & 0x00000001) != 0); + } + /** required string name = 1; */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** required string name = 1; */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** required string name = 1; */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + name_ = value; + onChanged(); + return this; + } + /** required string name = 1; */ + public Builder clearName() { + bitField0_ = (bitField0_ & ~0x00000001); + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** required string name = 1; */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + name_ = value; + onChanged(); + return this; + } + + private int id_; + /** required int32 id = 2; */ + public boolean hasId() { + return ((bitField0_ & 0x00000002) != 0); + } + /** required int32 id = 2; */ + public int getId() { + return id_; + } + /** required int32 id = 2; */ + public Builder setId(int value) { + bitField0_ |= 0x00000002; + id_ = value; + onChanged(); + return this; + } + /** required int32 id = 2; */ + public Builder clearId() { + bitField0_ = (bitField0_ & ~0x00000002); + id_ = 0; + onChanged(); + return this; + } + + private java.lang.Object email_ = ""; + /** optional string email = 3; */ + public boolean hasEmail() { + return ((bitField0_ & 0x00000004) != 0); + } + /** optional string email = 3; */ + public java.lang.String getEmail() { + java.lang.Object ref = email_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + email_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** optional string email = 3; */ + public com.google.protobuf.ByteString getEmailBytes() { + java.lang.Object ref = email_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + email_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** optional string email = 3; */ + public Builder setEmail(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + email_ = value; + onChanged(); + return this; + } + /** optional string email = 3; */ + public Builder clearEmail() { + bitField0_ = (bitField0_ & ~0x00000004); + email_ = getDefaultInstance().getEmail(); + onChanged(); + return this; + } + /** optional string email = 3; */ + public Builder setEmailBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + email_ = value; + onChanged(); + return this; + } + + private java.util.List phones_ = + java.util.Collections.emptyList(); + + private void ensurePhonesIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + phones_ = + new java.util.ArrayList( + phones_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.uber.cadence.converter.TestProtos.Person.PhoneNumber, + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder, + com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder> + phonesBuilder_; + + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public java.util.List + getPhonesList() { + if (phonesBuilder_ == null) { + return java.util.Collections.unmodifiableList(phones_); + } else { + return phonesBuilder_.getMessageList(); + } + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public int getPhonesCount() { + if (phonesBuilder_ == null) { + return phones_.size(); + } else { + return phonesBuilder_.getCount(); + } + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber getPhones(int index) { + if (phonesBuilder_ == null) { + return phones_.get(index); + } else { + return phonesBuilder_.getMessage(index); + } + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder setPhones( + int index, com.uber.cadence.converter.TestProtos.Person.PhoneNumber value) { + if (phonesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhonesIsMutable(); + phones_.set(index, value); + onChanged(); + } else { + phonesBuilder_.setMessage(index, value); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder setPhones( + int index, + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder builderForValue) { + if (phonesBuilder_ == null) { + ensurePhonesIsMutable(); + phones_.set(index, builderForValue.build()); + onChanged(); + } else { + phonesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder addPhones(com.uber.cadence.converter.TestProtos.Person.PhoneNumber value) { + if (phonesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhonesIsMutable(); + phones_.add(value); + onChanged(); + } else { + phonesBuilder_.addMessage(value); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder addPhones( + int index, com.uber.cadence.converter.TestProtos.Person.PhoneNumber value) { + if (phonesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhonesIsMutable(); + phones_.add(index, value); + onChanged(); + } else { + phonesBuilder_.addMessage(index, value); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder addPhones( + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder builderForValue) { + if (phonesBuilder_ == null) { + ensurePhonesIsMutable(); + phones_.add(builderForValue.build()); + onChanged(); + } else { + phonesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder addPhones( + int index, + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder builderForValue) { + if (phonesBuilder_ == null) { + ensurePhonesIsMutable(); + phones_.add(index, builderForValue.build()); + onChanged(); + } else { + phonesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder addAllPhones( + java.lang.Iterable + values) { + if (phonesBuilder_ == null) { + ensurePhonesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, phones_); + onChanged(); + } else { + phonesBuilder_.addAllMessages(values); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder clearPhones() { + if (phonesBuilder_ == null) { + phones_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + phonesBuilder_.clear(); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public Builder removePhones(int index) { + if (phonesBuilder_ == null) { + ensurePhonesIsMutable(); + phones_.remove(index); + onChanged(); + } else { + phonesBuilder_.remove(index); + } + return this; + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder getPhonesBuilder( + int index) { + return getPhonesFieldBuilder().getBuilder(index); + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder getPhonesOrBuilder( + int index) { + if (phonesBuilder_ == null) { + return phones_.get(index); + } else { + return phonesBuilder_.getMessageOrBuilder(index); + } + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public java.util.List< + ? extends com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder> + getPhonesOrBuilderList() { + if (phonesBuilder_ != null) { + return phonesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(phones_); + } + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder addPhonesBuilder() { + return getPhonesFieldBuilder() + .addBuilder( + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.getDefaultInstance()); + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder addPhonesBuilder( + int index) { + return getPhonesFieldBuilder() + .addBuilder( + index, + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.getDefaultInstance()); + } + /** repeated .tutorial.Person.PhoneNumber phones = 4; */ + public java.util.List + getPhonesBuilderList() { + return getPhonesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.uber.cadence.converter.TestProtos.Person.PhoneNumber, + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder, + com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder> + getPhonesFieldBuilder() { + if (phonesBuilder_ == null) { + phonesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.uber.cadence.converter.TestProtos.Person.PhoneNumber, + com.uber.cadence.converter.TestProtos.Person.PhoneNumber.Builder, + com.uber.cadence.converter.TestProtos.Person.PhoneNumberOrBuilder>( + phones_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + phones_ = null; + } + return phonesBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:tutorial.Person) + } + + // @@protoc_insertion_point(class_scope:tutorial.Person) + private static final com.uber.cadence.converter.TestProtos.Person DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.uber.cadence.converter.TestProtos.Person(); + } + + public static com.uber.cadence.converter.TestProtos.Person getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated + public static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Person parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Person(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.Person getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface AddressBookOrBuilder + extends + // @@protoc_insertion_point(interface_extends:tutorial.AddressBook) + com.google.protobuf.MessageOrBuilder { + + /** repeated .tutorial.Person people = 1; */ + java.util.List getPeopleList(); + /** repeated .tutorial.Person people = 1; */ + com.uber.cadence.converter.TestProtos.Person getPeople(int index); + /** repeated .tutorial.Person people = 1; */ + int getPeopleCount(); + /** repeated .tutorial.Person people = 1; */ + java.util.List + getPeopleOrBuilderList(); + /** repeated .tutorial.Person people = 1; */ + com.uber.cadence.converter.TestProtos.PersonOrBuilder getPeopleOrBuilder(int index); + } + /** Protobuf type {@code tutorial.AddressBook} */ + public static final class AddressBook extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:tutorial.AddressBook) + AddressBookOrBuilder { + private static final long serialVersionUID = 0L; + // Use AddressBook.newBuilder() to construct. + private AddressBook(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private AddressBook() { + people_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private AddressBook( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + people_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + people_.add( + input.readMessage( + com.uber.cadence.converter.TestProtos.Person.PARSER, extensionRegistry)); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + people_ = java.util.Collections.unmodifiableList(people_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.uber.cadence.converter.TestProtos.internal_static_tutorial_AddressBook_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_AddressBook_fieldAccessorTable.ensureFieldAccessorsInitialized( + com.uber.cadence.converter.TestProtos.AddressBook.class, + com.uber.cadence.converter.TestProtos.AddressBook.Builder.class); + } + + public static final int PEOPLE_FIELD_NUMBER = 1; + private java.util.List people_; + /** repeated .tutorial.Person people = 1; */ + public java.util.List getPeopleList() { + return people_; + } + /** repeated .tutorial.Person people = 1; */ + public java.util.List + getPeopleOrBuilderList() { + return people_; + } + /** repeated .tutorial.Person people = 1; */ + public int getPeopleCount() { + return people_.size(); + } + /** repeated .tutorial.Person people = 1; */ + public com.uber.cadence.converter.TestProtos.Person getPeople(int index) { + return people_.get(index); + } + /** repeated .tutorial.Person people = 1; */ + public com.uber.cadence.converter.TestProtos.PersonOrBuilder getPeopleOrBuilder(int index) { + return people_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + for (int i = 0; i < getPeopleCount(); i++) { + if (!getPeople(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < people_.size(); i++) { + output.writeMessage(1, people_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < people_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, people_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.uber.cadence.converter.TestProtos.AddressBook)) { + return super.equals(obj); + } + com.uber.cadence.converter.TestProtos.AddressBook other = + (com.uber.cadence.converter.TestProtos.AddressBook) obj; + + if (!getPeopleList().equals(other.getPeopleList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getPeopleCount() > 0) { + hash = (37 * hash) + PEOPLE_FIELD_NUMBER; + hash = (53 * hash) + getPeopleList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.uber.cadence.converter.TestProtos.AddressBook prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** Protobuf type {@code tutorial.AddressBook} */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:tutorial.AddressBook) + com.uber.cadence.converter.TestProtos.AddressBookOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_AddressBook_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_AddressBook_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.uber.cadence.converter.TestProtos.AddressBook.class, + com.uber.cadence.converter.TestProtos.AddressBook.Builder.class); + } + + // Construct using com.uber.cadence.converter.TestProtos.AddressBook.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPeopleFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (peopleBuilder_ == null) { + people_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + peopleBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.uber.cadence.converter.TestProtos + .internal_static_tutorial_AddressBook_descriptor; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.AddressBook getDefaultInstanceForType() { + return com.uber.cadence.converter.TestProtos.AddressBook.getDefaultInstance(); + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.AddressBook build() { + com.uber.cadence.converter.TestProtos.AddressBook result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.AddressBook buildPartial() { + com.uber.cadence.converter.TestProtos.AddressBook result = + new com.uber.cadence.converter.TestProtos.AddressBook(this); + int from_bitField0_ = bitField0_; + if (peopleBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + people_ = java.util.Collections.unmodifiableList(people_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.people_ = people_; + } else { + result.people_ = peopleBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.uber.cadence.converter.TestProtos.AddressBook) { + return mergeFrom((com.uber.cadence.converter.TestProtos.AddressBook) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.uber.cadence.converter.TestProtos.AddressBook other) { + if (other == com.uber.cadence.converter.TestProtos.AddressBook.getDefaultInstance()) + return this; + if (peopleBuilder_ == null) { + if (!other.people_.isEmpty()) { + if (people_.isEmpty()) { + people_ = other.people_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensurePeopleIsMutable(); + people_.addAll(other.people_); + } + onChanged(); + } + } else { + if (!other.people_.isEmpty()) { + if (peopleBuilder_.isEmpty()) { + peopleBuilder_.dispose(); + peopleBuilder_ = null; + people_ = other.people_; + bitField0_ = (bitField0_ & ~0x00000001); + peopleBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getPeopleFieldBuilder() + : null; + } else { + peopleBuilder_.addAllMessages(other.people_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + for (int i = 0; i < getPeopleCount(); i++) { + if (!getPeople(i).isInitialized()) { + return false; + } + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.uber.cadence.converter.TestProtos.AddressBook parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.uber.cadence.converter.TestProtos.AddressBook) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.util.List people_ = + java.util.Collections.emptyList(); + + private void ensurePeopleIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + people_ = new java.util.ArrayList(people_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.uber.cadence.converter.TestProtos.Person, + com.uber.cadence.converter.TestProtos.Person.Builder, + com.uber.cadence.converter.TestProtos.PersonOrBuilder> + peopleBuilder_; + + /** repeated .tutorial.Person people = 1; */ + public java.util.List getPeopleList() { + if (peopleBuilder_ == null) { + return java.util.Collections.unmodifiableList(people_); + } else { + return peopleBuilder_.getMessageList(); + } + } + /** repeated .tutorial.Person people = 1; */ + public int getPeopleCount() { + if (peopleBuilder_ == null) { + return people_.size(); + } else { + return peopleBuilder_.getCount(); + } + } + /** repeated .tutorial.Person people = 1; */ + public com.uber.cadence.converter.TestProtos.Person getPeople(int index) { + if (peopleBuilder_ == null) { + return people_.get(index); + } else { + return peopleBuilder_.getMessage(index); + } + } + /** repeated .tutorial.Person people = 1; */ + public Builder setPeople(int index, com.uber.cadence.converter.TestProtos.Person value) { + if (peopleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePeopleIsMutable(); + people_.set(index, value); + onChanged(); + } else { + peopleBuilder_.setMessage(index, value); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public Builder setPeople( + int index, com.uber.cadence.converter.TestProtos.Person.Builder builderForValue) { + if (peopleBuilder_ == null) { + ensurePeopleIsMutable(); + people_.set(index, builderForValue.build()); + onChanged(); + } else { + peopleBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public Builder addPeople(com.uber.cadence.converter.TestProtos.Person value) { + if (peopleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePeopleIsMutable(); + people_.add(value); + onChanged(); + } else { + peopleBuilder_.addMessage(value); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public Builder addPeople(int index, com.uber.cadence.converter.TestProtos.Person value) { + if (peopleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePeopleIsMutable(); + people_.add(index, value); + onChanged(); + } else { + peopleBuilder_.addMessage(index, value); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public Builder addPeople( + com.uber.cadence.converter.TestProtos.Person.Builder builderForValue) { + if (peopleBuilder_ == null) { + ensurePeopleIsMutable(); + people_.add(builderForValue.build()); + onChanged(); + } else { + peopleBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public Builder addPeople( + int index, com.uber.cadence.converter.TestProtos.Person.Builder builderForValue) { + if (peopleBuilder_ == null) { + ensurePeopleIsMutable(); + people_.add(index, builderForValue.build()); + onChanged(); + } else { + peopleBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public Builder addAllPeople( + java.lang.Iterable values) { + if (peopleBuilder_ == null) { + ensurePeopleIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, people_); + onChanged(); + } else { + peopleBuilder_.addAllMessages(values); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public Builder clearPeople() { + if (peopleBuilder_ == null) { + people_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + peopleBuilder_.clear(); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public Builder removePeople(int index) { + if (peopleBuilder_ == null) { + ensurePeopleIsMutable(); + people_.remove(index); + onChanged(); + } else { + peopleBuilder_.remove(index); + } + return this; + } + /** repeated .tutorial.Person people = 1; */ + public com.uber.cadence.converter.TestProtos.Person.Builder getPeopleBuilder(int index) { + return getPeopleFieldBuilder().getBuilder(index); + } + /** repeated .tutorial.Person people = 1; */ + public com.uber.cadence.converter.TestProtos.PersonOrBuilder getPeopleOrBuilder(int index) { + if (peopleBuilder_ == null) { + return people_.get(index); + } else { + return peopleBuilder_.getMessageOrBuilder(index); + } + } + /** repeated .tutorial.Person people = 1; */ + public java.util.List + getPeopleOrBuilderList() { + if (peopleBuilder_ != null) { + return peopleBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(people_); + } + } + /** repeated .tutorial.Person people = 1; */ + public com.uber.cadence.converter.TestProtos.Person.Builder addPeopleBuilder() { + return getPeopleFieldBuilder() + .addBuilder(com.uber.cadence.converter.TestProtos.Person.getDefaultInstance()); + } + /** repeated .tutorial.Person people = 1; */ + public com.uber.cadence.converter.TestProtos.Person.Builder addPeopleBuilder(int index) { + return getPeopleFieldBuilder() + .addBuilder(index, com.uber.cadence.converter.TestProtos.Person.getDefaultInstance()); + } + /** repeated .tutorial.Person people = 1; */ + public java.util.List + getPeopleBuilderList() { + return getPeopleFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.uber.cadence.converter.TestProtos.Person, + com.uber.cadence.converter.TestProtos.Person.Builder, + com.uber.cadence.converter.TestProtos.PersonOrBuilder> + getPeopleFieldBuilder() { + if (peopleBuilder_ == null) { + peopleBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.uber.cadence.converter.TestProtos.Person, + com.uber.cadence.converter.TestProtos.Person.Builder, + com.uber.cadence.converter.TestProtos.PersonOrBuilder>( + people_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + people_ = null; + } + return peopleBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:tutorial.AddressBook) + } + + // @@protoc_insertion_point(class_scope:tutorial.AddressBook) + private static final com.uber.cadence.converter.TestProtos.AddressBook DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.uber.cadence.converter.TestProtos.AddressBook(); + } + + public static com.uber.cadence.converter.TestProtos.AddressBook getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated + public static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AddressBook parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AddressBook(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.uber.cadence.converter.TestProtos.AddressBook getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_tutorial_Person_descriptor; + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_tutorial_Person_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_tutorial_Person_PhoneNumber_descriptor; + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_tutorial_AddressBook_descriptor; + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_tutorial_AddressBook_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\021addressbook.proto\022\010tutorial\"\333\001\n\006Person" + + "\022\014\n\004name\030\001 \002(\t\022\n\n\002id\030\002 \002(\005\022\r\n\005email\030\003 \001(" + + "\t\022,\n\006phones\030\004 \003(\0132\034.tutorial.Person.Phon" + + "eNumber\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022." + + "\n\004type\030\002 \001(\0162\032.tutorial.Person.PhoneType" + + ":\004HOME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020" + + "\001\022\010\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006people\030\001 \003" + + "(\0132\020.tutorial.PersonB(\n\032com.uber.cadence" + + ".converterB\nTestProtos" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}, assigner); + internal_static_tutorial_Person_descriptor = getDescriptor().getMessageTypes().get(0); + internal_static_tutorial_Person_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_tutorial_Person_descriptor, + new java.lang.String[] { + "Name", "Id", "Email", "Phones", + }); + internal_static_tutorial_Person_PhoneNumber_descriptor = + internal_static_tutorial_Person_descriptor.getNestedTypes().get(0); + internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_tutorial_Person_PhoneNumber_descriptor, + new java.lang.String[] { + "Number", "Type", + }); + internal_static_tutorial_AddressBook_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_tutorial_AddressBook_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_tutorial_AddressBook_descriptor, + new java.lang.String[] { + "People", + }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/test/proto/addressbook.proto b/src/test/proto/addressbook.proto new file mode 100644 index 000000000..c39688747 --- /dev/null +++ b/src/test/proto/addressbook.proto @@ -0,0 +1,29 @@ +syntax = "proto2"; + +package tutorial; + +option java_package = "com.uber.cadence.converter"; +option java_outer_classname = "TestProtos"; + +message Person { + required string name = 1; + required int32 id = 2; + optional string email = 3; + + enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; + } + + message PhoneNumber { + required string number = 1; + optional PhoneType type = 2 [default = HOME]; + } + + repeated PhoneNumber phones = 4; +} + +message AddressBook { + repeated Person people = 1; +} \ No newline at end of file