From 455d29a224bbd0a21ee1fcd42ae48114de72883f Mon Sep 17 00:00:00 2001 From: violin Date: Wed, 8 May 2019 16:25:46 +0800 Subject: [PATCH] [Dubbo-3829] support google pb generic invocation (#3975) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modify generic filter to support google pb service test. * save * save code * save genericFilter 改写完毕 * save * add Licensed * fix some problem after code review * change directory name after change module name --- dubbo-all/pom.xml | 8 + dubbo-bom/pom.xml | 5 + .../org/apache/dubbo/common/Constants.java | 2 + dubbo-dependencies-bom/pom.xml | 11 + .../dubbo/rpc/filter/GenericFilter.java | 39 +- .../dubbo/rpc/support/ProtocolUtils.java | 7 +- .../dubbo-serialization-protobuf-json/pom.xml | 46 + .../support/GenericProtobufObjectInput.java | 115 + .../support/GenericProtobufObjectOutput.java | 107 + .../support/GenericProtobufSerialization.java | 53 + .../protobuf/support/ProtobufUtils.java | 61 + ...pache.dubbo.common.serialize.Serialization | 1 + .../dubbo-serialization-test/pom.xml | 5 + .../GenericProtobufObjectOutputTest.java | 85 + .../GenericProtobufSerializationTest.java | 26 + .../protobuf/support/model/GooglePB.java | 3431 +++++++++++++++++ .../test/resources/protobuf/GooglePB.proto | 51 + dubbo-serialization/pom.xml | 1 + 18 files changed, 4051 insertions(+), 3 deletions(-) create mode 100644 dubbo-serialization/dubbo-serialization-protobuf-json/pom.xml create mode 100644 dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectInput.java create mode 100644 dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutput.java create mode 100644 dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java create mode 100644 dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/ProtobufUtils.java create mode 100644 dubbo-serialization/dubbo-serialization-protobuf-json/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.common.serialize.Serialization create mode 100644 dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutputTest.java create mode 100644 dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerializationTest.java create mode 100644 dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/model/GooglePB.java create mode 100644 dubbo-serialization/dubbo-serialization-test/src/test/resources/protobuf/GooglePB.proto diff --git a/dubbo-all/pom.xml b/dubbo-all/pom.xml index c38263aa7b..c353874f88 100644 --- a/dubbo-all/pom.xml +++ b/dubbo-all/pom.xml @@ -387,6 +387,13 @@ compile true + + org.apache.dubbo + dubbo-serialization-protobuf-json + ${project.version} + compile + true + org.apache.dubbo dubbo-configcenter-api @@ -585,6 +592,7 @@ org.apache.dubbo:dubbo-serialization-jdk org.apache.dubbo:dubbo-serialization-protostuff org.apache.dubbo:dubbo-serialization-gson + org.apache.dubbo:dubbo-serialization-googlePb org.apache.dubbo:dubbo-configcenter-api org.apache.dubbo:dubbo-configcenter-definition org.apache.dubbo:dubbo-configcenter-apollo diff --git a/dubbo-bom/pom.xml b/dubbo-bom/pom.xml index 5656864623..a7e44dcf6d 100644 --- a/dubbo-bom/pom.xml +++ b/dubbo-bom/pom.xml @@ -342,6 +342,11 @@ dubbo-serialization-gson ${project.version} + + org.apache.dubbo + dubbo-serialization-protobuf-json + ${project.version} + org.apache.dubbo dubbo-compatible diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java index c89a31421f..cc52e77d6f 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java @@ -727,6 +727,8 @@ public class Constants { public static final String GENERIC_SERIALIZATION_BEAN = "bean"; + public static final String GENERIC_SERIALIZATION_PROTOBUF = "protobuf-json"; + public static final String DUBBO_IP_TO_REGISTRY = "DUBBO_IP_TO_REGISTRY"; public static final String DUBBO_PORT_TO_REGISTRY = "DUBBO_PORT_TO_REGISTRY"; diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml index fa5434c964..6fc9a88ebc 100644 --- a/dubbo-dependencies-bom/pom.xml +++ b/dubbo-dependencies-bom/pom.xml @@ -108,6 +108,7 @@ 3.1.15 0.12.0 4.0.38 + 3.6.0 3.1.0 9.4.11.v20180605 1.1.0.Final @@ -271,6 +272,16 @@ hessian-lite ${hessian_lite_version} + + com.google.protobuf + protobuf-java + ${protobuf-java_version} + + + com.google.protobuf + protobuf-java-util + ${protobuf-java_version} + javax.servlet javax.servlet-api diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java index ae7b92c40f..fdbfdef275 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java @@ -76,7 +76,7 @@ public class GenericFilter implements Filter { } else if (ProtocolUtils.isJavaGenericSerialization(generic)) { for (int i = 0; i < args.length; i++) { if (byte[].class == args[i].getClass()) { - try(UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i])) { + try (UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i])) { args[i] = ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA) .deserialize(null, is).readObject(); @@ -107,6 +107,26 @@ public class GenericFilter implements Filter { args[i].getClass().getName()); } } + } else if (ProtocolUtils.isProtobufGenericSerialization(generic)) { + // as proto3 only accept one protobuf parameter + if (args.length == 1 && args[0] instanceof String) { + try (UnsafeByteArrayInputStream is = + new UnsafeByteArrayInputStream(((String) args[0]).getBytes())) { + args[0] = ExtensionLoader.getExtensionLoader(Serialization.class) + .getExtension("" + Constants.GENERIC_SERIALIZATION_PROTOBUF) + .deserialize(null, is).readObject(method.getParameterTypes()[0]); + } catch (Exception e) { + throw new RpcException("Deserialize argument failed.", e); + } + } else { + throw new RpcException( + "Generic serialization [" + + Constants.GENERIC_SERIALIZATION_PROTOBUF + + "] only support one" + String.class.getName() + + " argument and your message size is " + + args.length + " and type is" + + args[0].getClass().getName()); + } } Result result = invoker.invoke(new RpcInvocation(method, args, inv.getAttachments())); if (result.hasException() @@ -121,10 +141,25 @@ public class GenericFilter implements Filter { .serialize(null, os).writeObject(result.getValue()); return new RpcResult(os.toByteArray()); } catch (IOException e) { - throw new RpcException("Serialize result failed.", e); + throw new RpcException( + "Generic serialization [" + + Constants.GENERIC_SERIALIZATION_NATIVE_JAVA + + "] serialize result failed.", e); } } else if (ProtocolUtils.isBeanGenericSerialization(generic)) { return new RpcResult(JavaBeanSerializeUtil.serialize(result.getValue(), JavaBeanAccessor.METHOD)); + } else if (ProtocolUtils.isProtobufGenericSerialization(generic)) { + try { + UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream(512); + ExtensionLoader.getExtensionLoader(Serialization.class) + .getExtension(Constants.GENERIC_SERIALIZATION_PROTOBUF) + .serialize(null, os).writeObject(result.getValue()); + return new RpcResult(os.toString()); + } catch (IOException e) { + throw new RpcException("Generic serialization [" + + Constants.GENERIC_SERIALIZATION_PROTOBUF + + "] serialize result failed.", e); + } } else { return new RpcResult(PojoUtils.generalize(result.getValue())); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/ProtocolUtils.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/ProtocolUtils.java index ce5da6b51b..a64717c26c 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/ProtocolUtils.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/ProtocolUtils.java @@ -51,7 +51,8 @@ public class ProtocolUtils { && !"".equals(generic) && (Constants.GENERIC_SERIALIZATION_DEFAULT.equalsIgnoreCase(generic) /* Normal generalization cal */ || Constants.GENERIC_SERIALIZATION_NATIVE_JAVA.equalsIgnoreCase(generic) /* Streaming generalization call supporting jdk serialization */ - || Constants.GENERIC_SERIALIZATION_BEAN.equalsIgnoreCase(generic)); + || Constants.GENERIC_SERIALIZATION_BEAN.equalsIgnoreCase(generic) + || Constants.GENERIC_SERIALIZATION_PROTOBUF.equalsIgnoreCase(generic)); } public static boolean isDefaultGenericSerialization(String generic) { @@ -67,4 +68,8 @@ public class ProtocolUtils { public static boolean isBeanGenericSerialization(String generic) { return isGeneric(generic) && Constants.GENERIC_SERIALIZATION_BEAN.equals(generic); } + + public static boolean isProtobufGenericSerialization(String generic) { + return isGeneric(generic) && Constants.GENERIC_SERIALIZATION_PROTOBUF.equals(generic); + } } diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/pom.xml b/dubbo-serialization/dubbo-serialization-protobuf-json/pom.xml new file mode 100644 index 0000000000..6580e8705a --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-protobuf-json/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + dubbo-serialization + org.apache.dubbo + ${revision} + + dubbo-serialization-protobuf-json + jar + ${project.artifactId} + The protobuf serialization module of dubbo project + + false + + + + org.apache.dubbo + dubbo-serialization-api + ${project.parent.version} + + + com.google.protobuf + protobuf-java + + + com.google.protobuf + protobuf-java-util + + + \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectInput.java b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectInput.java new file mode 100644 index 0000000000..a1c565037d --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectInput.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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. + */ +package org.apache.dubbo.common.serialize.protobuf.support; + +import org.apache.dubbo.common.serialize.ObjectInput; + +import java.io.BufferedReader; +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; + +/** + * GenericGoogleProtobuf object input implementation + */ +public class GenericProtobufObjectInput implements ObjectInput { + private final BufferedReader reader; + + public GenericProtobufObjectInput(InputStream in) { + this.reader = new BufferedReader(new InputStreamReader(in)); + } + + @Override + public boolean readBool() throws IOException { + return read(boolean.class); + } + + @Override + public byte readByte() throws IOException { + return read(byte.class); + } + + @Override + public short readShort() throws IOException { + return read(short.class); + } + + @Override + public int readInt() throws IOException { + return read(int.class); + } + + @Override + public long readLong() throws IOException { + return read(long.class); + } + + @Override + public float readFloat() throws IOException { + return read(float.class); + } + + @Override + public double readDouble() throws IOException { + return read(double.class); + } + + @Override + public String readUTF() throws IOException { + return read(String.class); + } + + @Override + public byte[] readBytes() throws IOException { + return readLine().getBytes(); + } + + @Override + public Object readObject() throws IOException { + return read(String.class); + } + + @Override + public T readObject(Class cls) throws IOException { + return read(cls); + } + + @Override + @SuppressWarnings("unchecked") + public T readObject(Class cls, Type type) throws IOException { + return readObject(cls); + } + + private String readLine() throws IOException { + String line = reader.readLine(); + if (line == null || line.trim().length() == 0) { + throw new EOFException(); + } + return line; + } + + private T read(Class cls) throws IOException { + if (!ProtobufUtils.isSupported(cls)) { + throw new IllegalArgumentException("This serialization only support google protobuf entity, the class is :" + cls.getName()); + } + + String json = readLine(); + return ProtobufUtils.deserialize(json, cls); + } +} diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutput.java b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutput.java new file mode 100644 index 0000000000..93b488edc7 --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutput.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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. + */ +package org.apache.dubbo.common.serialize.protobuf.support; + +import org.apache.dubbo.common.serialize.ObjectOutput; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; + +/** + * GenericGoogleProtobuf object output implementation + */ +public class GenericProtobufObjectOutput implements ObjectOutput { + + private final PrintWriter writer; + + public GenericProtobufObjectOutput(OutputStream out) { + this.writer = new PrintWriter(new OutputStreamWriter(out)); + } + + @Override + public void writeBool(boolean v) throws IOException { + writeObject(v); + } + + @Override + public void writeByte(byte v) throws IOException { + writeObject(v); + } + + @Override + public void writeShort(short v) throws IOException { + writeObject(v); + } + + @Override + public void writeInt(int v) throws IOException { + writeObject(v); + } + + @Override + public void writeLong(long v) throws IOException { + writeObject(v); + } + + @Override + public void writeFloat(float v) throws IOException { + writeObject(v); + } + + @Override + public void writeDouble(double v) throws IOException { + writeObject(v); + } + + @Override + public void writeUTF(String v) throws IOException { + writeObject(v); + } + + @Override + public void writeBytes(byte[] b) { + writer.println(new String(b)); + } + + @Override + public void writeBytes(byte[] b, int off, int len) { + writer.println(new String(b, off, len)); + } + + @Override + public void writeObject(Object obj) throws IOException { + if (obj == null) { + throw new IllegalArgumentException("This serialization only support google protobuf object, the object is : null"); + } + + if (!ProtobufUtils.isSupported(obj.getClass())) { + throw new IllegalArgumentException("This serialization only support google protobuf object, the object class is: " + obj.getClass().getName()); + } + + writer.write(ProtobufUtils.serialize(obj)); + writer.println(); + writer.flush(); + } + + @Override + public void flushBuffer() { + writer.flush(); + } + +} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java new file mode 100644 index 0000000000..8b9395c95b --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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. + */ +package org.apache.dubbo.common.serialize.protobuf.support; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.serialize.ObjectInput; +import org.apache.dubbo.common.serialize.ObjectOutput; +import org.apache.dubbo.common.serialize.Serialization; + +import java.io.InputStream; +import java.io.OutputStream; + +/** + * This serizalization is use for google protobuf generic reference. + * The entity be transported between client and server by json string. + * + */ +public class GenericProtobufSerialization implements Serialization { + + @Override + public byte getContentTypeId() { + return 21; + } + + @Override + public String getContentType() { + return "text/json"; + } + + @Override + public ObjectOutput serialize(URL url, OutputStream output) { + return new GenericProtobufObjectOutput(output); + } + + @Override + public ObjectInput deserialize(URL url, InputStream input) { + return new GenericProtobufObjectInput(input); + } +} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/ProtobufUtils.java b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/ProtobufUtils.java new file mode 100644 index 0000000000..7a2eda8814 --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/ProtobufUtils.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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. + */ +package org.apache.dubbo.common.serialize.protobuf.support; + +import com.google.protobuf.GeneratedMessageV3; +import com.google.protobuf.GeneratedMessageV3.Builder; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.MessageOrBuilder; +import com.google.protobuf.util.JsonFormat; +import com.google.protobuf.util.JsonFormat.Printer; + +import java.lang.reflect.Method; + +public class ProtobufUtils { + + static boolean isSupported(Class clazz) { + if (clazz == null) { + return false; + } + + if (GeneratedMessageV3.class.isAssignableFrom(clazz)) { + return true; + } + return false; + } + + static T deserialize(String json, Class requestClass) throws InvalidProtocolBufferException { + Builder builder; + try { + builder = getMessageBuilder(requestClass); + } catch (Exception e) { + throw new IllegalArgumentException("Get google protobuf message builder from " + requestClass.getName() + "failed", e); + } + JsonFormat.parser().merge(json, builder); + return (T) builder.build(); + } + + static String serialize(Object value) throws InvalidProtocolBufferException { + Printer printer = JsonFormat.printer().omittingInsignificantWhitespace(); + return printer.print((MessageOrBuilder) value); + } + + private static Builder getMessageBuilder(Class requestType) throws Exception { + Method method = requestType.getMethod("newBuilder"); + return (Builder) method.invoke(null, null); + } +} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.common.serialize.Serialization b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.common.serialize.Serialization new file mode 100644 index 0000000000..56d6b68bf0 --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.common.serialize.Serialization @@ -0,0 +1 @@ +protobuf-json=org.apache.dubbo.common.serialize.protobuf.support.GenericProtobufSerialization \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-test/pom.xml b/dubbo-serialization/dubbo-serialization-test/pom.xml index 868b45bc82..60d0c5ff0f 100644 --- a/dubbo-serialization/dubbo-serialization-test/pom.xml +++ b/dubbo-serialization/dubbo-serialization-test/pom.xml @@ -77,5 +77,10 @@ dubbo-serialization-avro ${project.parent.version} + + org.apache.dubbo + dubbo-serialization-protobuf-json + ${project.parent.version} + diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutputTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutputTest.java new file mode 100644 index 0000000000..e420aec82a --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutputTest.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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. + */ +package org.apache.dubbo.common.serialize.protobuf.support; + +import org.apache.dubbo.common.serialize.protobuf.support.model.GooglePB; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + + +public class GenericProtobufObjectOutputTest { + private ByteArrayOutputStream byteArrayOutputStream; + private GenericProtobufObjectOutput genericProtobufObjectOutput; + private GenericProtobufObjectInput genericProtobufObjectInput; + private ByteArrayInputStream byteArrayInputStream; + + @BeforeEach + public void setUp() { + this.byteArrayOutputStream = new ByteArrayOutputStream(); + this.genericProtobufObjectOutput = new GenericProtobufObjectOutput(byteArrayOutputStream); + } + + @Test + public void testWriteObjectNull() throws IOException { + assertThrows(IllegalArgumentException.class, () -> { + this.genericProtobufObjectOutput.writeObject(null); + }); + } + + @Test + public void testWriteGooglePbObject() throws IOException { + Random random = new Random(); + final int bound = 100000; + List phoneNumberList = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + phoneNumberList.add(GooglePB.PhoneNumber.newBuilder().setNumber(random.nextInt(bound) + "").setType(GooglePB.PhoneType.forNumber(random.nextInt(GooglePB.PhoneType.values().length - 1))).build()); + } + + Map phoneNumberMap = new HashMap<>(); + for (int i = 0; i < 5; i++) { + phoneNumberMap.put("phoneNumber" + i, GooglePB.PhoneNumber.newBuilder().setNumber(random.nextInt(bound) + "").setType(GooglePB.PhoneType.forNumber(random.nextInt(GooglePB.PhoneType.values().length - 1))).build()); + } + GooglePB.PBRequestType request = GooglePB.PBRequestType.newBuilder() + .setAge(15).setCash(10).setMoney(16.0).setNum(100L) + .addAllPhone(phoneNumberList).putAllDoubleMap(phoneNumberMap).build(); + + this.genericProtobufObjectOutput.writeObject(request); + this.flushToInput(); + assertThat(genericProtobufObjectInput.readObject(GooglePB.PBRequestType.class), is(request)); + } + + private void flushToInput() { + this.genericProtobufObjectOutput.flushBuffer(); + this.byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); + this.genericProtobufObjectInput = new GenericProtobufObjectInput(byteArrayInputStream); + } +} + diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerializationTest.java new file mode 100644 index 0000000000..6a7748edd6 --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerializationTest.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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. + */ +package org.apache.dubbo.common.serialize.protobuf.support; + +import org.apache.dubbo.common.serialize.base.AbstractSerializationTest; +import org.apache.dubbo.common.serialize.protostuff.ProtostuffSerialization; + +public class GenericProtobufSerializationTest extends AbstractSerializationTest { + { + serialization = new ProtostuffSerialization(); + } +} diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/model/GooglePB.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/model/GooglePB.java new file mode 100644 index 0000000000..257b37f91b --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/model/GooglePB.java @@ -0,0 +1,3431 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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: GooglePB.proto + +package org.apache.dubbo.common.serialize.protobuf.support.model; + +public final class GooglePB { + private GooglePB() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + /** + * Protobuf enum {@code org.apache.dubbo.common.serialize.protobuf.model.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. + */ + @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< + PhoneType> 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 GooglePB.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 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:org.apache.dubbo.common.serialize.protobuf.model.PhoneType) + } + + public interface PBRequestTypeOrBuilder extends + // @@protoc_insertion_point(interface_extends:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) + com.google.protobuf.MessageOrBuilder { + + /** + * optional double money = 1; + */ + boolean hasMoney(); + /** + * optional double money = 1; + */ + double getMoney(); + + /** + * optional float cash = 2; + */ + boolean hasCash(); + /** + * optional float cash = 2; + */ + float getCash(); + + /** + * optional int32 age = 3; + */ + boolean hasAge(); + /** + * optional int32 age = 3; + */ + int getAge(); + + /** + * optional int64 num = 4; + */ + boolean hasNum(); + /** + * optional int64 num = 4; + */ + long getNum(); + + /** + * optional bool sex = 5; + */ + boolean hasSex(); + /** + * optional bool sex = 5; + */ + boolean getSex(); + + /** + * optional string name = 6; + */ + boolean hasName(); + /** + * optional string name = 6; + */ + String getName(); + /** + * optional string name = 6; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional bytes msg = 7; + */ + boolean hasMsg(); + /** + * optional bytes msg = 7; + */ + com.google.protobuf.ByteString getMsg(); + + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + java.util.List + getPhoneList(); + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + GooglePB.PhoneNumber getPhone(int index); + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + int getPhoneCount(); + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + java.util.List + getPhoneOrBuilderList(); + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + GooglePB.PhoneNumberOrBuilder getPhoneOrBuilder( + int index); + + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + int getDoubleMapCount(); + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + boolean containsDoubleMap( + String key); + /** + * Use {@link #getDoubleMapMap()} instead. + */ + @Deprecated + java.util.Map + getDoubleMap(); + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + java.util.Map + getDoubleMapMap(); + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + GooglePB.PhoneNumber getDoubleMapOrDefault( + String key, + GooglePB.PhoneNumber defaultValue); + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + GooglePB.PhoneNumber getDoubleMapOrThrow( + String key); + } + /** + * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PBRequestType} + */ + public static final class PBRequestType extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) + PBRequestTypeOrBuilder { + private static final long serialVersionUID = 0L; + // Use PBRequestType.newBuilder() to construct. + private PBRequestType(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PBRequestType() { + money_ = 0D; + cash_ = 0F; + age_ = 0; + num_ = 0L; + sex_ = false; + name_ = ""; + msg_ = com.google.protobuf.ByteString.EMPTY; + phone_ = java.util.Collections.emptyList(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PBRequestType( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + 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; + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 9: { + bitField0_ |= 0x00000001; + money_ = input.readDouble(); + break; + } + case 21: { + bitField0_ |= 0x00000002; + cash_ = input.readFloat(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + age_ = input.readInt32(); + break; + } + case 32: { + bitField0_ |= 0x00000008; + num_ = input.readInt64(); + break; + } + case 40: { + bitField0_ |= 0x00000010; + sex_ = input.readBool(); + break; + } + case 50: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000020; + name_ = bs; + break; + } + case 58: { + bitField0_ |= 0x00000040; + msg_ = input.readBytes(); + break; + } + case 66: { + if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + phone_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000080; + } + phone_.add( + input.readMessage(GooglePB.PhoneNumber.PARSER, extensionRegistry)); + break; + } + case 74: { + if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) { + doubleMap_ = com.google.protobuf.MapField.newMapField( + DoubleMapDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000100; + } + com.google.protobuf.MapEntry + doubleMap__ = input.readMessage( + DoubleMapDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + doubleMap_.getMutableMap().put( + doubleMap__.getKey(), doubleMap__.getValue()); + 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_ & 0x00000080) == 0x00000080)) { + phone_ = java.util.Collections.unmodifiableList(phone_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 9: + return internalGetDoubleMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_fieldAccessorTable + .ensureFieldAccessorsInitialized( + GooglePB.PBRequestType.class, GooglePB.PBRequestType.Builder.class); + } + + private int bitField0_; + public static final int MONEY_FIELD_NUMBER = 1; + private double money_; + /** + * optional double money = 1; + */ + public boolean hasMoney() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional double money = 1; + */ + public double getMoney() { + return money_; + } + + public static final int CASH_FIELD_NUMBER = 2; + private float cash_; + /** + * optional float cash = 2; + */ + public boolean hasCash() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional float cash = 2; + */ + public float getCash() { + return cash_; + } + + public static final int AGE_FIELD_NUMBER = 3; + private int age_; + /** + * optional int32 age = 3; + */ + public boolean hasAge() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int32 age = 3; + */ + public int getAge() { + return age_; + } + + public static final int NUM_FIELD_NUMBER = 4; + private long num_; + /** + * optional int64 num = 4; + */ + public boolean hasNum() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int64 num = 4; + */ + public long getNum() { + return num_; + } + + public static final int SEX_FIELD_NUMBER = 5; + private boolean sex_; + /** + * optional bool sex = 5; + */ + public boolean hasSex() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional bool sex = 5; + */ + public boolean getSex() { + return sex_; + } + + public static final int NAME_FIELD_NUMBER = 6; + private volatile Object name_; + /** + * optional string name = 6; + */ + public boolean hasName() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional string name = 6; + */ + public String getName() { + Object ref = name_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } + } + /** + * optional string name = 6; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MSG_FIELD_NUMBER = 7; + private com.google.protobuf.ByteString msg_; + /** + * optional bytes msg = 7; + */ + public boolean hasMsg() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + /** + * optional bytes msg = 7; + */ + public com.google.protobuf.ByteString getMsg() { + return msg_; + } + + public static final int PHONE_FIELD_NUMBER = 8; + private java.util.List phone_; + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public java.util.List getPhoneList() { + return phone_; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public java.util.List + getPhoneOrBuilderList() { + return phone_; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public int getPhoneCount() { + return phone_.size(); + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public GooglePB.PhoneNumber getPhone(int index) { + return phone_.get(index); + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public GooglePB.PhoneNumberOrBuilder getPhoneOrBuilder( + int index) { + return phone_.get(index); + } + + public static final int DOUBLEMAP_FIELD_NUMBER = 9; + private static final class DoubleMapDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + String, PhoneNumber> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + GooglePB.PhoneNumber.getDefaultInstance()); + } + private com.google.protobuf.MapField< + String, PhoneNumber> doubleMap_; + private com.google.protobuf.MapField + internalGetDoubleMap() { + if (doubleMap_ == null) { + return com.google.protobuf.MapField.emptyMapField( + DoubleMapDefaultEntryHolder.defaultEntry); + } + return doubleMap_; + } + + public int getDoubleMapCount() { + return internalGetDoubleMap().getMap().size(); + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public boolean containsDoubleMap( + String key) { + if (key == null) { throw new NullPointerException(); } + return internalGetDoubleMap().getMap().containsKey(key); + } + /** + * Use {@link #getDoubleMapMap()} instead. + */ + @Deprecated + public java.util.Map getDoubleMap() { + return getDoubleMapMap(); + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public java.util.Map getDoubleMapMap() { + return internalGetDoubleMap().getMap(); + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public GooglePB.PhoneNumber getDoubleMapOrDefault( + String key, + GooglePB.PhoneNumber defaultValue) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetDoubleMap().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public GooglePB.PhoneNumber getDoubleMapOrThrow( + String key) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetDoubleMap().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + for (int i = 0; i < getPhoneCount(); i++) { + if (!getPhone(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + for (GooglePB.PhoneNumber item : getDoubleMapMap().values()) { + if (!item.isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeDouble(1, money_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeFloat(2, cash_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt32(3, age_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeInt64(4, num_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeBool(5, sex_); + } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, name_); + } + if (((bitField0_ & 0x00000040) == 0x00000040)) { + output.writeBytes(7, msg_); + } + for (int i = 0; i < phone_.size(); i++) { + output.writeMessage(8, phone_.get(i)); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetDoubleMap(), + DoubleMapDefaultEntryHolder.defaultEntry, + 9); + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(1, money_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(2, cash_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, age_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, num_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(5, sex_); + } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, name_); + } + if (((bitField0_ & 0x00000040) == 0x00000040)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(7, msg_); + } + for (int i = 0; i < phone_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, phone_.get(i)); + } + for (java.util.Map.Entry entry + : internalGetDoubleMap().getMap().entrySet()) { + com.google.protobuf.MapEntry + doubleMap__ = DoubleMapDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(9, doubleMap__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GooglePB.PBRequestType)) { + return super.equals(obj); + } + GooglePB.PBRequestType other = (GooglePB.PBRequestType) obj; + + boolean result = true; + result = result && (hasMoney() == other.hasMoney()); + if (hasMoney()) { + result = result && ( + Double.doubleToLongBits(getMoney()) + == Double.doubleToLongBits( + other.getMoney())); + } + result = result && (hasCash() == other.hasCash()); + if (hasCash()) { + result = result && ( + Float.floatToIntBits(getCash()) + == Float.floatToIntBits( + other.getCash())); + } + result = result && (hasAge() == other.hasAge()); + if (hasAge()) { + result = result && (getAge() + == other.getAge()); + } + result = result && (hasNum() == other.hasNum()); + if (hasNum()) { + result = result && (getNum() + == other.getNum()); + } + result = result && (hasSex() == other.hasSex()); + if (hasSex()) { + result = result && (getSex() + == other.getSex()); + } + result = result && (hasName() == other.hasName()); + if (hasName()) { + result = result && getName() + .equals(other.getName()); + } + result = result && (hasMsg() == other.hasMsg()); + if (hasMsg()) { + result = result && getMsg() + .equals(other.getMsg()); + } + result = result && getPhoneList() + .equals(other.getPhoneList()); + result = result && internalGetDoubleMap().equals( + other.internalGetDoubleMap()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasMoney()) { + hash = (37 * hash) + MONEY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + Double.doubleToLongBits(getMoney())); + } + if (hasCash()) { + hash = (37 * hash) + CASH_FIELD_NUMBER; + hash = (53 * hash) + Float.floatToIntBits( + getCash()); + } + if (hasAge()) { + hash = (37 * hash) + AGE_FIELD_NUMBER; + hash = (53 * hash) + getAge(); + } + if (hasNum()) { + hash = (37 * hash) + NUM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getNum()); + } + if (hasSex()) { + hash = (37 * hash) + SEX_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getSex()); + } + if (hasName()) { + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + } + if (hasMsg()) { + hash = (37 * hash) + MSG_FIELD_NUMBER; + hash = (53 * hash) + getMsg().hashCode(); + } + if (getPhoneCount() > 0) { + hash = (37 * hash) + PHONE_FIELD_NUMBER; + hash = (53 * hash) + getPhoneList().hashCode(); + } + if (!internalGetDoubleMap().getMap().isEmpty()) { + hash = (37 * hash) + DOUBLEMAP_FIELD_NUMBER; + hash = (53 * hash) + internalGetDoubleMap().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static GooglePB.PBRequestType parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PBRequestType parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PBRequestType parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PBRequestType parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PBRequestType parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PBRequestType parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PBRequestType parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static GooglePB.PBRequestType 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 GooglePB.PBRequestType parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static GooglePB.PBRequestType 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 GooglePB.PBRequestType parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static GooglePB.PBRequestType parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(GooglePB.PBRequestType prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PBRequestType} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) + GooglePB.PBRequestTypeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 9: + return internalGetDoubleMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 9: + return internalGetMutableDoubleMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_fieldAccessorTable + .ensureFieldAccessorsInitialized( + GooglePB.PBRequestType.class, GooglePB.PBRequestType.Builder.class); + } + + // Construct using org.apache.dubbo.common.serialize.protobuf.model.GooglePB.PBRequestType.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getPhoneFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + money_ = 0D; + bitField0_ = (bitField0_ & ~0x00000001); + cash_ = 0F; + bitField0_ = (bitField0_ & ~0x00000002); + age_ = 0; + bitField0_ = (bitField0_ & ~0x00000004); + num_ = 0L; + bitField0_ = (bitField0_ & ~0x00000008); + sex_ = false; + bitField0_ = (bitField0_ & ~0x00000010); + name_ = ""; + bitField0_ = (bitField0_ & ~0x00000020); + msg_ = com.google.protobuf.ByteString.EMPTY; + bitField0_ = (bitField0_ & ~0x00000040); + if (phoneBuilder_ == null) { + phone_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + } else { + phoneBuilder_.clear(); + } + internalGetMutableDoubleMap().clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor; + } + + public GooglePB.PBRequestType getDefaultInstanceForType() { + return GooglePB.PBRequestType.getDefaultInstance(); + } + + public GooglePB.PBRequestType build() { + GooglePB.PBRequestType result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public GooglePB.PBRequestType buildPartial() { + GooglePB.PBRequestType result = new GooglePB.PBRequestType(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.money_ = money_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.cash_ = cash_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.age_ = age_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.num_ = num_; + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000010; + } + result.sex_ = sex_; + if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + to_bitField0_ |= 0x00000020; + } + result.name_ = name_; + if (((from_bitField0_ & 0x00000040) == 0x00000040)) { + to_bitField0_ |= 0x00000040; + } + result.msg_ = msg_; + if (phoneBuilder_ == null) { + if (((bitField0_ & 0x00000080) == 0x00000080)) { + phone_ = java.util.Collections.unmodifiableList(phone_); + bitField0_ = (bitField0_ & ~0x00000080); + } + result.phone_ = phone_; + } else { + result.phone_ = phoneBuilder_.build(); + } + result.doubleMap_ = internalGetDoubleMap(); + result.doubleMap_.makeImmutable(); + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof GooglePB.PBRequestType) { + return mergeFrom((GooglePB.PBRequestType)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(GooglePB.PBRequestType other) { + if (other == GooglePB.PBRequestType.getDefaultInstance()) return this; + if (other.hasMoney()) { + setMoney(other.getMoney()); + } + if (other.hasCash()) { + setCash(other.getCash()); + } + if (other.hasAge()) { + setAge(other.getAge()); + } + if (other.hasNum()) { + setNum(other.getNum()); + } + if (other.hasSex()) { + setSex(other.getSex()); + } + if (other.hasName()) { + bitField0_ |= 0x00000020; + name_ = other.name_; + onChanged(); + } + if (other.hasMsg()) { + setMsg(other.getMsg()); + } + if (phoneBuilder_ == null) { + if (!other.phone_.isEmpty()) { + if (phone_.isEmpty()) { + phone_ = other.phone_; + bitField0_ = (bitField0_ & ~0x00000080); + } else { + ensurePhoneIsMutable(); + phone_.addAll(other.phone_); + } + onChanged(); + } + } else { + if (!other.phone_.isEmpty()) { + if (phoneBuilder_.isEmpty()) { + phoneBuilder_.dispose(); + phoneBuilder_ = null; + phone_ = other.phone_; + bitField0_ = (bitField0_ & ~0x00000080); + phoneBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getPhoneFieldBuilder() : null; + } else { + phoneBuilder_.addAllMessages(other.phone_); + } + } + } + internalGetMutableDoubleMap().mergeFrom( + other.internalGetDoubleMap()); + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + for (int i = 0; i < getPhoneCount(); i++) { + if (!getPhone(i).isInitialized()) { + return false; + } + } + for (GooglePB.PhoneNumber item : getDoubleMapMap().values()) { + if (!item.isInitialized()) { + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + GooglePB.PBRequestType parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (GooglePB.PBRequestType) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private double money_ ; + /** + * optional double money = 1; + */ + public boolean hasMoney() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional double money = 1; + */ + public double getMoney() { + return money_; + } + /** + * optional double money = 1; + */ + public Builder setMoney(double value) { + bitField0_ |= 0x00000001; + money_ = value; + onChanged(); + return this; + } + /** + * optional double money = 1; + */ + public Builder clearMoney() { + bitField0_ = (bitField0_ & ~0x00000001); + money_ = 0D; + onChanged(); + return this; + } + + private float cash_ ; + /** + * optional float cash = 2; + */ + public boolean hasCash() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional float cash = 2; + */ + public float getCash() { + return cash_; + } + /** + * optional float cash = 2; + */ + public Builder setCash(float value) { + bitField0_ |= 0x00000002; + cash_ = value; + onChanged(); + return this; + } + /** + * optional float cash = 2; + */ + public Builder clearCash() { + bitField0_ = (bitField0_ & ~0x00000002); + cash_ = 0F; + onChanged(); + return this; + } + + private int age_ ; + /** + * optional int32 age = 3; + */ + public boolean hasAge() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int32 age = 3; + */ + public int getAge() { + return age_; + } + /** + * optional int32 age = 3; + */ + public Builder setAge(int value) { + bitField0_ |= 0x00000004; + age_ = value; + onChanged(); + return this; + } + /** + * optional int32 age = 3; + */ + public Builder clearAge() { + bitField0_ = (bitField0_ & ~0x00000004); + age_ = 0; + onChanged(); + return this; + } + + private long num_ ; + /** + * optional int64 num = 4; + */ + public boolean hasNum() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int64 num = 4; + */ + public long getNum() { + return num_; + } + /** + * optional int64 num = 4; + */ + public Builder setNum(long value) { + bitField0_ |= 0x00000008; + num_ = value; + onChanged(); + return this; + } + /** + * optional int64 num = 4; + */ + public Builder clearNum() { + bitField0_ = (bitField0_ & ~0x00000008); + num_ = 0L; + onChanged(); + return this; + } + + private boolean sex_ ; + /** + * optional bool sex = 5; + */ + public boolean hasSex() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional bool sex = 5; + */ + public boolean getSex() { + return sex_; + } + /** + * optional bool sex = 5; + */ + public Builder setSex(boolean value) { + bitField0_ |= 0x00000010; + sex_ = value; + onChanged(); + return this; + } + /** + * optional bool sex = 5; + */ + public Builder clearSex() { + bitField0_ = (bitField0_ & ~0x00000010); + sex_ = false; + onChanged(); + return this; + } + + private Object name_ = ""; + /** + * optional string name = 6; + */ + public boolean hasName() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional string name = 6; + */ + public String getName() { + Object ref = name_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string name = 6; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 6; + */ + public Builder setName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 6; + */ + public Builder clearName() { + bitField0_ = (bitField0_ & ~0x00000020); + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 6; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + name_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString msg_ = com.google.protobuf.ByteString.EMPTY; + /** + * optional bytes msg = 7; + */ + public boolean hasMsg() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + /** + * optional bytes msg = 7; + */ + public com.google.protobuf.ByteString getMsg() { + return msg_; + } + /** + * optional bytes msg = 7; + */ + public Builder setMsg(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + msg_ = value; + onChanged(); + return this; + } + /** + * optional bytes msg = 7; + */ + public Builder clearMsg() { + bitField0_ = (bitField0_ & ~0x00000040); + msg_ = getDefaultInstance().getMsg(); + onChanged(); + return this; + } + + private java.util.List phone_ = + java.util.Collections.emptyList(); + private void ensurePhoneIsMutable() { + if (!((bitField0_ & 0x00000080) == 0x00000080)) { + phone_ = new java.util.ArrayList(phone_); + bitField0_ |= 0x00000080; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + PhoneNumber, PhoneNumber.Builder, PhoneNumberOrBuilder> phoneBuilder_; + + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public java.util.List getPhoneList() { + if (phoneBuilder_ == null) { + return java.util.Collections.unmodifiableList(phone_); + } else { + return phoneBuilder_.getMessageList(); + } + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public int getPhoneCount() { + if (phoneBuilder_ == null) { + return phone_.size(); + } else { + return phoneBuilder_.getCount(); + } + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public GooglePB.PhoneNumber getPhone(int index) { + if (phoneBuilder_ == null) { + return phone_.get(index); + } else { + return phoneBuilder_.getMessage(index); + } + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder setPhone( + int index, GooglePB.PhoneNumber value) { + if (phoneBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhoneIsMutable(); + phone_.set(index, value); + onChanged(); + } else { + phoneBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder setPhone( + int index, GooglePB.PhoneNumber.Builder builderForValue) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + phone_.set(index, builderForValue.build()); + onChanged(); + } else { + phoneBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder addPhone(GooglePB.PhoneNumber value) { + if (phoneBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhoneIsMutable(); + phone_.add(value); + onChanged(); + } else { + phoneBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder addPhone( + int index, GooglePB.PhoneNumber value) { + if (phoneBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhoneIsMutable(); + phone_.add(index, value); + onChanged(); + } else { + phoneBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder addPhone( + GooglePB.PhoneNumber.Builder builderForValue) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + phone_.add(builderForValue.build()); + onChanged(); + } else { + phoneBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder addPhone( + int index, GooglePB.PhoneNumber.Builder builderForValue) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + phone_.add(index, builderForValue.build()); + onChanged(); + } else { + phoneBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder addAllPhone( + Iterable values) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, phone_); + onChanged(); + } else { + phoneBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder clearPhone() { + if (phoneBuilder_ == null) { + phone_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + onChanged(); + } else { + phoneBuilder_.clear(); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public Builder removePhone(int index) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + phone_.remove(index); + onChanged(); + } else { + phoneBuilder_.remove(index); + } + return this; + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public GooglePB.PhoneNumber.Builder getPhoneBuilder( + int index) { + return getPhoneFieldBuilder().getBuilder(index); + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public GooglePB.PhoneNumberOrBuilder getPhoneOrBuilder( + int index) { + if (phoneBuilder_ == null) { + return phone_.get(index); } else { + return phoneBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public java.util.List + getPhoneOrBuilderList() { + if (phoneBuilder_ != null) { + return phoneBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(phone_); + } + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public GooglePB.PhoneNumber.Builder addPhoneBuilder() { + return getPhoneFieldBuilder().addBuilder( + GooglePB.PhoneNumber.getDefaultInstance()); + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public GooglePB.PhoneNumber.Builder addPhoneBuilder( + int index) { + return getPhoneFieldBuilder().addBuilder( + index, GooglePB.PhoneNumber.getDefaultInstance()); + } + /** + * repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + */ + public java.util.List + getPhoneBuilderList() { + return getPhoneFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + PhoneNumber, PhoneNumber.Builder, PhoneNumberOrBuilder> + getPhoneFieldBuilder() { + if (phoneBuilder_ == null) { + phoneBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + PhoneNumber, PhoneNumber.Builder, PhoneNumberOrBuilder>( + phone_, + ((bitField0_ & 0x00000080) == 0x00000080), + getParentForChildren(), + isClean()); + phone_ = null; + } + return phoneBuilder_; + } + + private com.google.protobuf.MapField< + String, PhoneNumber> doubleMap_; + private com.google.protobuf.MapField + internalGetDoubleMap() { + if (doubleMap_ == null) { + return com.google.protobuf.MapField.emptyMapField( + DoubleMapDefaultEntryHolder.defaultEntry); + } + return doubleMap_; + } + private com.google.protobuf.MapField + internalGetMutableDoubleMap() { + onChanged();; + if (doubleMap_ == null) { + doubleMap_ = com.google.protobuf.MapField.newMapField( + DoubleMapDefaultEntryHolder.defaultEntry); + } + if (!doubleMap_.isMutable()) { + doubleMap_ = doubleMap_.copy(); + } + return doubleMap_; + } + + public int getDoubleMapCount() { + return internalGetDoubleMap().getMap().size(); + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public boolean containsDoubleMap( + String key) { + if (key == null) { throw new NullPointerException(); } + return internalGetDoubleMap().getMap().containsKey(key); + } + /** + * Use {@link #getDoubleMapMap()} instead. + */ + @Deprecated + public java.util.Map getDoubleMap() { + return getDoubleMapMap(); + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public java.util.Map getDoubleMapMap() { + return internalGetDoubleMap().getMap(); + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public GooglePB.PhoneNumber getDoubleMapOrDefault( + String key, + GooglePB.PhoneNumber defaultValue) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetDoubleMap().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public GooglePB.PhoneNumber getDoubleMapOrThrow( + String key) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetDoubleMap().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearDoubleMap() { + internalGetMutableDoubleMap().getMutableMap() + .clear(); + return this; + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public Builder removeDoubleMap( + String key) { + if (key == null) { throw new NullPointerException(); } + internalGetMutableDoubleMap().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @Deprecated + public java.util.Map + getMutableDoubleMap() { + return internalGetMutableDoubleMap().getMutableMap(); + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + public Builder putDoubleMap( + String key, + GooglePB.PhoneNumber value) { + if (key == null) { throw new NullPointerException(); } + if (value == null) { throw new NullPointerException(); } + internalGetMutableDoubleMap().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9; + */ + + public Builder putAllDoubleMap( + java.util.Map values) { + internalGetMutableDoubleMap().getMutableMap() + .putAll(values); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) + } + + // @@protoc_insertion_point(class_scope:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) + private static final GooglePB.PBRequestType DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new GooglePB.PBRequestType(); + } + + public static GooglePB.PBRequestType getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @Deprecated public static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PBRequestType parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PBRequestType(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public GooglePB.PBRequestType getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface PBResponseTypeOrBuilder extends + // @@protoc_insertion_point(interface_extends:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string msg = 1; + */ + boolean hasMsg(); + /** + * optional string msg = 1; + */ + String getMsg(); + /** + * optional string msg = 1; + */ + com.google.protobuf.ByteString + getMsgBytes(); + + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + boolean hasCDubboPBRequestType(); + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + GooglePB.PBRequestType getCDubboPBRequestType(); + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + GooglePB.PBRequestTypeOrBuilder getCDubboPBRequestTypeOrBuilder(); + } + /** + * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PBResponseType} + */ + public static final class PBResponseType extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) + PBResponseTypeOrBuilder { + private static final long serialVersionUID = 0L; + // Use PBResponseType.newBuilder() to construct. + private PBResponseType(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PBResponseType() { + msg_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PBResponseType( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + 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; + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000001; + msg_ = bs; + break; + } + case 26: { + GooglePB.PBRequestType.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + subBuilder = cDubboPBRequestType_.toBuilder(); + } + cDubboPBRequestType_ = input.readMessage(GooglePB.PBRequestType.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(cDubboPBRequestType_); + cDubboPBRequestType_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000002; + 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 GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_fieldAccessorTable + .ensureFieldAccessorsInitialized( + GooglePB.PBResponseType.class, GooglePB.PBResponseType.Builder.class); + } + + private int bitField0_; + public static final int MSG_FIELD_NUMBER = 1; + private volatile Object msg_; + /** + * optional string msg = 1; + */ + public boolean hasMsg() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string msg = 1; + */ + public String getMsg() { + Object ref = msg_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + msg_ = s; + } + return s; + } + } + /** + * optional string msg = 1; + */ + public com.google.protobuf.ByteString + getMsgBytes() { + Object ref = msg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + msg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CDUBBOPBREQUESTTYPE_FIELD_NUMBER = 3; + private GooglePB.PBRequestType cDubboPBRequestType_; + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public boolean hasCDubboPBRequestType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public GooglePB.PBRequestType getCDubboPBRequestType() { + return cDubboPBRequestType_ == null ? GooglePB.PBRequestType.getDefaultInstance() : cDubboPBRequestType_; + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public GooglePB.PBRequestTypeOrBuilder getCDubboPBRequestTypeOrBuilder() { + return cDubboPBRequestType_ == null ? GooglePB.PBRequestType.getDefaultInstance() : cDubboPBRequestType_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (hasCDubboPBRequestType()) { + if (!getCDubboPBRequestType().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, msg_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeMessage(3, getCDubboPBRequestType()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, msg_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getCDubboPBRequestType()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GooglePB.PBResponseType)) { + return super.equals(obj); + } + GooglePB.PBResponseType other = (GooglePB.PBResponseType) obj; + + boolean result = true; + result = result && (hasMsg() == other.hasMsg()); + if (hasMsg()) { + result = result && getMsg() + .equals(other.getMsg()); + } + result = result && (hasCDubboPBRequestType() == other.hasCDubboPBRequestType()); + if (hasCDubboPBRequestType()) { + result = result && getCDubboPBRequestType() + .equals(other.getCDubboPBRequestType()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasMsg()) { + hash = (37 * hash) + MSG_FIELD_NUMBER; + hash = (53 * hash) + getMsg().hashCode(); + } + if (hasCDubboPBRequestType()) { + hash = (37 * hash) + CDUBBOPBREQUESTTYPE_FIELD_NUMBER; + hash = (53 * hash) + getCDubboPBRequestType().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static GooglePB.PBResponseType parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PBResponseType parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PBResponseType parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PBResponseType parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PBResponseType parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PBResponseType parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PBResponseType parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static GooglePB.PBResponseType 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 GooglePB.PBResponseType parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static GooglePB.PBResponseType 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 GooglePB.PBResponseType parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static GooglePB.PBResponseType parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(GooglePB.PBResponseType prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PBResponseType} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) + GooglePB.PBResponseTypeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_fieldAccessorTable + .ensureFieldAccessorsInitialized( + GooglePB.PBResponseType.class, GooglePB.PBResponseType.Builder.class); + } + + // Construct using org.apache.dubbo.common.serialize.protobuf.model.GooglePB.PBResponseType.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getCDubboPBRequestTypeFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + msg_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + if (cDubboPBRequestTypeBuilder_ == null) { + cDubboPBRequestType_ = null; + } else { + cDubboPBRequestTypeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor; + } + + public GooglePB.PBResponseType getDefaultInstanceForType() { + return GooglePB.PBResponseType.getDefaultInstance(); + } + + public GooglePB.PBResponseType build() { + GooglePB.PBResponseType result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public GooglePB.PBResponseType buildPartial() { + GooglePB.PBResponseType result = new GooglePB.PBResponseType(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.msg_ = msg_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + if (cDubboPBRequestTypeBuilder_ == null) { + result.cDubboPBRequestType_ = cDubboPBRequestType_; + } else { + result.cDubboPBRequestType_ = cDubboPBRequestTypeBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof GooglePB.PBResponseType) { + return mergeFrom((GooglePB.PBResponseType)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(GooglePB.PBResponseType other) { + if (other == GooglePB.PBResponseType.getDefaultInstance()) return this; + if (other.hasMsg()) { + bitField0_ |= 0x00000001; + msg_ = other.msg_; + onChanged(); + } + if (other.hasCDubboPBRequestType()) { + mergeCDubboPBRequestType(other.getCDubboPBRequestType()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + if (hasCDubboPBRequestType()) { + if (!getCDubboPBRequestType().isInitialized()) { + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + GooglePB.PBResponseType parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (GooglePB.PBResponseType) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private Object msg_ = ""; + /** + * optional string msg = 1; + */ + public boolean hasMsg() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string msg = 1; + */ + public String getMsg() { + Object ref = msg_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + msg_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * optional string msg = 1; + */ + public com.google.protobuf.ByteString + getMsgBytes() { + Object ref = msg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + msg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string msg = 1; + */ + public Builder setMsg( + String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + msg_ = value; + onChanged(); + return this; + } + /** + * optional string msg = 1; + */ + public Builder clearMsg() { + bitField0_ = (bitField0_ & ~0x00000001); + msg_ = getDefaultInstance().getMsg(); + onChanged(); + return this; + } + /** + * optional string msg = 1; + */ + public Builder setMsgBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + msg_ = value; + onChanged(); + return this; + } + + private GooglePB.PBRequestType cDubboPBRequestType_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + PBRequestType, PBRequestType.Builder, PBRequestTypeOrBuilder> cDubboPBRequestTypeBuilder_; + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public boolean hasCDubboPBRequestType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public GooglePB.PBRequestType getCDubboPBRequestType() { + if (cDubboPBRequestTypeBuilder_ == null) { + return cDubboPBRequestType_ == null ? GooglePB.PBRequestType.getDefaultInstance() : cDubboPBRequestType_; + } else { + return cDubboPBRequestTypeBuilder_.getMessage(); + } + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public Builder setCDubboPBRequestType(GooglePB.PBRequestType value) { + if (cDubboPBRequestTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + cDubboPBRequestType_ = value; + onChanged(); + } else { + cDubboPBRequestTypeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public Builder setCDubboPBRequestType( + GooglePB.PBRequestType.Builder builderForValue) { + if (cDubboPBRequestTypeBuilder_ == null) { + cDubboPBRequestType_ = builderForValue.build(); + onChanged(); + } else { + cDubboPBRequestTypeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public Builder mergeCDubboPBRequestType(GooglePB.PBRequestType value) { + if (cDubboPBRequestTypeBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002) && + cDubboPBRequestType_ != null && + cDubboPBRequestType_ != GooglePB.PBRequestType.getDefaultInstance()) { + cDubboPBRequestType_ = + GooglePB.PBRequestType.newBuilder(cDubboPBRequestType_).mergeFrom(value).buildPartial(); + } else { + cDubboPBRequestType_ = value; + } + onChanged(); + } else { + cDubboPBRequestTypeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public Builder clearCDubboPBRequestType() { + if (cDubboPBRequestTypeBuilder_ == null) { + cDubboPBRequestType_ = null; + onChanged(); + } else { + cDubboPBRequestTypeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public GooglePB.PBRequestType.Builder getCDubboPBRequestTypeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getCDubboPBRequestTypeFieldBuilder().getBuilder(); + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + public GooglePB.PBRequestTypeOrBuilder getCDubboPBRequestTypeOrBuilder() { + if (cDubboPBRequestTypeBuilder_ != null) { + return cDubboPBRequestTypeBuilder_.getMessageOrBuilder(); + } else { + return cDubboPBRequestType_ == null ? + GooglePB.PBRequestType.getDefaultInstance() : cDubboPBRequestType_; + } + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + PBRequestType, PBRequestType.Builder, PBRequestTypeOrBuilder> + getCDubboPBRequestTypeFieldBuilder() { + if (cDubboPBRequestTypeBuilder_ == null) { + cDubboPBRequestTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + PBRequestType, PBRequestType.Builder, PBRequestTypeOrBuilder>( + getCDubboPBRequestType(), + getParentForChildren(), + isClean()); + cDubboPBRequestType_ = null; + } + return cDubboPBRequestTypeBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) + } + + // @@protoc_insertion_point(class_scope:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) + private static final GooglePB.PBResponseType DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new GooglePB.PBResponseType(); + } + + public static GooglePB.PBResponseType getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @Deprecated public static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PBResponseType parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PBResponseType(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public GooglePB.PBResponseType getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface PhoneNumberOrBuilder extends + // @@protoc_insertion_point(interface_extends:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) + com.google.protobuf.MessageOrBuilder { + + /** + * required string number = 1; + */ + boolean hasNumber(); + /** + * required string number = 1; + */ + String getNumber(); + /** + * required string number = 1; + */ + com.google.protobuf.ByteString + getNumberBytes(); + + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; + */ + boolean hasType(); + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; + */ + GooglePB.PhoneType getType(); + } + /** + * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber} + */ + public static final class PhoneNumber extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:org.apache.dubbo.common.serialize.protobuf.model.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; + } + + @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(); + 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; + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000001; + number_ = bs; + break; + } + case 16: { + int rawValue = input.readEnum(); + GooglePB.PhoneType value = GooglePB.PhoneType.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(2, rawValue); + } else { + bitField0_ |= 0x00000002; + type_ = rawValue; + } + 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 GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_fieldAccessorTable + .ensureFieldAccessorsInitialized( + GooglePB.PhoneNumber.class, GooglePB.PhoneNumber.Builder.class); + } + + private int bitField0_; + public static final int NUMBER_FIELD_NUMBER = 1; + private volatile Object number_; + /** + * required string number = 1; + */ + public boolean hasNumber() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string number = 1; + */ + public String getNumber() { + Object ref = number_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + number_ = s; + } + return s; + } + } + /** + * required string number = 1; + */ + public com.google.protobuf.ByteString + getNumberBytes() { + Object ref = number_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (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 .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; + */ + public GooglePB.PhoneType getType() { + GooglePB.PhoneType result = GooglePB.PhoneType.valueOf(type_); + return result == null ? GooglePB.PhoneType.HOME : result; + } + + private byte memoizedIsInitialized = -1; + 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; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, number_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeEnum(2, type_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, number_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, type_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GooglePB.PhoneNumber)) { + return super.equals(obj); + } + GooglePB.PhoneNumber other = (GooglePB.PhoneNumber) obj; + + boolean result = true; + result = result && (hasNumber() == other.hasNumber()); + if (hasNumber()) { + result = result && getNumber() + .equals(other.getNumber()); + } + result = result && (hasType() == other.hasType()); + if (hasType()) { + result = result && type_ == other.type_; + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @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 GooglePB.PhoneNumber parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PhoneNumber parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PhoneNumber parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PhoneNumber parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PhoneNumber parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GooglePB.PhoneNumber parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GooglePB.PhoneNumber parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static GooglePB.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 GooglePB.PhoneNumber parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static GooglePB.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 GooglePB.PhoneNumber parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static GooglePB.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); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(GooglePB.PhoneNumber prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) + GooglePB.PhoneNumberOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_fieldAccessorTable + .ensureFieldAccessorsInitialized( + GooglePB.PhoneNumber.class, GooglePB.PhoneNumber.Builder.class); + } + + // Construct using org.apache.dubbo.common.serialize.protobuf.model.GooglePB.PhoneNumber.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + number_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + type_ = 1; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor; + } + + public GooglePB.PhoneNumber getDefaultInstanceForType() { + return GooglePB.PhoneNumber.getDefaultInstance(); + } + + public GooglePB.PhoneNumber build() { + GooglePB.PhoneNumber result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public GooglePB.PhoneNumber buildPartial() { + GooglePB.PhoneNumber result = new GooglePB.PhoneNumber(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.number_ = number_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.type_ = type_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof GooglePB.PhoneNumber) { + return mergeFrom((GooglePB.PhoneNumber)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(GooglePB.PhoneNumber other) { + if (other == GooglePB.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; + } + + public final boolean isInitialized() { + if (!hasNumber()) { + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + GooglePB.PhoneNumber parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (GooglePB.PhoneNumber) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private Object number_ = ""; + /** + * required string number = 1; + */ + public boolean hasNumber() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string number = 1; + */ + public String getNumber() { + Object ref = number_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + number_ = s; + } + return s; + } else { + return (String) ref; + } + } + /** + * required string number = 1; + */ + public com.google.protobuf.ByteString + getNumberBytes() { + Object ref = number_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + number_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string number = 1; + */ + public Builder setNumber( + 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 .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; + */ + public GooglePB.PhoneType getType() { + GooglePB.PhoneType result = GooglePB.PhoneType.valueOf(type_); + return result == null ? GooglePB.PhoneType.HOME : result; + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; + */ + public Builder setType(GooglePB.PhoneType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + * optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; + */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000002); + type_ = 1; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) + } + + // @@protoc_insertion_point(class_scope:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) + private static final GooglePB.PhoneNumber DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new GooglePB.PhoneNumber(); + } + + public static GooglePB.PhoneNumber getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @Deprecated public static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + 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; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public GooglePB.PhoneNumber getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + String[] descriptorData = { + "\n\016GooglePB.proto\0220org.apache.dubbo.commo" + + "n.serialize.protobuf.model\"\220\003\n\rPBRequest" + + "Type\022\r\n\005money\030\001 \001(\001\022\014\n\004cash\030\002 \001(\002\022\013\n\003age" + + "\030\003 \001(\005\022\013\n\003num\030\004 \001(\003\022\013\n\003sex\030\005 \001(\010\022\014\n\004name" + + "\030\006 \001(\t\022\013\n\003msg\030\007 \001(\014\022L\n\005phone\030\010 \003(\0132=.org" + + ".apache.dubbo.common.serialize.protobuf." + + "model.PhoneNumber\022a\n\tdoubleMap\030\t \003(\0132N.o" + + "rg.apache.dubbo.common.serialize.protobu" + + "f.model.PBRequestType.DoubleMapEntry\032o\n\016" + + "DoubleMapEntry\022\013\n\003key\030\001 \001(\t\022L\n\005value\030\002 \001", + "(\0132=.org.apache.dubbo.common.serialize.p" + + "rotobuf.model.PhoneNumber:\0028\001\"{\n\016PBRespo" + + "nseType\022\013\n\003msg\030\001 \001(\t\022\\\n\023CDubboPBRequestT" + + "ype\030\003 \001(\0132?.org.apache.dubbo.common.seri" + + "alize.protobuf.model.PBRequestType\"n\n\013Ph" + + "oneNumber\022\016\n\006number\030\001 \002(\t\022O\n\004type\030\002 \001(\0162" + + ";.org.apache.dubbo.common.serialize.prot" + + "obuf.model.PhoneType:\004HOME*+\n\tPhoneType\022" + + "\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001\022\010\n\004WORK\020\0022\241\001\n\017CDub" + + "boPBService\022\215\001\n\010sayHello\022?.org.apache.du", + "bbo.common.serialize.protobuf.model.PBRe" + + "questType\032@.org.apache.dubbo.common.seri" + + "alize.protobuf.model.PBResponseType" + }; + 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_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor, + new String[] { "Money", "Cash", "Age", "Num", "Sex", "Name", "Msg", "Phone", "DoubleMap", }); + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_descriptor = + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor.getNestedTypes().get(0); + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_descriptor, + new String[] { "Key", "Value", }); + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor, + new String[] { "Msg", "CDubboPBRequestType", }); + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor, + new String[] { "Number", "Type", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/resources/protobuf/GooglePB.proto b/dubbo-serialization/dubbo-serialization-test/src/test/resources/protobuf/GooglePB.proto new file mode 100644 index 0000000000..bda3e37b5a --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-test/src/test/resources/protobuf/GooglePB.proto @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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. + */ +syntax = "proto2"; + +package org.apache.dubbo.common.serialize.protobuf.model; + +message PBRequestType { + optional double money = 1; + optional float cash = 2; + optional int32 age = 3; + optional int64 num = 4; + optional bool sex = 5; + optional string name = 6; + optional bytes msg = 7; + repeated org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8; + map doubleMap = 9; +} + +message PBResponseType { + optional string msg = 1; + optional org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3; +} + +message PhoneNumber { + required string number = 1; + optional org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME]; +} + +enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; +} + +service CDubboPBService { + rpc sayHello (org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) returns (org.apache.dubbo.common.serialize.protobuf.model.PBResponseType); +} \ No newline at end of file diff --git a/dubbo-serialization/pom.xml b/dubbo-serialization/pom.xml index b6b4b5c5ce..448aa07862 100644 --- a/dubbo-serialization/pom.xml +++ b/dubbo-serialization/pom.xml @@ -39,6 +39,7 @@ dubbo-serialization-avro dubbo-serialization-test dubbo-serialization-gson + dubbo-serialization-protobuf-json dubbo-serialization-native-hession