├── CODEOWNERS ├── .gitignore ├── src ├── test │ └── java │ │ └── com │ │ └── blueapron │ │ └── connect │ │ └── protobuf │ │ ├── protos │ │ ├── BytesValue.proto │ │ ├── SInt32Value.proto │ │ ├── SInt64Value.proto │ │ ├── UInt32Value.proto │ │ ├── UInt64Value.proto │ │ ├── DateValue.proto │ │ ├── ComplexMapMessage.proto │ │ ├── TimestampValue.proto │ │ ├── OneOfStructs.proto │ │ ├── TestProto.proto │ │ ├── LegacyName.proto │ │ ├── NestedTestProto.proto │ │ └── google │ │ │ └── type │ │ │ └── date.proto │ │ ├── LegacyName.java │ │ ├── ProtobufConverterTest.java │ │ ├── UInt32ValueOuterClass.java │ │ ├── SInt32ValueOuterClass.java │ │ ├── SInt64ValueOuterClass.java │ │ ├── UInt64ValueOuterClass.java │ │ ├── BytesValueOuterClass.java │ │ └── DateValueOuterClass.java └── main │ └── java │ └── com │ └── blueapron │ └── connect │ └── protobuf │ ├── ProtobufUtils.java │ ├── ProtobufConverter.java │ └── ProtobufData.java ├── .editorconfig ├── .github └── workflows │ └── maven.yml ├── settings.xml ├── config └── log4j.properties ├── README.md ├── pom.xml └── LICENSE /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Require OSS Approvers to approve all changes. 2 | * @blueapron/oss-approvers 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE Specific ignores 2 | .idea 3 | *.iml 4 | 5 | target 6 | 7 | # Maven Release Files 8 | pom.xml.releaseBackup 9 | release.properties 10 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/BytesValue.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.blueapron.connect.protobuf"; 4 | 5 | message BytesValue { 6 | bytes value = 1; 7 | } 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | # Unix-style newlines with a newline ending every file 4 | [*] 5 | end_of_line = lf 6 | insert_final_newline = true 7 | 8 | [*.java] 9 | indent_style = space 10 | indent_size = 2 11 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/SInt32Value.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.blueapron.connect.protobuf"; 4 | 5 | // Wrapper message for `sint32`. 6 | message SInt32Value { 7 | sint32 value = 1; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/SInt64Value.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.blueapron.connect.protobuf"; 4 | 5 | // Wrapper message for `sint64`. 6 | message SInt64Value { 7 | sint64 value = 1; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/UInt32Value.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.blueapron.connect.protobuf"; 4 | 5 | // Wrapper message for `uint32`. 6 | message UInt32Value { 7 | uint32 value = 1; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/UInt64Value.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.blueapron.connect.protobuf"; 4 | 5 | // Wrapper message for `uint64`. 6 | message UInt64Value { 7 | uint64 value = 1; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/DateValue.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/type/date.proto"; 4 | 5 | option java_package = "com.blueapron.connect.protobuf"; 6 | 7 | // Wrapper message for `Date`. 8 | message DateValue { 9 | // The bytes value. 10 | google.type.Date value = 1; 11 | } 12 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/ComplexMapMessage.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "NestedTestProto.proto"; 4 | package blueapron.connect.protobuf; 5 | option java_package = "com.blueapron.connect.protobuf"; 6 | 7 | message ComplexMapType { 8 | UserId user_id = 1; 9 | map user_messages = 2; 10 | } 11 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/TimestampValue.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/timestamp.proto"; 4 | 5 | option java_package = "com.blueapron.connect.protobuf"; 6 | 7 | // Wrapper message for `Timestamp`. 8 | message TimestampValue { 9 | // The bytes value. 10 | google.protobuf.Timestamp value = 1; 11 | } 12 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | name: Unit Test CI 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v1 14 | - name: Set up JDK 1.8 15 | uses: actions/setup-java@v1 16 | with: 17 | java-version: 1.8 18 | - name: Maven Test 19 | run: mvn test 20 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/OneOfStructs.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.blueapron.connect.protobuf"; 4 | 5 | message First { 6 | string value = 1; 7 | } 8 | 9 | message Second { 10 | string value = 2; 11 | } 12 | 13 | message OneOfContainer { 14 | oneof possibilities { 15 | First first = 1; 16 | Second second = 2; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/TestProto.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.blueapron.connect.protobuf"; 4 | option java_outer_classname = "TestMessageProtos"; 5 | 6 | import "google/protobuf/descriptor.proto"; 7 | import "LegacyName.proto"; 8 | 9 | message TestMessage { 10 | string test_string = 1; 11 | string some_field = 2 [(blueapron.connect.protobuf.legacy_name) = "legacy_field_name"]; 12 | } 13 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/LegacyName.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/descriptor.proto"; 4 | 5 | package blueapron.connect.protobuf; 6 | 7 | option java_package = "com.blueapron.connect.protobuf"; 8 | 9 | /* This custom field option should be used to specify the initial name of a 10 | * protocol buffer field when deprecating or renaming a field. 11 | */ 12 | extend google.protobuf.FieldOptions { 13 | string legacy_name = 60000; 14 | } 15 | -------------------------------------------------------------------------------- /settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ossrh 5 | 6 | true 7 | 8 | 9 | ${env.GPG_PASSPHRASE} 10 | 11 | 12 | 13 | 14 | 15 | ossrh 16 | ${env.OSSRH_JIRA_USERNAME} 17 | ${env.OSSRH_JIRA_PASSWORD} 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /config/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, stdout, file 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n 6 | 7 | log4j.logger.kafka=ERROR, stdout 8 | log4j.logger.org.apache.zookeeper=ERROR, stdout 9 | log4j.logger.org.apache.kafka=ERROR, stdout 10 | log4j.logger.org.I0Itec.zkclient=ERROR, stdout 11 | log4j.additivity.kafka.server=false 12 | log4j.additivity.kafka.consumer.ZookeeperConsumerConnector=false 13 | 14 | log4j.appender.file=org.apache.log4j.DailyRollingFileAppender 15 | log4j.appender.file.DatePattern='.'yyyy-MM-dd-HH 16 | log4j.appender.file.File=${kafka.logs.dir}/kafka-connect-protobuf-converter.log 17 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 18 | log4j.appender.file.layout.ConversionPattern=[%d] %p %m (%c)%n 19 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/NestedTestProto.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/timestamp.proto"; 4 | 5 | package blueapron.connect.protobuf; 6 | 7 | option java_package = "com.blueapron.connect.protobuf"; 8 | 9 | message UserId { 10 | oneof user_id { 11 | string ba_com_user_id = 1; 12 | int32 other_user_id = 2; 13 | MessageId another_id = 3; 14 | } 15 | } 16 | 17 | message MessageId { 18 | string id = 1; 19 | } 20 | 21 | enum Status { 22 | ACTIVE = 0; 23 | INACTIVE = 1; 24 | } 25 | 26 | message ComplexType { 27 | oneof some_val { 28 | string one_id = 1; 29 | int32 other_id = 2; 30 | } 31 | bool is_active = 3; 32 | } 33 | 34 | /* 35 | * Complex message using nested protos and repeated fields 36 | */ 37 | message NestedTestProto { 38 | UserId user_id = 1; 39 | bool is_active = 2; 40 | repeated string experiments_active = 3; 41 | google.protobuf.Timestamp updated_at = 4; 42 | Status status = 5; 43 | ComplexType complex_type = 6; 44 | map map_type = 7; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/blueapron/connect/protobuf/ProtobufUtils.java: -------------------------------------------------------------------------------- 1 | package com.blueapron.connect.protobuf; 2 | 3 | import java.util.Calendar; 4 | import java.util.TimeZone; 5 | 6 | public class ProtobufUtils { 7 | static java.util.Date convertFromGoogleDate(com.google.type.Date date) { 8 | Calendar cal = Calendar.getInstance(); 9 | cal.setLenient(false); 10 | cal.set(Calendar.YEAR, date.getYear()); 11 | // Months start at 0, not 1 12 | cal.set(Calendar.MONTH, date.getMonth() - 1); 13 | cal.set(Calendar.DAY_OF_MONTH, date.getDay()); 14 | cal.set(Calendar.HOUR_OF_DAY, 0); 15 | cal.set(Calendar.MINUTE, 0); 16 | cal.set(Calendar.SECOND, 0); 17 | cal.set(Calendar.MILLISECOND, 0); 18 | return cal.getTime(); 19 | } 20 | 21 | static com.google.type.Date convertToGoogleDate(java.util.Date date) { 22 | TimeZone timeZone = TimeZone.getTimeZone("UTC"); 23 | Calendar cal = Calendar.getInstance(timeZone); 24 | cal.setTime(date); 25 | com.google.type.Date.Builder dateBuilder = com.google.type.Date.newBuilder(); 26 | dateBuilder.setDay(cal.get(Calendar.DAY_OF_MONTH)); 27 | // Months start at 0, not 1 28 | dateBuilder.setMonth(cal.get(Calendar.MONTH) + 1); 29 | dateBuilder.setYear(cal.get(Calendar.YEAR)); 30 | return dateBuilder.build(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/protos/google/type/date.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.type; 18 | 19 | option cc_enable_arenas = true; 20 | option go_package = "google.golang.org/genproto/googleapis/type/date;date"; 21 | option java_multiple_files = true; 22 | option java_outer_classname = "DateProto"; 23 | option java_package = "com.google.type"; 24 | option objc_class_prefix = "GTP"; 25 | 26 | 27 | // Represents a whole calendar date, e.g. date of birth. The time of day and 28 | // time zone are either specified elsewhere or are not significant. The date 29 | // is relative to the Proleptic Gregorian Calendar. The day may be 0 to 30 | // represent a year and month where the day is not significant, e.g. credit card 31 | // expiration date. The year may be 0 to represent a month and day independent 32 | // of year, e.g. anniversary date. Related types are [google.type.TimeOfDay][google.type.TimeOfDay] 33 | // and `google.protobuf.Timestamp`. 34 | message Date { 35 | // Year of date. Must be from 1 to 9999, or 0 if specifying a date without 36 | // a year. 37 | int32 year = 1; 38 | 39 | // Month of year. Must be from 1 to 12. 40 | int32 month = 2; 41 | 42 | // Day of month. Must be from 1 to 31 and valid for the year and month, or 0 43 | // if specifying a year/month where the day is not significant. 44 | int32 day = 3; 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/LegacyName.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: LegacyName.proto 3 | 4 | package com.blueapron.connect.protobuf; 5 | 6 | public final class LegacyName { 7 | private LegacyName() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | registry.add(com.blueapron.connect.protobuf.LegacyName.legacyName); 11 | } 12 | 13 | public static void registerAllExtensions( 14 | com.google.protobuf.ExtensionRegistry registry) { 15 | registerAllExtensions( 16 | (com.google.protobuf.ExtensionRegistryLite) registry); 17 | } 18 | public static final int LEGACY_NAME_FIELD_NUMBER = 60000; 19 | /** 20 | * extend .google.protobuf.FieldOptions { ... } 21 | */ 22 | public static final 23 | com.google.protobuf.GeneratedMessage.GeneratedExtension< 24 | com.google.protobuf.DescriptorProtos.FieldOptions, 25 | java.lang.String> legacyName = com.google.protobuf.GeneratedMessage 26 | .newFileScopedGeneratedExtension( 27 | java.lang.String.class, 28 | null); 29 | 30 | public static com.google.protobuf.Descriptors.FileDescriptor 31 | getDescriptor() { 32 | return descriptor; 33 | } 34 | private static com.google.protobuf.Descriptors.FileDescriptor 35 | descriptor; 36 | static { 37 | java.lang.String[] descriptorData = { 38 | "\n\020LegacyName.proto\022\032blueapron.connect.pr" + 39 | "otobuf\032 google/protobuf/descriptor.proto" + 40 | ":4\n\013legacy_name\022\035.google.protobuf.FieldO" + 41 | "ptions\030\340\324\003 \001(\tB \n\036com.blueapron.connect." + 42 | "protobufb\006proto3" 43 | }; 44 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 45 | .internalBuildGeneratedFileFrom(descriptorData, 46 | new com.google.protobuf.Descriptors.FileDescriptor[] { 47 | com.google.protobuf.DescriptorProtos.getDescriptor(), 48 | }); 49 | legacyName.internalInit(descriptor.getExtensions().get(0)); 50 | com.google.protobuf.DescriptorProtos.getDescriptor(); 51 | } 52 | 53 | // @@protoc_insertion_point(outer_class_scope) 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/blueapron/connect/protobuf/ProtobufConverter.java: -------------------------------------------------------------------------------- 1 | package com.blueapron.connect.protobuf; 2 | 3 | import org.apache.kafka.connect.data.Schema; 4 | import org.apache.kafka.connect.data.SchemaAndValue; 5 | import org.apache.kafka.connect.errors.ConnectException; 6 | import org.apache.kafka.connect.storage.Converter; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import java.util.Map; 11 | 12 | 13 | /** 14 | * Implementation of Converter that uses Protobufs. 15 | */ 16 | public class ProtobufConverter implements Converter { 17 | private static final Logger log = LoggerFactory.getLogger(ProtobufConverter.class); 18 | private static final String PROTO_CLASS_NAME_CONFIG = "protoClassName"; 19 | private static final String LEGACY_NAME_CONFIG = "legacyName"; 20 | private static final String PROTO_MAP_CONVERSION_TYPE = "protoMapConversionType"; 21 | private ProtobufData protobufData; 22 | 23 | private boolean isInvalidConfiguration(Object proto, boolean isKey) { 24 | return proto == null && !isKey; 25 | } 26 | 27 | @Override 28 | public void configure(Map configs, boolean isKey) { 29 | Object legacyName = configs.get(LEGACY_NAME_CONFIG); 30 | String legacyNameString = legacyName == null ? "legacy_name" : legacyName.toString(); 31 | boolean useConnectSchemaMap = "map".equals(configs.get(PROTO_MAP_CONVERSION_TYPE)); 32 | 33 | Object protoClassName = configs.get(PROTO_CLASS_NAME_CONFIG); 34 | if (isInvalidConfiguration(protoClassName, isKey)) { 35 | throw new ConnectException("Value converter must have a " + PROTO_CLASS_NAME_CONFIG + " configured"); 36 | } 37 | 38 | if (protoClassName == null) { 39 | protobufData = null; 40 | return; 41 | } 42 | 43 | String protoClassNameString = protoClassName.toString(); 44 | try { 45 | log.info("Initializing ProtobufData with args: [protoClassName={}, legacyName={}, useConnectSchemaMap={}]", protoClassNameString, legacyNameString, useConnectSchemaMap); 46 | protobufData = new ProtobufData(Class.forName(protoClassNameString).asSubclass(com.google.protobuf.GeneratedMessageV3.class), legacyNameString, useConnectSchemaMap); 47 | } catch (ClassNotFoundException e) { 48 | throw new ConnectException("Proto class " + protoClassNameString + " not found in the classpath"); 49 | } catch (ClassCastException e) { 50 | throw new ConnectException("Proto class " + protoClassNameString + " is not a valid proto3 message class"); 51 | } 52 | } 53 | 54 | @Override 55 | public byte[] fromConnectData(String topic, Schema schema, Object value) { 56 | if (protobufData == null || schema == null || value == null) { 57 | return null; 58 | } 59 | 60 | return protobufData.fromConnectData(value); 61 | } 62 | 63 | @Override 64 | public SchemaAndValue toConnectData(String topic, byte[] value) { 65 | if (protobufData == null || value == null) { 66 | return SchemaAndValue.NULL; 67 | } 68 | 69 | return protobufData.toConnectData(value); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/ProtobufConverterTest.java: -------------------------------------------------------------------------------- 1 | package com.blueapron.connect.protobuf; 2 | 3 | import com.blueapron.connect.protobuf.OneOfStructs.OneOfContainer; 4 | import org.apache.kafka.connect.data.Schema; 5 | import org.apache.kafka.connect.data.SchemaAndValue; 6 | import org.apache.kafka.connect.data.SchemaBuilder; 7 | import org.apache.kafka.connect.data.Struct; 8 | import org.apache.kafka.connect.errors.ConnectException; 9 | import org.junit.Test; 10 | 11 | import static org.junit.Assert.assertArrayEquals; 12 | import static org.junit.Assert.assertEquals; 13 | 14 | import com.blueapron.connect.protobuf.TestMessageProtos.TestMessage; 15 | 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | 19 | public class ProtobufConverterTest { 20 | private final String LEGACY_FIELD_NAME = "legacy_field_name"; 21 | private final String CUSTOM_LEGACY_NAME = "blueapron.connect.protobuf.legacy_name"; 22 | private final String TEST_MESSAGE_CLASS_NAME = "com.blueapron.connect.protobuf.TestMessageProtos$TestMessage"; 23 | private static final String TEST_MSG_STRING = "Hello World"; 24 | private static final String LEGACY_MSG_STRING = "Some renamed field"; 25 | private static final TestMessage HELLO_WORLD_MESSAGE = TestMessage.newBuilder().setTestString(TEST_MSG_STRING).setSomeField(LEGACY_MSG_STRING).build(); 26 | 27 | private Schema getTestMessageSchema(String legacyFieldName) { 28 | final SchemaBuilder builder = SchemaBuilder.struct().name("TestMessage"); 29 | final SchemaBuilder fieldBuilder = SchemaBuilder.string(); 30 | fieldBuilder.optional(); 31 | builder.field("test_string", fieldBuilder.build()); 32 | builder.field(legacyFieldName, fieldBuilder.build()); 33 | return builder.build(); 34 | } 35 | 36 | private Schema getTestMessageSchema() { 37 | return getTestMessageSchema(LEGACY_FIELD_NAME); 38 | } 39 | 40 | private Struct getTestMessageResult(String messageText, String legacyFieldText, String legacyFieldName) { 41 | Schema schema = getTestMessageSchema(legacyFieldName); 42 | Struct result = new Struct(schema.schema()); 43 | result.put("test_string", messageText); 44 | result.put(legacyFieldName, legacyFieldText); 45 | return result; 46 | } 47 | private Struct getTestMessageResult(String messageText, String legacyFieldText) { 48 | return getTestMessageResult(messageText, legacyFieldText, LEGACY_FIELD_NAME); 49 | } 50 | 51 | private ProtobufConverter getConfiguredProtobufConverter(String protobufClassName, boolean isKey, String legacy_name) { 52 | ProtobufConverter protobufConverter = new ProtobufConverter(); 53 | 54 | Map configs = new HashMap(); 55 | configs.put("protoClassName", protobufClassName); 56 | configs.put("legacyName", legacy_name); 57 | 58 | protobufConverter.configure(configs, isKey); 59 | 60 | return protobufConverter; 61 | } 62 | 63 | private ProtobufConverter getConfiguredProtobufConverter(String protobufClassName, boolean isKey) { 64 | return getConfiguredProtobufConverter(protobufClassName, isKey, CUSTOM_LEGACY_NAME); 65 | } 66 | 67 | @Test(expected = ConnectException.class) 68 | public void testNullValueConverter() { 69 | // When the value converter is null, we need to throw an exception and stop processing 70 | getConfiguredProtobufConverter(null, false); 71 | } 72 | 73 | @Test(expected = ConnectException.class) 74 | public void testInvalidClassKeyConverter() { 75 | getConfiguredProtobufConverter("com.does.not.exist", true); 76 | } 77 | 78 | @Test(expected = ConnectException.class) 79 | public void testInvalidClassValueConverter() { 80 | getConfiguredProtobufConverter("com.does.not.exist", false); 81 | } 82 | 83 | @Test(expected = ConnectException.class) 84 | public void testNonProtoClassValueConverter() { 85 | getConfiguredProtobufConverter("java.lang.String", true); 86 | } 87 | 88 | @Test 89 | public void testFromConnectDataForKey() { 90 | final byte[] expected = HELLO_WORLD_MESSAGE.toByteArray(); 91 | 92 | ProtobufConverter testMessageConverter = getConfiguredProtobufConverter(TEST_MESSAGE_CLASS_NAME, true); 93 | byte[] result = testMessageConverter.fromConnectData("my-topic", 94 | getTestMessageSchema(), 95 | getTestMessageResult(TEST_MSG_STRING, LEGACY_MSG_STRING)); 96 | 97 | assertArrayEquals(expected, result); 98 | } 99 | 100 | @Test 101 | public void testFromConnectDataWhenKeyIsNull() { 102 | // When the key is null, the message content will be empty 103 | ProtobufConverter testMessageConverter = getConfiguredProtobufConverter(null, true); 104 | byte[] result = testMessageConverter.fromConnectData("my-topic", 105 | getTestMessageSchema(), 106 | getTestMessageResult(TEST_MSG_STRING, LEGACY_MSG_STRING)); 107 | 108 | assertArrayEquals(null, result); 109 | } 110 | 111 | @Test 112 | public void testFromConnectDataForValue() { 113 | final byte[] expected = HELLO_WORLD_MESSAGE.toByteArray(); 114 | 115 | ProtobufConverter testMessageConverter = getConfiguredProtobufConverter(TEST_MESSAGE_CLASS_NAME, false); 116 | byte[] result = testMessageConverter.fromConnectData("my-topic", 117 | getTestMessageSchema(), 118 | getTestMessageResult(TEST_MSG_STRING, LEGACY_MSG_STRING)); 119 | 120 | assertArrayEquals(expected, result); 121 | } 122 | 123 | @Test 124 | public void testToConnectDataForKey() { 125 | ProtobufConverter testMessageConverter = getConfiguredProtobufConverter(TEST_MESSAGE_CLASS_NAME, true); 126 | SchemaAndValue result = testMessageConverter.toConnectData("my-topic", HELLO_WORLD_MESSAGE.toByteArray()); 127 | 128 | SchemaAndValue expected = new SchemaAndValue(getTestMessageSchema(), getTestMessageResult(TEST_MSG_STRING, LEGACY_MSG_STRING)); 129 | 130 | assertEquals(expected, result); 131 | } 132 | 133 | @Test 134 | public void testToConnectDataWhenKeyIsNull() { 135 | ProtobufConverter testMessageConverter = getConfiguredProtobufConverter(null, true); 136 | SchemaAndValue result = testMessageConverter.toConnectData("my-topic", HELLO_WORLD_MESSAGE.toByteArray()); 137 | 138 | assertEquals(SchemaAndValue.NULL, result); 139 | } 140 | 141 | @Test 142 | public void testToConnectDataForValue() { 143 | ProtobufConverter testMessageConverter = getConfiguredProtobufConverter(TEST_MESSAGE_CLASS_NAME, false); 144 | SchemaAndValue result = testMessageConverter.toConnectData("my-topic", HELLO_WORLD_MESSAGE.toByteArray()); 145 | 146 | SchemaAndValue expected = new SchemaAndValue(getTestMessageSchema(), getTestMessageResult(TEST_MSG_STRING, LEGACY_MSG_STRING)); 147 | 148 | assertEquals(expected, result); 149 | } 150 | 151 | @Test 152 | public void testToConnectDataForValueWithMismatchedDefaultLegacyName() { 153 | ProtobufConverter testMessageConverter = getConfiguredProtobufConverter(TEST_MESSAGE_CLASS_NAME, false, "legacy_name"); 154 | SchemaAndValue result = testMessageConverter.toConnectData("my-topic", HELLO_WORLD_MESSAGE.toByteArray()); 155 | 156 | String unrenamedLegacyFieldName = "some_field"; 157 | 158 | SchemaAndValue expected = new SchemaAndValue( 159 | getTestMessageSchema(unrenamedLegacyFieldName), 160 | getTestMessageResult(TEST_MSG_STRING, LEGACY_MSG_STRING, unrenamedLegacyFieldName) 161 | ); 162 | 163 | assertEquals(expected, result); 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecated: Please Use https://www.confluent.io/hub/confluentinc/kafka-connect-protobuf-converter 2 | 3 | # kafka-connect-protobuf-converter 4 | Converter plugin for [Kafka Connect](https://docs.confluent.io/current/connect/). A converter 5 | controls the format of the data that will be written to Kafka for source connectors or 6 | read from Kafka for sink connectors. 7 | 8 | ## Compatibility 9 | 10 | The 2.x release series is compatible with Kafka Connect 5.x. and up (older releases have been validated to work all the way back to Kafka Connect 3.2.0, although we highly recommend updating to the latest version). 11 | 12 | *N.B. This converter only works with `proto3` protocol buffer schemas.* 13 | 14 | ## Usage 15 | 16 | Copy the `kafka-connect-protobuf-converter` jar and the jar containing your compiled protocol buffers to 17 | `/usr/share/java/kafka-serde-tools` on your Kafka Connect instance and restart Kafka Connect. 18 | 19 | Converters can be specified on a per-connector basis. 20 | 21 | To use the protobuf converter in Kafka Connect, specify the converter as your key and value converter and specify the 22 | protocol buffer class you want to use to deserialize the message (ex: `com.google.protobuf.Int32Value`). 23 | 24 | Note: Nested classes must be specified using the `$` notation, for example 25 | `com.blueapron.connect.protobuf.NestedTestProtoOuterClass$NestedTestProto` 26 | 27 | Example Kafka Connect JDBC source: 28 | ``` 29 | connector.class=io.confluent.connect.jdbc.JdbcSourceConnector 30 | mode=bulk 31 | topic.prefix=blueapron-protos-int 32 | tasks.max=1 33 | query=select * from int32value 34 | name=blueapron-protos-source-int 35 | connection.url=jdbc:postgresql://192.168.99.100:5432/test?user=postgres&password=mysecretpassword 36 | value.converter=com.blueapron.connect.protobuf.ProtobufConverter 37 | value.converter.protoClassName=com.google.protobuf.Int32Value 38 | key.converter=com.blueapron.connect.protobuf.ProtobufConverter 39 | ``` 40 | 41 | Example Kafka Connect JDBC sink: 42 | ``` 43 | connector.class=io.confluent.connect.jdbc.JdbcSinkConnector 44 | topics=blueapron-protos-int 45 | topics.to.tables=blueapron-protos-int=int32output 46 | auto.create=true 47 | tasks.max=1 48 | name=blueapron-protos-sink-int 49 | connection.url=jdbc:postgresql://192.168.99.100:5432/test?user=postgres&password=mysecretpassword 50 | value.converter=com.blueapron.connect.protobuf.ProtobufConverter 51 | value.converter.protoClassName=com.google.protobuf.Int32Value 52 | key.converter=com.blueapron.connect.protobuf.ProtobufConverter 53 | ``` 54 | 55 | ## Supported Conversions 56 | 57 | [List of proto3 types](https://developers.google.com/protocol-buffers/docs/proto3) 58 | 59 | ### From Connect 60 | 61 | |Connect Schema Type|Protobuf Type| 62 | | ----------------- | ----------- | 63 | |INT32 |int32 | 64 | |INT64 |int64 | 65 | |FLOAT32 |float | 66 | |FLOAT64 |double | 67 | |BOOLEAN |bool | 68 | |STRING |string | 69 | |BYTES |bytes | 70 | 71 | 72 | |Connect Logical Type|Protobuf Type| 73 | | ------------------ | ----------- | 74 | |Timestamp |Timestamp | 75 | |Date |Date | 76 | 77 | ### To Connect 78 | 79 | |Protobuf Type|Connect Schema Type| 80 | | ----------- | ----------------- | 81 | |int32 |INT32 | 82 | |int64 |INT64 | 83 | |sint32 |INT32 | 84 | |sint64 |INT64 | 85 | |uint32 |INT64 | 86 | |float |FLOAT32 | 87 | |double |FLOAT64 | 88 | |bool |BOOLEAN | 89 | |string |STRING | 90 | |bytes |BYTES | 91 | |repeated |ARRAY | 92 | |map |ARRAY of STRUCT* | 93 | 94 | 95 | |Protobuf Type|Connect Logical Type| 96 | | ----------- | ------------------ | 97 | |Timestamp |Timestamp | 98 | |Date |Date | 99 | |uint64 |Decimal | 100 | 101 | \* Protobuf map type fields are converted by default to an Array of Struct, 102 | but the converter supports also converting these fields into Connect Schema Map type. 103 | To enable this conversion mode, set the configuration field `protoMapConversionType` to `map`: 104 | ``` 105 | value.converter.protoMapConversionType=map 106 | ``` 107 | 108 | ## Handling field renames and deletes 109 | Renaming and removing fields is supported by the proto IDL, but certain output formats (for example, BigQuery) do not 110 | support renaming or removal. In order to support these output formats, we use a custom field option to specify the 111 | original name and keep the Kafka Connect schema consistent. 112 | 113 | You can specify the name for this field option using the `legacyName` configuration item. By default, the field option 114 | used is `legacy_name` 115 | 116 | Example: `value.converter.legacyName=blueapron.connect.protobuf.legacy_name` 117 | 118 | This annotation provides a hint that allows renamed fields to be mapped to correctly to their output schema names. 119 | 120 | ``` 121 | // Before rename: 122 | message TestMessage { 123 | string test_string = 1; 124 | } 125 | 126 | // After first rename: 127 | import "path/to/LegacyName.proto"; 128 | 129 | message TestMessage { 130 | string renamed_string = 1 [(blueapron.connect.protobuf.legacy_name) = "test_string"]; 131 | } 132 | 133 | // After subsequent rename: 134 | import "path/to/LegacyName.proto"; 135 | 136 | message TestMessage { 137 | string yet_another_named_string = 1 [(blueapron.connect.protobuf.legacy_name) = "test_string"]; 138 | } 139 | 140 | ``` 141 | 142 | We can also use the same syntax to support removing fields. You can treat deleted fields as renamed fields, prefixing 143 | the deprecated field name with `OBSOLETE_` and including a legacy_name field option as previously detailed. 144 | 145 | ``` 146 | // Before deprecation: 147 | message TestMessage { 148 | string test_string = 1; 149 | int32 test_count = 2; 150 | } 151 | 152 | // After deprecation: 153 | import "path/to/LegacyName.proto"; 154 | 155 | message TestMessage { 156 | string OBSOLETE_test_string = 1 [(blueapron.connect.protobuf.legacy_name) = "test_string"]; 157 | int32 test_count = 2; 158 | } 159 | ``` 160 | 161 | ## Contributing 162 | 163 | Contributions are warmly welcomed. If fixing a bug, please open an issue on the project before opening a PR. This helps with documentation for other users and will make code review go quicker 🙌 164 | 165 | ## Development 166 | 167 | #### Run tests: 168 | ``` 169 | mvn test 170 | ``` 171 | 172 | #### Create the JAR: 173 | ``` 174 | mvn clean package 175 | ``` 176 | 177 | Copy the JAR with dependencies (`kafka-connect-protobuf-converter-*-jar-with-dependencies.jar`) to 178 | `/usr/share/java/kafka-serde-tools` on your local Kafka Connect instance to make the 179 | converter available in Kafka Connect. 180 | 181 | #### Deploy to Maven Central: 182 | 183 | *Note:* only internal Blue Apron employees can deploy to Maven Central 184 | 1. Update the version to include -SNAPSHOT 185 | 1. Prepare your local environment for the deploy. If you already have a custom `~/.m2/settings.xml`, you may want to back up or merge your existing file rather than overwrite it. 186 | ``` 187 | cp settings.xml ~/.m2/settings.xml 188 | export GPG_PASSPHRASE= 189 | export OSSRH_JIRA_USERNAME= 190 | export OSSRH_JIRA_PASSWORD= 191 | ``` 192 | 1. Confirm the tests run 193 | ``` 194 | mvn test 195 | mvn release:clean 196 | ``` 197 | 1. Prepare the release 198 | ``` 199 | mvn release:prepare 200 | ``` 201 | 1. Perform the release 202 | ``` 203 | mvn release:perform 204 | ``` 205 | 206 | #### Generate protos: 207 | 208 | Run the below command from the repository root. 209 | ``` 210 | protoc -I=src/test/java/com/blueapron/connect/protobuf/protos --java_out=src/test/java/ src/test/java/com/blueapron/connect/protobuf/protos/*.proto 211 | ``` 212 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.blueapron 6 | kafka-connect-protobuf-converter 7 | jar 8 | 3.1.1-SNAPSHOT 9 | 10 | com.blueapron:kafka-connect-protobuf-converter 11 | Converter plugin for Kafka Connect. A converter controls the format of the data 12 | that will be written to Kafka for source connectors or read from Kafka for sink connectors. 13 | https://github.com/blueapron/kafka-connect-protobuf-converter 14 | 15 | 16 | https://www.blueapron.com/ 17 | Blue Apron 18 | 19 | 20 | 21 | 1.8 22 | 3.11.1 23 | UTF-8 24 | 25 | 26 | 27 | github 28 | https://github.com/blueapron/kafka-connect-protobuf-converter/issues 29 | 30 | 31 | 32 | 33 | MIT License 34 | http://www.opensource.org/licenses/mit-license.php 35 | repo 36 | 37 | 38 | 39 | 40 | 41 | Data Engineering Team 42 | data-engineering@blueapron.com 43 | Blue Apron 44 | https://www.blueapron.com/ 45 | 46 | 47 | Megan Patten 48 | https://github.com/makearl 49 | 50 | 51 | 52 | 53 | scm:git:git://github.com/blueapron/kafka-connect-protobuf-converter.git 54 | scm:git:git@github.com:blueapron/kafka-connect-protobuf-converter.git 55 | https://github.com/blueapron/kafka-connect-protobuf-converter/tree/master 56 | HEAD 57 | 58 | 59 | 60 | 61 | org.apache.kafka 62 | connect-api 63 | 1.0.0 64 | 65 | 66 | com.google.protobuf 67 | protobuf-java 68 | ${protobuf.version} 69 | 70 | 71 | 72 | com.google.api.grpc 73 | googleapis-common-protos 74 | 0.0.3 75 | 76 | 77 | com.google.protobuf 78 | protobuf-java-util 79 | ${protobuf.version} 80 | 81 | 82 | junit 83 | junit 84 | 4.12 85 | test 86 | 87 | 88 | uk.co.jemos.podam 89 | podam 90 | 6.0.2.RELEASE 91 | test 92 | 93 | 94 | 95 | 96 | 97 | ossrh 98 | https://oss.sonatype.org/content/repositories/snapshots 99 | 100 | 101 | ossrh 102 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 103 | 104 | 105 | 106 | 107 | 108 | 109 | maven-deploy-plugin 110 | 3.0.0-M1 111 | 112 | 113 | default-deploy 114 | deploy 115 | 116 | deploy 117 | 118 | 119 | 120 | 121 | 122 | org.apache.maven.plugins 123 | maven-gpg-plugin 124 | 1.6 125 | 126 | 127 | sign-artifacts 128 | verify 129 | 130 | sign 131 | 132 | 133 | 134 | 135 | 136 | org.apache.maven.plugins 137 | maven-release-plugin 138 | 2.5.3 139 | 140 | true 141 | false 142 | release 143 | deploy 144 | 145 | 146 | 147 | org.sonatype.plugins 148 | nexus-staging-maven-plugin 149 | 1.6.7 150 | true 151 | 152 | ossrh 153 | https://oss.sonatype.org/ 154 | true 155 | 156 | 157 | 158 | org.apache.maven.plugins 159 | maven-source-plugin 160 | 2.2.1 161 | 162 | 163 | attach-sources 164 | 165 | jar-no-fork 166 | 167 | 168 | 169 | 170 | 171 | org.apache.maven.plugins 172 | maven-javadoc-plugin 173 | 2.9.1 174 | 175 | ${java.version} 176 | 177 | 178 | 179 | attach-javadocs 180 | 181 | jar 182 | 183 | 184 | 185 | 186 | 187 | org.apache.maven.plugins 188 | maven-compiler-plugin 189 | 3.3 190 | 191 | ${java.version} 192 | ${java.version} 193 | 194 | 195 | 196 | maven-assembly-plugin 197 | 3.1.0 198 | 199 | 200 | jar-with-dependencies 201 | 202 | 203 | 204 | 205 | make-assembly 206 | package 207 | 208 | single 209 | 210 | 211 | 212 | 213 | 214 | io.confluent 215 | kafka-connect-maven-plugin 216 | 0.11.2 217 | 218 | 219 | 220 | kafka-connect 221 | 222 | 223 | Kafka Connect Protobuf Converter 224 | 225 | https://github.com/blueapron/kafka-connect-protobuf-converter/blob/master/README.md 226 | 227 | Proto3 converter for Kafka Connect. 228 | blueapron 229 | organization 230 | Blue Apron, LLC. 231 | https://www.blueapron.com/ 232 | 233 | converter 234 | 235 | 236 | proto3 237 | protocol buffers 238 | protobuf 239 | converter 240 | 241 | ${project.issueManagement.url} 242 | Support provided through community involvement. 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Blue Apron, LLC. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | This project uses the following open-source libraries as runtime dependencies: 24 | 25 | connect-api (https://github.com/apache/kafka/tree/trunk/connect/api) 26 | and googleapis-common-protos (https://github.com/googleapis/googleapis/tree/master) under the Apache License 27 | 28 | Apache License 29 | Version 2.0, January 2004 30 | http://www.apache.org/licenses/ 31 | 32 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 33 | 34 | 1. Definitions. 35 | 36 | "License" shall mean the terms and conditions for use, reproduction, 37 | and distribution as defined by Sections 1 through 9 of this document. 38 | 39 | "Licensor" shall mean the copyright owner or entity authorized by 40 | the copyright owner that is granting the License. 41 | 42 | "Legal Entity" shall mean the union of the acting entity and all 43 | other entities that control, are controlled by, or are under common 44 | control with that entity. For the purposes of this definition, 45 | "control" means (i) the power, direct or indirect, to cause the 46 | direction or management of such entity, whether by contract or 47 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 48 | outstanding shares, or (iii) beneficial ownership of such entity. 49 | 50 | "You" (or "Your") shall mean an individual or Legal Entity 51 | exercising permissions granted by this License. 52 | 53 | "Source" form shall mean the preferred form for making modifications, 54 | including but not limited to software source code, documentation 55 | source, and configuration files. 56 | 57 | "Object" form shall mean any form resulting from mechanical 58 | transformation or translation of a Source form, including but 59 | not limited to compiled object code, generated documentation, 60 | and conversions to other media types. 61 | 62 | "Work" shall mean the work of authorship, whether in Source or 63 | Object form, made available under the License, as indicated by a 64 | copyright notice that is included in or attached to the work 65 | (an example is provided in the Appendix below). 66 | 67 | "Derivative Works" shall mean any work, whether in Source or Object 68 | form, that is based on (or derived from) the Work and for which the 69 | editorial revisions, annotations, elaborations, or other modifications 70 | represent, as a whole, an original work of authorship. For the purposes 71 | of this License, Derivative Works shall not include works that remain 72 | separable from, or merely link (or bind by name) to the interfaces of, 73 | the Work and Derivative Works thereof. 74 | 75 | "Contribution" shall mean any work of authorship, including 76 | the original version of the Work and any modifications or additions 77 | to that Work or Derivative Works thereof, that is intentionally 78 | submitted to Licensor for inclusion in the Work by the copyright owner 79 | or by an individual or Legal Entity authorized to submit on behalf of 80 | the copyright owner. For the purposes of this definition, "submitted" 81 | means any form of electronic, verbal, or written communication sent 82 | to the Licensor or its representatives, including but not limited to 83 | communication on electronic mailing lists, source code control systems, 84 | and issue tracking systems that are managed by, or on behalf of, the 85 | Licensor for the purpose of discussing and improving the Work, but 86 | excluding communication that is conspicuously marked or otherwise 87 | designated in writing by the copyright owner as "Not a Contribution." 88 | 89 | "Contributor" shall mean Licensor and any individual or Legal Entity 90 | on behalf of whom a Contribution has been received by Licensor and 91 | subsequently incorporated within the Work. 92 | 93 | 2. Grant of Copyright License. Subject to the terms and conditions of 94 | this License, each Contributor hereby grants to You a perpetual, 95 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 96 | copyright license to reproduce, prepare Derivative Works of, 97 | publicly display, publicly perform, sublicense, and distribute the 98 | Work and such Derivative Works in Source or Object form. 99 | 100 | 3. Grant of Patent License. Subject to the terms and conditions of 101 | this License, each Contributor hereby grants to You a perpetual, 102 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 103 | (except as stated in this section) patent license to make, have made, 104 | use, offer to sell, sell, import, and otherwise transfer the Work, 105 | where such license applies only to those patent claims licensable 106 | by such Contributor that are necessarily infringed by their 107 | Contribution(s) alone or by combination of their Contribution(s) 108 | with the Work to which such Contribution(s) was submitted. If You 109 | institute patent litigation against any entity (including a 110 | cross-claim or counterclaim in a lawsuit) alleging that the Work 111 | or a Contribution incorporated within the Work constitutes direct 112 | or contributory patent infringement, then any patent licenses 113 | granted to You under this License for that Work shall terminate 114 | as of the date such litigation is filed. 115 | 116 | 4. Redistribution. You may reproduce and distribute copies of the 117 | Work or Derivative Works thereof in any medium, with or without 118 | modifications, and in Source or Object form, provided that You 119 | meet the following conditions: 120 | 121 | (a) You must give any other recipients of the Work or 122 | Derivative Works a copy of this License; and 123 | 124 | (b) You must cause any modified files to carry prominent notices 125 | stating that You changed the files; and 126 | 127 | (c) You must retain, in the Source form of any Derivative Works 128 | that You distribute, all copyright, patent, trademark, and 129 | attribution notices from the Source form of the Work, 130 | excluding those notices that do not pertain to any part of 131 | the Derivative Works; and 132 | 133 | (d) If the Work includes a "NOTICE" text file as part of its 134 | distribution, then any Derivative Works that You distribute must 135 | include a readable copy of the attribution notices contained 136 | within such NOTICE file, excluding those notices that do not 137 | pertain to any part of the Derivative Works, in at least one 138 | of the following places: within a NOTICE text file distributed 139 | as part of the Derivative Works; within the Source form or 140 | documentation, if provided along with the Derivative Works; or, 141 | within a display generated by the Derivative Works, if and 142 | wherever such third-party notices normally appear. The contents 143 | of the NOTICE file are for informational purposes only and 144 | do not modify the License. You may add Your own attribution 145 | notices within Derivative Works that You distribute, alongside 146 | or as an addendum to the NOTICE text from the Work, provided 147 | that such additional attribution notices cannot be construed 148 | as modifying the License. 149 | 150 | You may add Your own copyright statement to Your modifications and 151 | may provide additional or different license terms and conditions 152 | for use, reproduction, or distribution of Your modifications, or 153 | for any such Derivative Works as a whole, provided Your use, 154 | reproduction, and distribution of the Work otherwise complies with 155 | the conditions stated in this License. 156 | 157 | 5. Submission of Contributions. Unless You explicitly state otherwise, 158 | any Contribution intentionally submitted for inclusion in the Work 159 | by You to the Licensor shall be under the terms and conditions of 160 | this License, without any additional terms or conditions. 161 | Notwithstanding the above, nothing herein shall supersede or modify 162 | the terms of any separate license agreement you may have executed 163 | with Licensor regarding such Contributions. 164 | 165 | 6. Trademarks. This License does not grant permission to use the trade 166 | names, trademarks, service marks, or product names of the Licensor, 167 | except as required for reasonable and customary use in describing the 168 | origin of the Work and reproducing the content of the NOTICE file. 169 | 170 | 7. Disclaimer of Warranty. Unless required by applicable law or 171 | agreed to in writing, Licensor provides the Work (and each 172 | Contributor provides its Contributions) on an "AS IS" BASIS, 173 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 174 | implied, including, without limitation, any warranties or conditions 175 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 176 | PARTICULAR PURPOSE. You are solely responsible for determining the 177 | appropriateness of using or redistributing the Work and assume any 178 | risks associated with Your exercise of permissions under this License. 179 | 180 | 8. Limitation of Liability. In no event and under no legal theory, 181 | whether in tort (including negligence), contract, or otherwise, 182 | unless required by applicable law (such as deliberate and grossly 183 | negligent acts) or agreed to in writing, shall any Contributor be 184 | liable to You for damages, including any direct, indirect, special, 185 | incidental, or consequential damages of any character arising as a 186 | result of this License or out of the use or inability to use the 187 | Work (including but not limited to damages for loss of goodwill, 188 | work stoppage, computer failure or malfunction, or any and all 189 | other commercial damages or losses), even if such Contributor 190 | has been advised of the possibility of such damages. 191 | 192 | 9. Accepting Warranty or Additional Liability. While redistributing 193 | the Work or Derivative Works thereof, You may choose to offer, 194 | and charge a fee for, acceptance of support, warranty, indemnity, 195 | or other liability obligations and/or rights consistent with this 196 | License. However, in accepting such obligations, You may act only 197 | on Your own behalf and on Your sole responsibility, not on behalf 198 | of any other Contributor, and only if You agree to indemnify, 199 | defend, and hold each Contributor harmless for any liability 200 | incurred by, or claims asserted against, such Contributor by reason 201 | of your accepting any such warranty or additional liability. 202 | 203 | END OF TERMS AND CONDITIONS 204 | 205 | APPENDIX: How to apply the Apache License to your work. 206 | 207 | To apply the Apache License to your work, attach the following 208 | boilerplate notice, with the fields enclosed by brackets "[]" 209 | replaced with your own identifying information. (Don't include 210 | the brackets!) The text should be enclosed in the appropriate 211 | comment syntax for the file format. We also recommend that a 212 | file or class name and description of purpose be included on the 213 | same "printed page" as the copyright notice for easier 214 | identification within third-party archives. 215 | 216 | Copyright [yyyy] [name of copyright owner] 217 | 218 | Licensed under the Apache License, Version 2.0 (the "License"); 219 | you may not use this file except in compliance with the License. 220 | You may obtain a copy of the License at 221 | 222 | http://www.apache.org/licenses/LICENSE-2.0 223 | 224 | Unless required by applicable law or agreed to in writing, software 225 | distributed under the License is distributed on an "AS IS" BASIS, 226 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 227 | See the License for the specific language governing permissions and 228 | limitations under the License. 229 | 230 | 231 | protobuf-java-util (https://github.com/google/protobuf/tree/master/java/util) 232 | 233 | Copyright 2014, Google Inc. All rights reserved. 234 | 235 | Redistribution and use in source and binary forms, with or without 236 | modification, are permitted provided that the following conditions are 237 | met: 238 | 239 | * Redistributions of source code must retain the above copyright 240 | notice, this list of conditions and the following disclaimer. 241 | * Redistributions in binary form must reproduce the above 242 | copyright notice, this list of conditions and the following disclaimer 243 | in the documentation and/or other materials provided with the 244 | distribution. 245 | * Neither the name of Google Inc. nor the names of its 246 | contributors may be used to endorse or promote products derived from 247 | this software without specific prior written permission. 248 | 249 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 250 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 251 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 252 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 253 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 254 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 255 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 256 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 257 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 258 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 259 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 260 | 261 | Code generated by the Protocol Buffer compiler is owned by the owner 262 | of the input file used when generating it. This code is not 263 | standalone and requires a support library to be linked with it. This 264 | support library is itself covered by the above license. 265 | -------------------------------------------------------------------------------- /src/main/java/com/blueapron/connect/protobuf/ProtobufData.java: -------------------------------------------------------------------------------- 1 | package com.blueapron.connect.protobuf; 2 | 3 | 4 | import com.google.protobuf.ByteString; 5 | import com.google.protobuf.Descriptors; 6 | import com.google.protobuf.Descriptors.FieldDescriptor; 7 | import com.google.protobuf.Descriptors.OneofDescriptor; 8 | import com.google.protobuf.GeneratedMessageV3; 9 | import com.google.protobuf.InvalidProtocolBufferException; 10 | import com.google.protobuf.MapEntry; 11 | import com.google.protobuf.Message; 12 | import org.apache.kafka.connect.data.Date; 13 | import org.apache.kafka.connect.data.Decimal; 14 | import org.apache.kafka.connect.data.Field; 15 | import org.apache.kafka.connect.data.Schema; 16 | import org.apache.kafka.connect.data.SchemaAndValue; 17 | import org.apache.kafka.connect.data.SchemaBuilder; 18 | import org.apache.kafka.connect.data.Struct; 19 | import org.apache.kafka.connect.data.Timestamp; 20 | import org.apache.kafka.connect.errors.ConnectException; 21 | import org.apache.kafka.connect.errors.DataException; 22 | 23 | import java.lang.reflect.Method; 24 | import java.math.BigDecimal; 25 | import java.math.BigInteger; 26 | import java.nio.ByteBuffer; 27 | import java.util.ArrayList; 28 | import java.util.Collection; 29 | import java.util.HashMap; 30 | import java.util.List; 31 | import java.util.Map; 32 | import java.util.stream.Collectors; 33 | import com.google.protobuf.util.Timestamps; 34 | 35 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.BOOL; 36 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.BYTES; 37 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.DOUBLE; 38 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.ENUM; 39 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.FLOAT; 40 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.INT32; 41 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.INT64; 42 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.SINT32; 43 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.SINT64; 44 | import static com.google.protobuf.Descriptors.FieldDescriptor.Type.STRING; 45 | 46 | 47 | class ProtobufData { 48 | public static final String CONNECT_DECIMAL_PRECISION_PROP = "connect.decimal.precision"; 49 | private final Method newBuilder; 50 | private final Schema schema; 51 | private final String legacyName; 52 | private final boolean useConnectSchemaMap; 53 | public static final Descriptors.FieldDescriptor.Type[] PROTO_TYPES_WITH_DEFAULTS = new Descriptors.FieldDescriptor.Type[] { INT32, INT64, SINT32, SINT64, FLOAT, DOUBLE, BOOL, STRING, BYTES, ENUM }; 54 | private HashMap connectProtoNameMap = new HashMap(); 55 | 56 | private GeneratedMessageV3.Builder getBuilder() { 57 | try { 58 | return (GeneratedMessageV3.Builder) newBuilder.invoke(Object.class); 59 | } catch (Exception e) { 60 | throw new ConnectException("Not a valid proto3 builder", e); 61 | } 62 | } 63 | 64 | private Message getMessage(byte[] value) { 65 | try { 66 | return getBuilder().mergeFrom(value).build(); 67 | } catch (InvalidProtocolBufferException e) { 68 | throw new DataException("Invalid protobuf data", e); 69 | } 70 | } 71 | 72 | private String getProtoMapKey(String descriptorContainingTypeName, String connectFieldName) { 73 | return descriptorContainingTypeName.concat(connectFieldName); 74 | } 75 | 76 | private String getConnectFieldName(Descriptors.FieldDescriptor descriptor) { 77 | String name = descriptor.getName(); 78 | for (Map.Entry option: descriptor.getOptions().getAllFields().entrySet()) { 79 | if (option.getKey().getFullName().equalsIgnoreCase(this.legacyName)) { 80 | name = option.getValue().toString(); 81 | } 82 | } 83 | 84 | connectProtoNameMap.put(getProtoMapKey(descriptor.getContainingType().getFullName(), name), descriptor.getName()); 85 | return name; 86 | } 87 | 88 | private String getProtoFieldName(String descriptorForTypeName, String connectFieldName) { 89 | return connectProtoNameMap.get(getProtoMapKey(descriptorForTypeName, connectFieldName)); 90 | } 91 | 92 | ProtobufData(Class clazz, String legacyName) { 93 | this(clazz, legacyName, false); 94 | } 95 | 96 | ProtobufData(Class clazz, String legacyName, boolean useConnectSchemaMap ) { 97 | this.legacyName = legacyName; 98 | this.useConnectSchemaMap = useConnectSchemaMap; 99 | 100 | try { 101 | this.newBuilder = clazz.getDeclaredMethod("newBuilder"); 102 | } catch (NoSuchMethodException e) { 103 | throw new ConnectException("Proto class " + clazz.getCanonicalName() + " is not a valid proto3 message class", e); 104 | } 105 | 106 | this.schema = toConnectSchema(getBuilder().getDefaultInstanceForType()); 107 | } 108 | 109 | SchemaAndValue toConnectData(byte[] value) { 110 | Message message = getMessage(value); 111 | if (message == null) { 112 | return SchemaAndValue.NULL; 113 | } 114 | return new SchemaAndValue(this.schema, toConnectData(this.schema, message)); 115 | } 116 | 117 | private Schema toConnectSchema(Message message) { 118 | final SchemaBuilder builder = SchemaBuilder.struct().name(message.getDescriptorForType().getName()); 119 | final List fieldDescriptorList = message.getDescriptorForType().getFields(); 120 | for (Descriptors.FieldDescriptor descriptor : fieldDescriptorList) { 121 | builder.field(getConnectFieldName(descriptor), toConnectSchema(descriptor)); 122 | } 123 | 124 | return builder.build(); 125 | } 126 | 127 | private boolean isTimestampDescriptor(Descriptors.FieldDescriptor descriptor) { 128 | return descriptor.getMessageType().getFullName().equals("google.protobuf.Timestamp"); 129 | } 130 | 131 | private boolean isDateDescriptor(Descriptors.FieldDescriptor descriptor) { 132 | return descriptor.getMessageType().getFullName().equals("google.type.Date"); 133 | } 134 | 135 | private Schema toConnectSchema(Descriptors.FieldDescriptor descriptor) { 136 | final SchemaBuilder builder; 137 | 138 | switch (descriptor.getType()) { 139 | case INT32: 140 | case SINT32: 141 | { 142 | builder = SchemaBuilder.int32(); 143 | break; 144 | } 145 | 146 | case INT64: 147 | case SINT64: 148 | case UINT32: 149 | { 150 | builder = SchemaBuilder.int64(); 151 | break; 152 | } 153 | 154 | case UINT64: 155 | builder = Decimal.builder(0).parameter(CONNECT_DECIMAL_PRECISION_PROP, "20"); 156 | break; 157 | 158 | case FLOAT: { 159 | builder = SchemaBuilder.float32(); 160 | break; 161 | } 162 | 163 | case DOUBLE: { 164 | builder = SchemaBuilder.float64(); 165 | break; 166 | } 167 | 168 | case BOOL: { 169 | builder = SchemaBuilder.bool(); 170 | break; 171 | } 172 | 173 | // TODO - Do we need to support byte or short? 174 | /*case INT8: 175 | // Encoded as an Integer 176 | converted = value == null ? null : ((Integer) value).byteValue(); 177 | break; 178 | case INT16: 179 | // Encoded as an Integer 180 | converted = value == null ? null : ((Integer) value).shortValue(); 181 | break;*/ 182 | 183 | case STRING: 184 | builder = SchemaBuilder.string(); 185 | break; 186 | 187 | case BYTES: 188 | builder = SchemaBuilder.bytes(); 189 | break; 190 | 191 | case ENUM: 192 | builder = SchemaBuilder.string(); 193 | break; 194 | 195 | case MESSAGE: { 196 | if (isTimestampDescriptor(descriptor)) { 197 | builder = Timestamp.builder(); 198 | break; 199 | } 200 | 201 | if (isDateDescriptor(descriptor)) { 202 | builder = Date.builder(); 203 | break; 204 | } 205 | 206 | if (shouldConvertToConnectSchemaMap(descriptor)) { 207 | FieldDescriptor keyFieldDescriptor = descriptor.getMessageType().findFieldByName("key"); 208 | FieldDescriptor valueFieldDescriptor = descriptor.getMessageType().findFieldByName("value"); 209 | builder = SchemaBuilder.map(toConnectSchema(keyFieldDescriptor), toConnectSchema(valueFieldDescriptor)); 210 | break; 211 | } 212 | 213 | String jsonName = descriptor.getJsonName(); 214 | builder = SchemaBuilder.struct().name(jsonName.substring(0, 1).toUpperCase() + jsonName.substring(1)); 215 | for (Descriptors.FieldDescriptor fieldDescriptor : descriptor.getMessageType().getFields()) { 216 | builder.field(getConnectFieldName(fieldDescriptor), toConnectSchema(fieldDescriptor)); 217 | } 218 | 219 | break; 220 | } 221 | 222 | default: 223 | throw new DataException("Unknown Connect schema type: " + descriptor.getType()); 224 | } 225 | 226 | builder.optional(); 227 | Schema schema = builder.build(); 228 | 229 | if (descriptor.isRepeated() && !shouldConvertToConnectSchemaMap(descriptor)) { 230 | final SchemaBuilder arrayBuilder = SchemaBuilder.array(schema); 231 | arrayBuilder.optional(); 232 | schema = arrayBuilder.build(); 233 | } 234 | 235 | return schema; 236 | } 237 | 238 | private boolean shouldConvertToConnectSchemaMap(FieldDescriptor descriptor) { 239 | return useConnectSchemaMap && descriptor.isMapField(); 240 | } 241 | 242 | private boolean isProtobufTimestamp(Schema schema) { 243 | return Timestamp.SCHEMA.name().equals(schema.name()); 244 | } 245 | 246 | private boolean isProtobufDate(Schema schema) { 247 | return Date.SCHEMA.name().equals(schema.name()); 248 | } 249 | 250 | private void setStructField(Schema schema, Message message, Struct result, Descriptors.FieldDescriptor fieldDescriptor) { 251 | final String fieldName = getConnectFieldName(fieldDescriptor); 252 | final Field field = schema.field(fieldName); 253 | Object obj = null; 254 | if (fieldDescriptor.getType() != FieldDescriptor.Type.MESSAGE || fieldDescriptor.isRepeated() || fieldDescriptor.isMapField() || message.hasField(fieldDescriptor)) { 255 | obj = toConnectData(field.schema(), message.getField(fieldDescriptor)); 256 | } 257 | result.put(fieldName, obj); 258 | } 259 | 260 | Object toConnectData(Schema schema, Object value) { 261 | try { 262 | if (isProtobufTimestamp(schema)) { 263 | com.google.protobuf.Timestamp timestamp = (com.google.protobuf.Timestamp) value; 264 | return Timestamp.toLogical(schema, Timestamps.toMillis(timestamp)); 265 | } 266 | 267 | if (isProtobufDate(schema)) { 268 | com.google.type.Date date = (com.google.type.Date) value; 269 | return ProtobufUtils.convertFromGoogleDate(date); 270 | } 271 | 272 | Object converted = null; 273 | switch (schema.type()) { 274 | // Pass through types 275 | case INT32: { 276 | Integer intValue = (Integer) value; // Validate type 277 | converted = value; 278 | break; 279 | } 280 | 281 | case INT64: { 282 | try { 283 | Long longValue = (Long) value; // Validate type 284 | converted = value; 285 | } catch (ClassCastException e) { 286 | Integer intValue = (Integer) value; // Validate type 287 | converted = Integer.toUnsignedLong(intValue); 288 | } 289 | 290 | break; 291 | } 292 | 293 | case FLOAT32: { 294 | Float floatValue = (Float) value; // Validate type 295 | converted = value; 296 | break; 297 | } 298 | 299 | case FLOAT64: { 300 | Double doubleValue = (Double) value; // Validate type 301 | converted = value; 302 | break; 303 | } 304 | 305 | case BOOLEAN: { 306 | Boolean boolValue = (Boolean) value; // Validate type 307 | converted = value; 308 | break; 309 | } 310 | 311 | // TODO - Do we need to support byte or short? 312 | /*case INT8: 313 | // Encoded as an Integer 314 | converted = value == null ? null : ((Integer) value).byteValue(); 315 | break; 316 | case INT16: 317 | // Encoded as an Integer 318 | converted = value == null ? null : ((Integer) value).shortValue(); 319 | break;*/ 320 | 321 | case STRING: 322 | if (value instanceof String) { 323 | converted = value; 324 | } else if (value instanceof CharSequence 325 | || value instanceof Enum 326 | || value instanceof Descriptors.EnumValueDescriptor) { 327 | converted = value.toString(); 328 | } else { 329 | throw new DataException("Invalid class for string type, expecting String or " 330 | + "CharSequence but found " + value.getClass()); 331 | } 332 | break; 333 | 334 | case BYTES: 335 | if (value instanceof byte[]) { 336 | converted = ByteBuffer.wrap((byte[]) value); 337 | } else if (value instanceof ByteString) { 338 | final byte[] valueBytes = ((ByteString) value).toByteArray(); 339 | converted = ByteBuffer.wrap(valueBytes); 340 | } else if (value instanceof ByteBuffer) { 341 | converted = value; 342 | } else if (value instanceof Long){ 343 | BigInteger unsigned = toUnsigned(BigInteger.valueOf((Long) value), 8); 344 | converted = new BigDecimal(unsigned, 0); 345 | } else { 346 | throw new DataException("Invalid class for bytes type, expecting byte[], ByteString, " 347 | + "or ByteBuffer but found " + value.getClass()); 348 | } 349 | break; 350 | 351 | // Used for repeated types 352 | case ARRAY: { 353 | final Schema valueSchema = schema.valueSchema(); 354 | final Collection original = (Collection) value; 355 | final List result = new ArrayList(original.size()); 356 | for (Object elem : original) { 357 | result.add(toConnectData(valueSchema, elem)); 358 | } 359 | converted = result; 360 | break; 361 | } 362 | 363 | case MAP: { 364 | Collection original = (Collection) value; 365 | converted = original.stream().collect(Collectors.toMap( 366 | entry -> toConnectData(schema.keySchema(), entry.getKey()), 367 | entry -> toConnectData(schema.valueSchema(), entry.getValue()) 368 | )); 369 | break; 370 | } 371 | 372 | case STRUCT: { 373 | final Message message = (Message) value; // Validate type 374 | 375 | final Struct result = new Struct(schema.schema()); 376 | final Descriptors.Descriptor descriptor = message.getDescriptorForType(); 377 | 378 | for (OneofDescriptor oneOfDescriptor : descriptor.getOneofs()) { 379 | final Descriptors.FieldDescriptor fieldDescriptor = message.getOneofFieldDescriptor(oneOfDescriptor); 380 | if (fieldDescriptor != null) { 381 | setStructField(schema, message, result, fieldDescriptor); 382 | } 383 | } 384 | 385 | for (Descriptors.FieldDescriptor fieldDescriptor : descriptor.getFields()) { 386 | Descriptors.OneofDescriptor oneOfDescriptor = fieldDescriptor.getContainingOneof(); 387 | if (oneOfDescriptor != null) { 388 | continue; 389 | } 390 | 391 | setStructField(schema, message, result, fieldDescriptor); 392 | } 393 | 394 | converted = result; 395 | break; 396 | } 397 | 398 | default: 399 | throw new DataException("Unknown Connect schema type: " + schema.type()); 400 | } 401 | 402 | return converted; 403 | } catch (ClassCastException e) { 404 | throw new DataException("Invalid type for " + schema.type() + ": " + value.getClass()); 405 | } 406 | } 407 | 408 | private static BigInteger toUnsigned(BigInteger num, int sizeInBytes) { 409 | return num.andNot(BigInteger.valueOf(-1).shiftLeft(sizeInBytes * 8)); 410 | } 411 | 412 | 413 | byte[] fromConnectData(Object value) { 414 | final com.google.protobuf.GeneratedMessageV3.Builder builder = getBuilder(); 415 | final Struct struct = (Struct) value; 416 | 417 | for (Field field : this.schema.fields()) { 418 | fromConnectData(builder, field, struct.get(field)); 419 | } 420 | 421 | return builder.build().toByteArray(); 422 | } 423 | 424 | private void fromConnectData(com.google.protobuf.GeneratedMessageV3.Builder builder, Field field, Object value) { 425 | final String protobufFieldName = getProtoFieldName(builder.getDescriptorForType().getFullName(), field.name()); 426 | final Descriptors.FieldDescriptor fieldDescriptor = builder.getDescriptorForType().findFieldByName(protobufFieldName); 427 | if (fieldDescriptor == null) { 428 | // Ignore unknown fields 429 | return; 430 | } 431 | 432 | final Schema schema = field.schema(); 433 | final Schema.Type schemaType = schema.type(); 434 | 435 | try { 436 | switch (schemaType) { 437 | case INT32: { 438 | if (isProtobufDate(schema)) { 439 | final java.util.Date date = (java.util.Date) value; 440 | builder.setField(fieldDescriptor, ProtobufUtils.convertToGoogleDate(date)); 441 | return; 442 | } 443 | 444 | final Integer intValue = (Integer) value; // Check for correct type 445 | builder.setField(fieldDescriptor, intValue); 446 | return; 447 | } 448 | 449 | case INT64: { 450 | if (isProtobufTimestamp(schema)) { 451 | final java.util.Date timestamp = (java.util.Date) value; 452 | builder.setField(fieldDescriptor, Timestamps.fromMillis(Timestamp.fromLogical(schema, timestamp))); 453 | return; 454 | } 455 | 456 | final Long longValue = (Long) value; // Check for correct type 457 | builder.setField(fieldDescriptor, longValue); 458 | return; 459 | } 460 | 461 | case FLOAT32: { 462 | final Float floatValue = (Float) value; // Check for correct type 463 | builder.setField(fieldDescriptor, floatValue); 464 | return; 465 | } 466 | 467 | case FLOAT64: { 468 | final Double doubleValue = (Double) value; // Check for correct type 469 | builder.setField(fieldDescriptor, doubleValue); 470 | return; 471 | } 472 | 473 | case BOOLEAN: { 474 | final Boolean boolValue = (Boolean) value; // Check for correct type 475 | builder.setField(fieldDescriptor, boolValue); 476 | return; 477 | } 478 | 479 | case STRING: { 480 | final String stringValue = (String) value; // Check for correct type 481 | builder.setField(fieldDescriptor, stringValue); 482 | return; 483 | } 484 | 485 | case BYTES: { 486 | final ByteBuffer bytesValue = value instanceof byte[] ? ByteBuffer.wrap((byte[]) value) : 487 | (ByteBuffer) value; 488 | builder.setField(fieldDescriptor, ByteString.copyFrom(bytesValue)); 489 | return; 490 | } 491 | 492 | default: 493 | throw new DataException("Unknown schema type: " + schema.type()); 494 | } 495 | } catch (ClassCastException e) { 496 | throw new DataException("Invalid type for " + schema.type() + ": " + value.getClass()); 497 | } 498 | } 499 | } 500 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/UInt32ValueOuterClass.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: UInt32Value.proto 3 | 4 | package com.blueapron.connect.protobuf; 5 | 6 | public final class UInt32ValueOuterClass { 7 | private UInt32ValueOuterClass() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface UInt32ValueOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:UInt32Value) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | * uint32 value = 1; 23 | * @return The value. 24 | */ 25 | int getValue(); 26 | } 27 | /** 28 | *
 29 |    * Wrapper message for `uint32`.
 30 |    * 
31 | * 32 | * Protobuf type {@code UInt32Value} 33 | */ 34 | public static final class UInt32Value extends 35 | com.google.protobuf.GeneratedMessageV3 implements 36 | // @@protoc_insertion_point(message_implements:UInt32Value) 37 | UInt32ValueOrBuilder { 38 | private static final long serialVersionUID = 0L; 39 | // Use UInt32Value.newBuilder() to construct. 40 | private UInt32Value(com.google.protobuf.GeneratedMessageV3.Builder builder) { 41 | super(builder); 42 | } 43 | private UInt32Value() { 44 | } 45 | 46 | @java.lang.Override 47 | @SuppressWarnings({"unused"}) 48 | protected java.lang.Object newInstance( 49 | UnusedPrivateParameter unused) { 50 | return new UInt32Value(); 51 | } 52 | 53 | @java.lang.Override 54 | public final com.google.protobuf.UnknownFieldSet 55 | getUnknownFields() { 56 | return this.unknownFields; 57 | } 58 | private UInt32Value( 59 | com.google.protobuf.CodedInputStream input, 60 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 61 | throws com.google.protobuf.InvalidProtocolBufferException { 62 | this(); 63 | if (extensionRegistry == null) { 64 | throw new java.lang.NullPointerException(); 65 | } 66 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 67 | com.google.protobuf.UnknownFieldSet.newBuilder(); 68 | try { 69 | boolean done = false; 70 | while (!done) { 71 | int tag = input.readTag(); 72 | switch (tag) { 73 | case 0: 74 | done = true; 75 | break; 76 | case 8: { 77 | 78 | value_ = input.readUInt32(); 79 | break; 80 | } 81 | default: { 82 | if (!parseUnknownField( 83 | input, unknownFields, extensionRegistry, tag)) { 84 | done = true; 85 | } 86 | break; 87 | } 88 | } 89 | } 90 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 91 | throw e.setUnfinishedMessage(this); 92 | } catch (java.io.IOException e) { 93 | throw new com.google.protobuf.InvalidProtocolBufferException( 94 | e).setUnfinishedMessage(this); 95 | } finally { 96 | this.unknownFields = unknownFields.build(); 97 | makeExtensionsImmutable(); 98 | } 99 | } 100 | public static final com.google.protobuf.Descriptors.Descriptor 101 | getDescriptor() { 102 | return com.blueapron.connect.protobuf.UInt32ValueOuterClass.internal_static_UInt32Value_descriptor; 103 | } 104 | 105 | @java.lang.Override 106 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 107 | internalGetFieldAccessorTable() { 108 | return com.blueapron.connect.protobuf.UInt32ValueOuterClass.internal_static_UInt32Value_fieldAccessorTable 109 | .ensureFieldAccessorsInitialized( 110 | com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value.class, com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value.Builder.class); 111 | } 112 | 113 | public static final int VALUE_FIELD_NUMBER = 1; 114 | private int value_; 115 | /** 116 | * uint32 value = 1; 117 | * @return The value. 118 | */ 119 | public int getValue() { 120 | return value_; 121 | } 122 | 123 | private byte memoizedIsInitialized = -1; 124 | @java.lang.Override 125 | public final boolean isInitialized() { 126 | byte isInitialized = memoizedIsInitialized; 127 | if (isInitialized == 1) return true; 128 | if (isInitialized == 0) return false; 129 | 130 | memoizedIsInitialized = 1; 131 | return true; 132 | } 133 | 134 | @java.lang.Override 135 | public void writeTo(com.google.protobuf.CodedOutputStream output) 136 | throws java.io.IOException { 137 | if (value_ != 0) { 138 | output.writeUInt32(1, value_); 139 | } 140 | unknownFields.writeTo(output); 141 | } 142 | 143 | @java.lang.Override 144 | public int getSerializedSize() { 145 | int size = memoizedSize; 146 | if (size != -1) return size; 147 | 148 | size = 0; 149 | if (value_ != 0) { 150 | size += com.google.protobuf.CodedOutputStream 151 | .computeUInt32Size(1, value_); 152 | } 153 | size += unknownFields.getSerializedSize(); 154 | memoizedSize = size; 155 | return size; 156 | } 157 | 158 | @java.lang.Override 159 | public boolean equals(final java.lang.Object obj) { 160 | if (obj == this) { 161 | return true; 162 | } 163 | if (!(obj instanceof com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value)) { 164 | return super.equals(obj); 165 | } 166 | com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value other = (com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value) obj; 167 | 168 | if (getValue() 169 | != other.getValue()) return false; 170 | if (!unknownFields.equals(other.unknownFields)) return false; 171 | return true; 172 | } 173 | 174 | @java.lang.Override 175 | public int hashCode() { 176 | if (memoizedHashCode != 0) { 177 | return memoizedHashCode; 178 | } 179 | int hash = 41; 180 | hash = (19 * hash) + getDescriptor().hashCode(); 181 | hash = (37 * hash) + VALUE_FIELD_NUMBER; 182 | hash = (53 * hash) + getValue(); 183 | hash = (29 * hash) + unknownFields.hashCode(); 184 | memoizedHashCode = hash; 185 | return hash; 186 | } 187 | 188 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom( 189 | java.nio.ByteBuffer data) 190 | throws com.google.protobuf.InvalidProtocolBufferException { 191 | return PARSER.parseFrom(data); 192 | } 193 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom( 194 | java.nio.ByteBuffer data, 195 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 196 | throws com.google.protobuf.InvalidProtocolBufferException { 197 | return PARSER.parseFrom(data, extensionRegistry); 198 | } 199 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom( 200 | com.google.protobuf.ByteString data) 201 | throws com.google.protobuf.InvalidProtocolBufferException { 202 | return PARSER.parseFrom(data); 203 | } 204 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom( 205 | com.google.protobuf.ByteString data, 206 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 207 | throws com.google.protobuf.InvalidProtocolBufferException { 208 | return PARSER.parseFrom(data, extensionRegistry); 209 | } 210 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom(byte[] data) 211 | throws com.google.protobuf.InvalidProtocolBufferException { 212 | return PARSER.parseFrom(data); 213 | } 214 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom( 215 | byte[] data, 216 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 217 | throws com.google.protobuf.InvalidProtocolBufferException { 218 | return PARSER.parseFrom(data, extensionRegistry); 219 | } 220 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom(java.io.InputStream input) 221 | throws java.io.IOException { 222 | return com.google.protobuf.GeneratedMessageV3 223 | .parseWithIOException(PARSER, input); 224 | } 225 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom( 226 | java.io.InputStream input, 227 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 228 | throws java.io.IOException { 229 | return com.google.protobuf.GeneratedMessageV3 230 | .parseWithIOException(PARSER, input, extensionRegistry); 231 | } 232 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseDelimitedFrom(java.io.InputStream input) 233 | throws java.io.IOException { 234 | return com.google.protobuf.GeneratedMessageV3 235 | .parseDelimitedWithIOException(PARSER, input); 236 | } 237 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseDelimitedFrom( 238 | java.io.InputStream input, 239 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 240 | throws java.io.IOException { 241 | return com.google.protobuf.GeneratedMessageV3 242 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 243 | } 244 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom( 245 | com.google.protobuf.CodedInputStream input) 246 | throws java.io.IOException { 247 | return com.google.protobuf.GeneratedMessageV3 248 | .parseWithIOException(PARSER, input); 249 | } 250 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parseFrom( 251 | com.google.protobuf.CodedInputStream input, 252 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 253 | throws java.io.IOException { 254 | return com.google.protobuf.GeneratedMessageV3 255 | .parseWithIOException(PARSER, input, extensionRegistry); 256 | } 257 | 258 | @java.lang.Override 259 | public Builder newBuilderForType() { return newBuilder(); } 260 | public static Builder newBuilder() { 261 | return DEFAULT_INSTANCE.toBuilder(); 262 | } 263 | public static Builder newBuilder(com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value prototype) { 264 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 265 | } 266 | @java.lang.Override 267 | public Builder toBuilder() { 268 | return this == DEFAULT_INSTANCE 269 | ? new Builder() : new Builder().mergeFrom(this); 270 | } 271 | 272 | @java.lang.Override 273 | protected Builder newBuilderForType( 274 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 275 | Builder builder = new Builder(parent); 276 | return builder; 277 | } 278 | /** 279 | *
280 |      * Wrapper message for `uint32`.
281 |      * 
282 | * 283 | * Protobuf type {@code UInt32Value} 284 | */ 285 | public static final class Builder extends 286 | com.google.protobuf.GeneratedMessageV3.Builder implements 287 | // @@protoc_insertion_point(builder_implements:UInt32Value) 288 | com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32ValueOrBuilder { 289 | public static final com.google.protobuf.Descriptors.Descriptor 290 | getDescriptor() { 291 | return com.blueapron.connect.protobuf.UInt32ValueOuterClass.internal_static_UInt32Value_descriptor; 292 | } 293 | 294 | @java.lang.Override 295 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 296 | internalGetFieldAccessorTable() { 297 | return com.blueapron.connect.protobuf.UInt32ValueOuterClass.internal_static_UInt32Value_fieldAccessorTable 298 | .ensureFieldAccessorsInitialized( 299 | com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value.class, com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value.Builder.class); 300 | } 301 | 302 | // Construct using com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value.newBuilder() 303 | private Builder() { 304 | maybeForceBuilderInitialization(); 305 | } 306 | 307 | private Builder( 308 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 309 | super(parent); 310 | maybeForceBuilderInitialization(); 311 | } 312 | private void maybeForceBuilderInitialization() { 313 | if (com.google.protobuf.GeneratedMessageV3 314 | .alwaysUseFieldBuilders) { 315 | } 316 | } 317 | @java.lang.Override 318 | public Builder clear() { 319 | super.clear(); 320 | value_ = 0; 321 | 322 | return this; 323 | } 324 | 325 | @java.lang.Override 326 | public com.google.protobuf.Descriptors.Descriptor 327 | getDescriptorForType() { 328 | return com.blueapron.connect.protobuf.UInt32ValueOuterClass.internal_static_UInt32Value_descriptor; 329 | } 330 | 331 | @java.lang.Override 332 | public com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value getDefaultInstanceForType() { 333 | return com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value.getDefaultInstance(); 334 | } 335 | 336 | @java.lang.Override 337 | public com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value build() { 338 | com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value result = buildPartial(); 339 | if (!result.isInitialized()) { 340 | throw newUninitializedMessageException(result); 341 | } 342 | return result; 343 | } 344 | 345 | @java.lang.Override 346 | public com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value buildPartial() { 347 | com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value result = new com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value(this); 348 | result.value_ = value_; 349 | onBuilt(); 350 | return result; 351 | } 352 | 353 | @java.lang.Override 354 | public Builder clone() { 355 | return super.clone(); 356 | } 357 | @java.lang.Override 358 | public Builder setField( 359 | com.google.protobuf.Descriptors.FieldDescriptor field, 360 | java.lang.Object value) { 361 | return super.setField(field, value); 362 | } 363 | @java.lang.Override 364 | public Builder clearField( 365 | com.google.protobuf.Descriptors.FieldDescriptor field) { 366 | return super.clearField(field); 367 | } 368 | @java.lang.Override 369 | public Builder clearOneof( 370 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 371 | return super.clearOneof(oneof); 372 | } 373 | @java.lang.Override 374 | public Builder setRepeatedField( 375 | com.google.protobuf.Descriptors.FieldDescriptor field, 376 | int index, java.lang.Object value) { 377 | return super.setRepeatedField(field, index, value); 378 | } 379 | @java.lang.Override 380 | public Builder addRepeatedField( 381 | com.google.protobuf.Descriptors.FieldDescriptor field, 382 | java.lang.Object value) { 383 | return super.addRepeatedField(field, value); 384 | } 385 | @java.lang.Override 386 | public Builder mergeFrom(com.google.protobuf.Message other) { 387 | if (other instanceof com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value) { 388 | return mergeFrom((com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value)other); 389 | } else { 390 | super.mergeFrom(other); 391 | return this; 392 | } 393 | } 394 | 395 | public Builder mergeFrom(com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value other) { 396 | if (other == com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value.getDefaultInstance()) return this; 397 | if (other.getValue() != 0) { 398 | setValue(other.getValue()); 399 | } 400 | this.mergeUnknownFields(other.unknownFields); 401 | onChanged(); 402 | return this; 403 | } 404 | 405 | @java.lang.Override 406 | public final boolean isInitialized() { 407 | return true; 408 | } 409 | 410 | @java.lang.Override 411 | public Builder mergeFrom( 412 | com.google.protobuf.CodedInputStream input, 413 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 414 | throws java.io.IOException { 415 | com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value parsedMessage = null; 416 | try { 417 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 418 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 419 | parsedMessage = (com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value) e.getUnfinishedMessage(); 420 | throw e.unwrapIOException(); 421 | } finally { 422 | if (parsedMessage != null) { 423 | mergeFrom(parsedMessage); 424 | } 425 | } 426 | return this; 427 | } 428 | 429 | private int value_ ; 430 | /** 431 | * uint32 value = 1; 432 | * @return The value. 433 | */ 434 | public int getValue() { 435 | return value_; 436 | } 437 | /** 438 | * uint32 value = 1; 439 | * @param value The value to set. 440 | * @return This builder for chaining. 441 | */ 442 | public Builder setValue(int value) { 443 | 444 | value_ = value; 445 | onChanged(); 446 | return this; 447 | } 448 | /** 449 | * uint32 value = 1; 450 | * @return This builder for chaining. 451 | */ 452 | public Builder clearValue() { 453 | 454 | value_ = 0; 455 | onChanged(); 456 | return this; 457 | } 458 | @java.lang.Override 459 | public final Builder setUnknownFields( 460 | final com.google.protobuf.UnknownFieldSet unknownFields) { 461 | return super.setUnknownFields(unknownFields); 462 | } 463 | 464 | @java.lang.Override 465 | public final Builder mergeUnknownFields( 466 | final com.google.protobuf.UnknownFieldSet unknownFields) { 467 | return super.mergeUnknownFields(unknownFields); 468 | } 469 | 470 | 471 | // @@protoc_insertion_point(builder_scope:UInt32Value) 472 | } 473 | 474 | // @@protoc_insertion_point(class_scope:UInt32Value) 475 | private static final com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value DEFAULT_INSTANCE; 476 | static { 477 | DEFAULT_INSTANCE = new com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value(); 478 | } 479 | 480 | public static com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value getDefaultInstance() { 481 | return DEFAULT_INSTANCE; 482 | } 483 | 484 | private static final com.google.protobuf.Parser 485 | PARSER = new com.google.protobuf.AbstractParser() { 486 | @java.lang.Override 487 | public UInt32Value parsePartialFrom( 488 | com.google.protobuf.CodedInputStream input, 489 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 490 | throws com.google.protobuf.InvalidProtocolBufferException { 491 | return new UInt32Value(input, extensionRegistry); 492 | } 493 | }; 494 | 495 | public static com.google.protobuf.Parser parser() { 496 | return PARSER; 497 | } 498 | 499 | @java.lang.Override 500 | public com.google.protobuf.Parser getParserForType() { 501 | return PARSER; 502 | } 503 | 504 | @java.lang.Override 505 | public com.blueapron.connect.protobuf.UInt32ValueOuterClass.UInt32Value getDefaultInstanceForType() { 506 | return DEFAULT_INSTANCE; 507 | } 508 | 509 | } 510 | 511 | private static final com.google.protobuf.Descriptors.Descriptor 512 | internal_static_UInt32Value_descriptor; 513 | private static final 514 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 515 | internal_static_UInt32Value_fieldAccessorTable; 516 | 517 | public static com.google.protobuf.Descriptors.FileDescriptor 518 | getDescriptor() { 519 | return descriptor; 520 | } 521 | private static com.google.protobuf.Descriptors.FileDescriptor 522 | descriptor; 523 | static { 524 | java.lang.String[] descriptorData = { 525 | "\n\021UInt32Value.proto\"\034\n\013UInt32Value\022\r\n\005va" + 526 | "lue\030\001 \001(\rB \n\036com.blueapron.connect.proto" + 527 | "bufb\006proto3" 528 | }; 529 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 530 | .internalBuildGeneratedFileFrom(descriptorData, 531 | new com.google.protobuf.Descriptors.FileDescriptor[] { 532 | }); 533 | internal_static_UInt32Value_descriptor = 534 | getDescriptor().getMessageTypes().get(0); 535 | internal_static_UInt32Value_fieldAccessorTable = new 536 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 537 | internal_static_UInt32Value_descriptor, 538 | new java.lang.String[] { "Value", }); 539 | } 540 | 541 | // @@protoc_insertion_point(outer_class_scope) 542 | } 543 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/SInt32ValueOuterClass.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: SInt32Value.proto 3 | 4 | package com.blueapron.connect.protobuf; 5 | 6 | public final class SInt32ValueOuterClass { 7 | private SInt32ValueOuterClass() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface SInt32ValueOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:SInt32Value) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | * sint32 value = 1; 23 | * @return The value. 24 | */ 25 | int getValue(); 26 | } 27 | /** 28 | *
 29 |    * Wrapper message for `sint32`.
 30 |    * 
31 | * 32 | * Protobuf type {@code SInt32Value} 33 | */ 34 | public static final class SInt32Value extends 35 | com.google.protobuf.GeneratedMessageV3 implements 36 | // @@protoc_insertion_point(message_implements:SInt32Value) 37 | SInt32ValueOrBuilder { 38 | private static final long serialVersionUID = 0L; 39 | // Use SInt32Value.newBuilder() to construct. 40 | private SInt32Value(com.google.protobuf.GeneratedMessageV3.Builder builder) { 41 | super(builder); 42 | } 43 | private SInt32Value() { 44 | } 45 | 46 | @java.lang.Override 47 | @SuppressWarnings({"unused"}) 48 | protected java.lang.Object newInstance( 49 | UnusedPrivateParameter unused) { 50 | return new SInt32Value(); 51 | } 52 | 53 | @java.lang.Override 54 | public final com.google.protobuf.UnknownFieldSet 55 | getUnknownFields() { 56 | return this.unknownFields; 57 | } 58 | private SInt32Value( 59 | com.google.protobuf.CodedInputStream input, 60 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 61 | throws com.google.protobuf.InvalidProtocolBufferException { 62 | this(); 63 | if (extensionRegistry == null) { 64 | throw new java.lang.NullPointerException(); 65 | } 66 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 67 | com.google.protobuf.UnknownFieldSet.newBuilder(); 68 | try { 69 | boolean done = false; 70 | while (!done) { 71 | int tag = input.readTag(); 72 | switch (tag) { 73 | case 0: 74 | done = true; 75 | break; 76 | case 8: { 77 | 78 | value_ = input.readSInt32(); 79 | break; 80 | } 81 | default: { 82 | if (!parseUnknownField( 83 | input, unknownFields, extensionRegistry, tag)) { 84 | done = true; 85 | } 86 | break; 87 | } 88 | } 89 | } 90 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 91 | throw e.setUnfinishedMessage(this); 92 | } catch (java.io.IOException e) { 93 | throw new com.google.protobuf.InvalidProtocolBufferException( 94 | e).setUnfinishedMessage(this); 95 | } finally { 96 | this.unknownFields = unknownFields.build(); 97 | makeExtensionsImmutable(); 98 | } 99 | } 100 | public static final com.google.protobuf.Descriptors.Descriptor 101 | getDescriptor() { 102 | return com.blueapron.connect.protobuf.SInt32ValueOuterClass.internal_static_SInt32Value_descriptor; 103 | } 104 | 105 | @java.lang.Override 106 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 107 | internalGetFieldAccessorTable() { 108 | return com.blueapron.connect.protobuf.SInt32ValueOuterClass.internal_static_SInt32Value_fieldAccessorTable 109 | .ensureFieldAccessorsInitialized( 110 | com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value.class, com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value.Builder.class); 111 | } 112 | 113 | public static final int VALUE_FIELD_NUMBER = 1; 114 | private int value_; 115 | /** 116 | * sint32 value = 1; 117 | * @return The value. 118 | */ 119 | public int getValue() { 120 | return value_; 121 | } 122 | 123 | private byte memoizedIsInitialized = -1; 124 | @java.lang.Override 125 | public final boolean isInitialized() { 126 | byte isInitialized = memoizedIsInitialized; 127 | if (isInitialized == 1) return true; 128 | if (isInitialized == 0) return false; 129 | 130 | memoizedIsInitialized = 1; 131 | return true; 132 | } 133 | 134 | @java.lang.Override 135 | public void writeTo(com.google.protobuf.CodedOutputStream output) 136 | throws java.io.IOException { 137 | if (value_ != 0) { 138 | output.writeSInt32(1, value_); 139 | } 140 | unknownFields.writeTo(output); 141 | } 142 | 143 | @java.lang.Override 144 | public int getSerializedSize() { 145 | int size = memoizedSize; 146 | if (size != -1) return size; 147 | 148 | size = 0; 149 | if (value_ != 0) { 150 | size += com.google.protobuf.CodedOutputStream 151 | .computeSInt32Size(1, value_); 152 | } 153 | size += unknownFields.getSerializedSize(); 154 | memoizedSize = size; 155 | return size; 156 | } 157 | 158 | @java.lang.Override 159 | public boolean equals(final java.lang.Object obj) { 160 | if (obj == this) { 161 | return true; 162 | } 163 | if (!(obj instanceof com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value)) { 164 | return super.equals(obj); 165 | } 166 | com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value other = (com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value) obj; 167 | 168 | if (getValue() 169 | != other.getValue()) return false; 170 | if (!unknownFields.equals(other.unknownFields)) return false; 171 | return true; 172 | } 173 | 174 | @java.lang.Override 175 | public int hashCode() { 176 | if (memoizedHashCode != 0) { 177 | return memoizedHashCode; 178 | } 179 | int hash = 41; 180 | hash = (19 * hash) + getDescriptor().hashCode(); 181 | hash = (37 * hash) + VALUE_FIELD_NUMBER; 182 | hash = (53 * hash) + getValue(); 183 | hash = (29 * hash) + unknownFields.hashCode(); 184 | memoizedHashCode = hash; 185 | return hash; 186 | } 187 | 188 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom( 189 | java.nio.ByteBuffer data) 190 | throws com.google.protobuf.InvalidProtocolBufferException { 191 | return PARSER.parseFrom(data); 192 | } 193 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom( 194 | java.nio.ByteBuffer data, 195 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 196 | throws com.google.protobuf.InvalidProtocolBufferException { 197 | return PARSER.parseFrom(data, extensionRegistry); 198 | } 199 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom( 200 | com.google.protobuf.ByteString data) 201 | throws com.google.protobuf.InvalidProtocolBufferException { 202 | return PARSER.parseFrom(data); 203 | } 204 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom( 205 | com.google.protobuf.ByteString data, 206 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 207 | throws com.google.protobuf.InvalidProtocolBufferException { 208 | return PARSER.parseFrom(data, extensionRegistry); 209 | } 210 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom(byte[] data) 211 | throws com.google.protobuf.InvalidProtocolBufferException { 212 | return PARSER.parseFrom(data); 213 | } 214 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom( 215 | byte[] data, 216 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 217 | throws com.google.protobuf.InvalidProtocolBufferException { 218 | return PARSER.parseFrom(data, extensionRegistry); 219 | } 220 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom(java.io.InputStream input) 221 | throws java.io.IOException { 222 | return com.google.protobuf.GeneratedMessageV3 223 | .parseWithIOException(PARSER, input); 224 | } 225 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom( 226 | java.io.InputStream input, 227 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 228 | throws java.io.IOException { 229 | return com.google.protobuf.GeneratedMessageV3 230 | .parseWithIOException(PARSER, input, extensionRegistry); 231 | } 232 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseDelimitedFrom(java.io.InputStream input) 233 | throws java.io.IOException { 234 | return com.google.protobuf.GeneratedMessageV3 235 | .parseDelimitedWithIOException(PARSER, input); 236 | } 237 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseDelimitedFrom( 238 | java.io.InputStream input, 239 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 240 | throws java.io.IOException { 241 | return com.google.protobuf.GeneratedMessageV3 242 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 243 | } 244 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom( 245 | com.google.protobuf.CodedInputStream input) 246 | throws java.io.IOException { 247 | return com.google.protobuf.GeneratedMessageV3 248 | .parseWithIOException(PARSER, input); 249 | } 250 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parseFrom( 251 | com.google.protobuf.CodedInputStream input, 252 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 253 | throws java.io.IOException { 254 | return com.google.protobuf.GeneratedMessageV3 255 | .parseWithIOException(PARSER, input, extensionRegistry); 256 | } 257 | 258 | @java.lang.Override 259 | public Builder newBuilderForType() { return newBuilder(); } 260 | public static Builder newBuilder() { 261 | return DEFAULT_INSTANCE.toBuilder(); 262 | } 263 | public static Builder newBuilder(com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value prototype) { 264 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 265 | } 266 | @java.lang.Override 267 | public Builder toBuilder() { 268 | return this == DEFAULT_INSTANCE 269 | ? new Builder() : new Builder().mergeFrom(this); 270 | } 271 | 272 | @java.lang.Override 273 | protected Builder newBuilderForType( 274 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 275 | Builder builder = new Builder(parent); 276 | return builder; 277 | } 278 | /** 279 | *
280 |      * Wrapper message for `sint32`.
281 |      * 
282 | * 283 | * Protobuf type {@code SInt32Value} 284 | */ 285 | public static final class Builder extends 286 | com.google.protobuf.GeneratedMessageV3.Builder implements 287 | // @@protoc_insertion_point(builder_implements:SInt32Value) 288 | com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32ValueOrBuilder { 289 | public static final com.google.protobuf.Descriptors.Descriptor 290 | getDescriptor() { 291 | return com.blueapron.connect.protobuf.SInt32ValueOuterClass.internal_static_SInt32Value_descriptor; 292 | } 293 | 294 | @java.lang.Override 295 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 296 | internalGetFieldAccessorTable() { 297 | return com.blueapron.connect.protobuf.SInt32ValueOuterClass.internal_static_SInt32Value_fieldAccessorTable 298 | .ensureFieldAccessorsInitialized( 299 | com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value.class, com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value.Builder.class); 300 | } 301 | 302 | // Construct using com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value.newBuilder() 303 | private Builder() { 304 | maybeForceBuilderInitialization(); 305 | } 306 | 307 | private Builder( 308 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 309 | super(parent); 310 | maybeForceBuilderInitialization(); 311 | } 312 | private void maybeForceBuilderInitialization() { 313 | if (com.google.protobuf.GeneratedMessageV3 314 | .alwaysUseFieldBuilders) { 315 | } 316 | } 317 | @java.lang.Override 318 | public Builder clear() { 319 | super.clear(); 320 | value_ = 0; 321 | 322 | return this; 323 | } 324 | 325 | @java.lang.Override 326 | public com.google.protobuf.Descriptors.Descriptor 327 | getDescriptorForType() { 328 | return com.blueapron.connect.protobuf.SInt32ValueOuterClass.internal_static_SInt32Value_descriptor; 329 | } 330 | 331 | @java.lang.Override 332 | public com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value getDefaultInstanceForType() { 333 | return com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value.getDefaultInstance(); 334 | } 335 | 336 | @java.lang.Override 337 | public com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value build() { 338 | com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value result = buildPartial(); 339 | if (!result.isInitialized()) { 340 | throw newUninitializedMessageException(result); 341 | } 342 | return result; 343 | } 344 | 345 | @java.lang.Override 346 | public com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value buildPartial() { 347 | com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value result = new com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value(this); 348 | result.value_ = value_; 349 | onBuilt(); 350 | return result; 351 | } 352 | 353 | @java.lang.Override 354 | public Builder clone() { 355 | return super.clone(); 356 | } 357 | @java.lang.Override 358 | public Builder setField( 359 | com.google.protobuf.Descriptors.FieldDescriptor field, 360 | java.lang.Object value) { 361 | return super.setField(field, value); 362 | } 363 | @java.lang.Override 364 | public Builder clearField( 365 | com.google.protobuf.Descriptors.FieldDescriptor field) { 366 | return super.clearField(field); 367 | } 368 | @java.lang.Override 369 | public Builder clearOneof( 370 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 371 | return super.clearOneof(oneof); 372 | } 373 | @java.lang.Override 374 | public Builder setRepeatedField( 375 | com.google.protobuf.Descriptors.FieldDescriptor field, 376 | int index, java.lang.Object value) { 377 | return super.setRepeatedField(field, index, value); 378 | } 379 | @java.lang.Override 380 | public Builder addRepeatedField( 381 | com.google.protobuf.Descriptors.FieldDescriptor field, 382 | java.lang.Object value) { 383 | return super.addRepeatedField(field, value); 384 | } 385 | @java.lang.Override 386 | public Builder mergeFrom(com.google.protobuf.Message other) { 387 | if (other instanceof com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value) { 388 | return mergeFrom((com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value)other); 389 | } else { 390 | super.mergeFrom(other); 391 | return this; 392 | } 393 | } 394 | 395 | public Builder mergeFrom(com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value other) { 396 | if (other == com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value.getDefaultInstance()) return this; 397 | if (other.getValue() != 0) { 398 | setValue(other.getValue()); 399 | } 400 | this.mergeUnknownFields(other.unknownFields); 401 | onChanged(); 402 | return this; 403 | } 404 | 405 | @java.lang.Override 406 | public final boolean isInitialized() { 407 | return true; 408 | } 409 | 410 | @java.lang.Override 411 | public Builder mergeFrom( 412 | com.google.protobuf.CodedInputStream input, 413 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 414 | throws java.io.IOException { 415 | com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value parsedMessage = null; 416 | try { 417 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 418 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 419 | parsedMessage = (com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value) e.getUnfinishedMessage(); 420 | throw e.unwrapIOException(); 421 | } finally { 422 | if (parsedMessage != null) { 423 | mergeFrom(parsedMessage); 424 | } 425 | } 426 | return this; 427 | } 428 | 429 | private int value_ ; 430 | /** 431 | * sint32 value = 1; 432 | * @return The value. 433 | */ 434 | public int getValue() { 435 | return value_; 436 | } 437 | /** 438 | * sint32 value = 1; 439 | * @param value The value to set. 440 | * @return This builder for chaining. 441 | */ 442 | public Builder setValue(int value) { 443 | 444 | value_ = value; 445 | onChanged(); 446 | return this; 447 | } 448 | /** 449 | * sint32 value = 1; 450 | * @return This builder for chaining. 451 | */ 452 | public Builder clearValue() { 453 | 454 | value_ = 0; 455 | onChanged(); 456 | return this; 457 | } 458 | @java.lang.Override 459 | public final Builder setUnknownFields( 460 | final com.google.protobuf.UnknownFieldSet unknownFields) { 461 | return super.setUnknownFields(unknownFields); 462 | } 463 | 464 | @java.lang.Override 465 | public final Builder mergeUnknownFields( 466 | final com.google.protobuf.UnknownFieldSet unknownFields) { 467 | return super.mergeUnknownFields(unknownFields); 468 | } 469 | 470 | 471 | // @@protoc_insertion_point(builder_scope:SInt32Value) 472 | } 473 | 474 | // @@protoc_insertion_point(class_scope:SInt32Value) 475 | private static final com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value DEFAULT_INSTANCE; 476 | static { 477 | DEFAULT_INSTANCE = new com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value(); 478 | } 479 | 480 | public static com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value getDefaultInstance() { 481 | return DEFAULT_INSTANCE; 482 | } 483 | 484 | private static final com.google.protobuf.Parser 485 | PARSER = new com.google.protobuf.AbstractParser() { 486 | @java.lang.Override 487 | public SInt32Value parsePartialFrom( 488 | com.google.protobuf.CodedInputStream input, 489 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 490 | throws com.google.protobuf.InvalidProtocolBufferException { 491 | return new SInt32Value(input, extensionRegistry); 492 | } 493 | }; 494 | 495 | public static com.google.protobuf.Parser parser() { 496 | return PARSER; 497 | } 498 | 499 | @java.lang.Override 500 | public com.google.protobuf.Parser getParserForType() { 501 | return PARSER; 502 | } 503 | 504 | @java.lang.Override 505 | public com.blueapron.connect.protobuf.SInt32ValueOuterClass.SInt32Value getDefaultInstanceForType() { 506 | return DEFAULT_INSTANCE; 507 | } 508 | 509 | } 510 | 511 | private static final com.google.protobuf.Descriptors.Descriptor 512 | internal_static_SInt32Value_descriptor; 513 | private static final 514 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 515 | internal_static_SInt32Value_fieldAccessorTable; 516 | 517 | public static com.google.protobuf.Descriptors.FileDescriptor 518 | getDescriptor() { 519 | return descriptor; 520 | } 521 | private static com.google.protobuf.Descriptors.FileDescriptor 522 | descriptor; 523 | static { 524 | java.lang.String[] descriptorData = { 525 | "\n\021SInt32Value.proto\"\034\n\013SInt32Value\022\r\n\005va" + 526 | "lue\030\001 \001(\021B \n\036com.blueapron.connect.proto" + 527 | "bufb\006proto3" 528 | }; 529 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 530 | .internalBuildGeneratedFileFrom(descriptorData, 531 | new com.google.protobuf.Descriptors.FileDescriptor[] { 532 | }); 533 | internal_static_SInt32Value_descriptor = 534 | getDescriptor().getMessageTypes().get(0); 535 | internal_static_SInt32Value_fieldAccessorTable = new 536 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 537 | internal_static_SInt32Value_descriptor, 538 | new java.lang.String[] { "Value", }); 539 | } 540 | 541 | // @@protoc_insertion_point(outer_class_scope) 542 | } 543 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/SInt64ValueOuterClass.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: SInt64Value.proto 3 | 4 | package com.blueapron.connect.protobuf; 5 | 6 | public final class SInt64ValueOuterClass { 7 | private SInt64ValueOuterClass() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface SInt64ValueOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:SInt64Value) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | * sint64 value = 1; 23 | * @return The value. 24 | */ 25 | long getValue(); 26 | } 27 | /** 28 | *
 29 |    * Wrapper message for `sint64`.
 30 |    * 
31 | * 32 | * Protobuf type {@code SInt64Value} 33 | */ 34 | public static final class SInt64Value extends 35 | com.google.protobuf.GeneratedMessageV3 implements 36 | // @@protoc_insertion_point(message_implements:SInt64Value) 37 | SInt64ValueOrBuilder { 38 | private static final long serialVersionUID = 0L; 39 | // Use SInt64Value.newBuilder() to construct. 40 | private SInt64Value(com.google.protobuf.GeneratedMessageV3.Builder builder) { 41 | super(builder); 42 | } 43 | private SInt64Value() { 44 | } 45 | 46 | @java.lang.Override 47 | @SuppressWarnings({"unused"}) 48 | protected java.lang.Object newInstance( 49 | UnusedPrivateParameter unused) { 50 | return new SInt64Value(); 51 | } 52 | 53 | @java.lang.Override 54 | public final com.google.protobuf.UnknownFieldSet 55 | getUnknownFields() { 56 | return this.unknownFields; 57 | } 58 | private SInt64Value( 59 | com.google.protobuf.CodedInputStream input, 60 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 61 | throws com.google.protobuf.InvalidProtocolBufferException { 62 | this(); 63 | if (extensionRegistry == null) { 64 | throw new java.lang.NullPointerException(); 65 | } 66 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 67 | com.google.protobuf.UnknownFieldSet.newBuilder(); 68 | try { 69 | boolean done = false; 70 | while (!done) { 71 | int tag = input.readTag(); 72 | switch (tag) { 73 | case 0: 74 | done = true; 75 | break; 76 | case 8: { 77 | 78 | value_ = input.readSInt64(); 79 | break; 80 | } 81 | default: { 82 | if (!parseUnknownField( 83 | input, unknownFields, extensionRegistry, tag)) { 84 | done = true; 85 | } 86 | break; 87 | } 88 | } 89 | } 90 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 91 | throw e.setUnfinishedMessage(this); 92 | } catch (java.io.IOException e) { 93 | throw new com.google.protobuf.InvalidProtocolBufferException( 94 | e).setUnfinishedMessage(this); 95 | } finally { 96 | this.unknownFields = unknownFields.build(); 97 | makeExtensionsImmutable(); 98 | } 99 | } 100 | public static final com.google.protobuf.Descriptors.Descriptor 101 | getDescriptor() { 102 | return com.blueapron.connect.protobuf.SInt64ValueOuterClass.internal_static_SInt64Value_descriptor; 103 | } 104 | 105 | @java.lang.Override 106 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 107 | internalGetFieldAccessorTable() { 108 | return com.blueapron.connect.protobuf.SInt64ValueOuterClass.internal_static_SInt64Value_fieldAccessorTable 109 | .ensureFieldAccessorsInitialized( 110 | com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value.class, com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value.Builder.class); 111 | } 112 | 113 | public static final int VALUE_FIELD_NUMBER = 1; 114 | private long value_; 115 | /** 116 | * sint64 value = 1; 117 | * @return The value. 118 | */ 119 | public long getValue() { 120 | return value_; 121 | } 122 | 123 | private byte memoizedIsInitialized = -1; 124 | @java.lang.Override 125 | public final boolean isInitialized() { 126 | byte isInitialized = memoizedIsInitialized; 127 | if (isInitialized == 1) return true; 128 | if (isInitialized == 0) return false; 129 | 130 | memoizedIsInitialized = 1; 131 | return true; 132 | } 133 | 134 | @java.lang.Override 135 | public void writeTo(com.google.protobuf.CodedOutputStream output) 136 | throws java.io.IOException { 137 | if (value_ != 0L) { 138 | output.writeSInt64(1, value_); 139 | } 140 | unknownFields.writeTo(output); 141 | } 142 | 143 | @java.lang.Override 144 | public int getSerializedSize() { 145 | int size = memoizedSize; 146 | if (size != -1) return size; 147 | 148 | size = 0; 149 | if (value_ != 0L) { 150 | size += com.google.protobuf.CodedOutputStream 151 | .computeSInt64Size(1, value_); 152 | } 153 | size += unknownFields.getSerializedSize(); 154 | memoizedSize = size; 155 | return size; 156 | } 157 | 158 | @java.lang.Override 159 | public boolean equals(final java.lang.Object obj) { 160 | if (obj == this) { 161 | return true; 162 | } 163 | if (!(obj instanceof com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value)) { 164 | return super.equals(obj); 165 | } 166 | com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value other = (com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value) obj; 167 | 168 | if (getValue() 169 | != other.getValue()) return false; 170 | if (!unknownFields.equals(other.unknownFields)) return false; 171 | return true; 172 | } 173 | 174 | @java.lang.Override 175 | public int hashCode() { 176 | if (memoizedHashCode != 0) { 177 | return memoizedHashCode; 178 | } 179 | int hash = 41; 180 | hash = (19 * hash) + getDescriptor().hashCode(); 181 | hash = (37 * hash) + VALUE_FIELD_NUMBER; 182 | hash = (53 * hash) + com.google.protobuf.Internal.hashLong( 183 | getValue()); 184 | hash = (29 * hash) + unknownFields.hashCode(); 185 | memoizedHashCode = hash; 186 | return hash; 187 | } 188 | 189 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom( 190 | java.nio.ByteBuffer data) 191 | throws com.google.protobuf.InvalidProtocolBufferException { 192 | return PARSER.parseFrom(data); 193 | } 194 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom( 195 | java.nio.ByteBuffer data, 196 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 197 | throws com.google.protobuf.InvalidProtocolBufferException { 198 | return PARSER.parseFrom(data, extensionRegistry); 199 | } 200 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom( 201 | com.google.protobuf.ByteString data) 202 | throws com.google.protobuf.InvalidProtocolBufferException { 203 | return PARSER.parseFrom(data); 204 | } 205 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom( 206 | com.google.protobuf.ByteString data, 207 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 208 | throws com.google.protobuf.InvalidProtocolBufferException { 209 | return PARSER.parseFrom(data, extensionRegistry); 210 | } 211 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom(byte[] data) 212 | throws com.google.protobuf.InvalidProtocolBufferException { 213 | return PARSER.parseFrom(data); 214 | } 215 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom( 216 | byte[] data, 217 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 218 | throws com.google.protobuf.InvalidProtocolBufferException { 219 | return PARSER.parseFrom(data, extensionRegistry); 220 | } 221 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom(java.io.InputStream input) 222 | throws java.io.IOException { 223 | return com.google.protobuf.GeneratedMessageV3 224 | .parseWithIOException(PARSER, input); 225 | } 226 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom( 227 | java.io.InputStream input, 228 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 229 | throws java.io.IOException { 230 | return com.google.protobuf.GeneratedMessageV3 231 | .parseWithIOException(PARSER, input, extensionRegistry); 232 | } 233 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseDelimitedFrom(java.io.InputStream input) 234 | throws java.io.IOException { 235 | return com.google.protobuf.GeneratedMessageV3 236 | .parseDelimitedWithIOException(PARSER, input); 237 | } 238 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseDelimitedFrom( 239 | java.io.InputStream input, 240 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 241 | throws java.io.IOException { 242 | return com.google.protobuf.GeneratedMessageV3 243 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 244 | } 245 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom( 246 | com.google.protobuf.CodedInputStream input) 247 | throws java.io.IOException { 248 | return com.google.protobuf.GeneratedMessageV3 249 | .parseWithIOException(PARSER, input); 250 | } 251 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parseFrom( 252 | com.google.protobuf.CodedInputStream input, 253 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 254 | throws java.io.IOException { 255 | return com.google.protobuf.GeneratedMessageV3 256 | .parseWithIOException(PARSER, input, extensionRegistry); 257 | } 258 | 259 | @java.lang.Override 260 | public Builder newBuilderForType() { return newBuilder(); } 261 | public static Builder newBuilder() { 262 | return DEFAULT_INSTANCE.toBuilder(); 263 | } 264 | public static Builder newBuilder(com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value prototype) { 265 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 266 | } 267 | @java.lang.Override 268 | public Builder toBuilder() { 269 | return this == DEFAULT_INSTANCE 270 | ? new Builder() : new Builder().mergeFrom(this); 271 | } 272 | 273 | @java.lang.Override 274 | protected Builder newBuilderForType( 275 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 276 | Builder builder = new Builder(parent); 277 | return builder; 278 | } 279 | /** 280 | *
281 |      * Wrapper message for `sint64`.
282 |      * 
283 | * 284 | * Protobuf type {@code SInt64Value} 285 | */ 286 | public static final class Builder extends 287 | com.google.protobuf.GeneratedMessageV3.Builder implements 288 | // @@protoc_insertion_point(builder_implements:SInt64Value) 289 | com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64ValueOrBuilder { 290 | public static final com.google.protobuf.Descriptors.Descriptor 291 | getDescriptor() { 292 | return com.blueapron.connect.protobuf.SInt64ValueOuterClass.internal_static_SInt64Value_descriptor; 293 | } 294 | 295 | @java.lang.Override 296 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 297 | internalGetFieldAccessorTable() { 298 | return com.blueapron.connect.protobuf.SInt64ValueOuterClass.internal_static_SInt64Value_fieldAccessorTable 299 | .ensureFieldAccessorsInitialized( 300 | com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value.class, com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value.Builder.class); 301 | } 302 | 303 | // Construct using com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value.newBuilder() 304 | private Builder() { 305 | maybeForceBuilderInitialization(); 306 | } 307 | 308 | private Builder( 309 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 310 | super(parent); 311 | maybeForceBuilderInitialization(); 312 | } 313 | private void maybeForceBuilderInitialization() { 314 | if (com.google.protobuf.GeneratedMessageV3 315 | .alwaysUseFieldBuilders) { 316 | } 317 | } 318 | @java.lang.Override 319 | public Builder clear() { 320 | super.clear(); 321 | value_ = 0L; 322 | 323 | return this; 324 | } 325 | 326 | @java.lang.Override 327 | public com.google.protobuf.Descriptors.Descriptor 328 | getDescriptorForType() { 329 | return com.blueapron.connect.protobuf.SInt64ValueOuterClass.internal_static_SInt64Value_descriptor; 330 | } 331 | 332 | @java.lang.Override 333 | public com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value getDefaultInstanceForType() { 334 | return com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value.getDefaultInstance(); 335 | } 336 | 337 | @java.lang.Override 338 | public com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value build() { 339 | com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value result = buildPartial(); 340 | if (!result.isInitialized()) { 341 | throw newUninitializedMessageException(result); 342 | } 343 | return result; 344 | } 345 | 346 | @java.lang.Override 347 | public com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value buildPartial() { 348 | com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value result = new com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value(this); 349 | result.value_ = value_; 350 | onBuilt(); 351 | return result; 352 | } 353 | 354 | @java.lang.Override 355 | public Builder clone() { 356 | return super.clone(); 357 | } 358 | @java.lang.Override 359 | public Builder setField( 360 | com.google.protobuf.Descriptors.FieldDescriptor field, 361 | java.lang.Object value) { 362 | return super.setField(field, value); 363 | } 364 | @java.lang.Override 365 | public Builder clearField( 366 | com.google.protobuf.Descriptors.FieldDescriptor field) { 367 | return super.clearField(field); 368 | } 369 | @java.lang.Override 370 | public Builder clearOneof( 371 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 372 | return super.clearOneof(oneof); 373 | } 374 | @java.lang.Override 375 | public Builder setRepeatedField( 376 | com.google.protobuf.Descriptors.FieldDescriptor field, 377 | int index, java.lang.Object value) { 378 | return super.setRepeatedField(field, index, value); 379 | } 380 | @java.lang.Override 381 | public Builder addRepeatedField( 382 | com.google.protobuf.Descriptors.FieldDescriptor field, 383 | java.lang.Object value) { 384 | return super.addRepeatedField(field, value); 385 | } 386 | @java.lang.Override 387 | public Builder mergeFrom(com.google.protobuf.Message other) { 388 | if (other instanceof com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value) { 389 | return mergeFrom((com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value)other); 390 | } else { 391 | super.mergeFrom(other); 392 | return this; 393 | } 394 | } 395 | 396 | public Builder mergeFrom(com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value other) { 397 | if (other == com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value.getDefaultInstance()) return this; 398 | if (other.getValue() != 0L) { 399 | setValue(other.getValue()); 400 | } 401 | this.mergeUnknownFields(other.unknownFields); 402 | onChanged(); 403 | return this; 404 | } 405 | 406 | @java.lang.Override 407 | public final boolean isInitialized() { 408 | return true; 409 | } 410 | 411 | @java.lang.Override 412 | public Builder mergeFrom( 413 | com.google.protobuf.CodedInputStream input, 414 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 415 | throws java.io.IOException { 416 | com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value parsedMessage = null; 417 | try { 418 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 419 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 420 | parsedMessage = (com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value) e.getUnfinishedMessage(); 421 | throw e.unwrapIOException(); 422 | } finally { 423 | if (parsedMessage != null) { 424 | mergeFrom(parsedMessage); 425 | } 426 | } 427 | return this; 428 | } 429 | 430 | private long value_ ; 431 | /** 432 | * sint64 value = 1; 433 | * @return The value. 434 | */ 435 | public long getValue() { 436 | return value_; 437 | } 438 | /** 439 | * sint64 value = 1; 440 | * @param value The value to set. 441 | * @return This builder for chaining. 442 | */ 443 | public Builder setValue(long value) { 444 | 445 | value_ = value; 446 | onChanged(); 447 | return this; 448 | } 449 | /** 450 | * sint64 value = 1; 451 | * @return This builder for chaining. 452 | */ 453 | public Builder clearValue() { 454 | 455 | value_ = 0L; 456 | onChanged(); 457 | return this; 458 | } 459 | @java.lang.Override 460 | public final Builder setUnknownFields( 461 | final com.google.protobuf.UnknownFieldSet unknownFields) { 462 | return super.setUnknownFields(unknownFields); 463 | } 464 | 465 | @java.lang.Override 466 | public final Builder mergeUnknownFields( 467 | final com.google.protobuf.UnknownFieldSet unknownFields) { 468 | return super.mergeUnknownFields(unknownFields); 469 | } 470 | 471 | 472 | // @@protoc_insertion_point(builder_scope:SInt64Value) 473 | } 474 | 475 | // @@protoc_insertion_point(class_scope:SInt64Value) 476 | private static final com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value DEFAULT_INSTANCE; 477 | static { 478 | DEFAULT_INSTANCE = new com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value(); 479 | } 480 | 481 | public static com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value getDefaultInstance() { 482 | return DEFAULT_INSTANCE; 483 | } 484 | 485 | private static final com.google.protobuf.Parser 486 | PARSER = new com.google.protobuf.AbstractParser() { 487 | @java.lang.Override 488 | public SInt64Value parsePartialFrom( 489 | com.google.protobuf.CodedInputStream input, 490 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 491 | throws com.google.protobuf.InvalidProtocolBufferException { 492 | return new SInt64Value(input, extensionRegistry); 493 | } 494 | }; 495 | 496 | public static com.google.protobuf.Parser parser() { 497 | return PARSER; 498 | } 499 | 500 | @java.lang.Override 501 | public com.google.protobuf.Parser getParserForType() { 502 | return PARSER; 503 | } 504 | 505 | @java.lang.Override 506 | public com.blueapron.connect.protobuf.SInt64ValueOuterClass.SInt64Value getDefaultInstanceForType() { 507 | return DEFAULT_INSTANCE; 508 | } 509 | 510 | } 511 | 512 | private static final com.google.protobuf.Descriptors.Descriptor 513 | internal_static_SInt64Value_descriptor; 514 | private static final 515 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 516 | internal_static_SInt64Value_fieldAccessorTable; 517 | 518 | public static com.google.protobuf.Descriptors.FileDescriptor 519 | getDescriptor() { 520 | return descriptor; 521 | } 522 | private static com.google.protobuf.Descriptors.FileDescriptor 523 | descriptor; 524 | static { 525 | java.lang.String[] descriptorData = { 526 | "\n\021SInt64Value.proto\"\034\n\013SInt64Value\022\r\n\005va" + 527 | "lue\030\001 \001(\022B \n\036com.blueapron.connect.proto" + 528 | "bufb\006proto3" 529 | }; 530 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 531 | .internalBuildGeneratedFileFrom(descriptorData, 532 | new com.google.protobuf.Descriptors.FileDescriptor[] { 533 | }); 534 | internal_static_SInt64Value_descriptor = 535 | getDescriptor().getMessageTypes().get(0); 536 | internal_static_SInt64Value_fieldAccessorTable = new 537 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 538 | internal_static_SInt64Value_descriptor, 539 | new java.lang.String[] { "Value", }); 540 | } 541 | 542 | // @@protoc_insertion_point(outer_class_scope) 543 | } 544 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/UInt64ValueOuterClass.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: UInt64Value.proto 3 | 4 | package com.blueapron.connect.protobuf; 5 | 6 | public final class UInt64ValueOuterClass { 7 | private UInt64ValueOuterClass() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface UInt64ValueOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:UInt64Value) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | * uint64 value = 1; 23 | * @return The value. 24 | */ 25 | long getValue(); 26 | } 27 | /** 28 | *
 29 |    * Wrapper message for `uint64`.
 30 |    * 
31 | * 32 | * Protobuf type {@code UInt64Value} 33 | */ 34 | public static final class UInt64Value extends 35 | com.google.protobuf.GeneratedMessageV3 implements 36 | // @@protoc_insertion_point(message_implements:UInt64Value) 37 | UInt64ValueOrBuilder { 38 | private static final long serialVersionUID = 0L; 39 | // Use UInt64Value.newBuilder() to construct. 40 | private UInt64Value(com.google.protobuf.GeneratedMessageV3.Builder builder) { 41 | super(builder); 42 | } 43 | private UInt64Value() { 44 | } 45 | 46 | @java.lang.Override 47 | @SuppressWarnings({"unused"}) 48 | protected java.lang.Object newInstance( 49 | UnusedPrivateParameter unused) { 50 | return new UInt64Value(); 51 | } 52 | 53 | @java.lang.Override 54 | public final com.google.protobuf.UnknownFieldSet 55 | getUnknownFields() { 56 | return this.unknownFields; 57 | } 58 | private UInt64Value( 59 | com.google.protobuf.CodedInputStream input, 60 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 61 | throws com.google.protobuf.InvalidProtocolBufferException { 62 | this(); 63 | if (extensionRegistry == null) { 64 | throw new java.lang.NullPointerException(); 65 | } 66 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 67 | com.google.protobuf.UnknownFieldSet.newBuilder(); 68 | try { 69 | boolean done = false; 70 | while (!done) { 71 | int tag = input.readTag(); 72 | switch (tag) { 73 | case 0: 74 | done = true; 75 | break; 76 | case 8: { 77 | 78 | value_ = input.readUInt64(); 79 | break; 80 | } 81 | default: { 82 | if (!parseUnknownField( 83 | input, unknownFields, extensionRegistry, tag)) { 84 | done = true; 85 | } 86 | break; 87 | } 88 | } 89 | } 90 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 91 | throw e.setUnfinishedMessage(this); 92 | } catch (java.io.IOException e) { 93 | throw new com.google.protobuf.InvalidProtocolBufferException( 94 | e).setUnfinishedMessage(this); 95 | } finally { 96 | this.unknownFields = unknownFields.build(); 97 | makeExtensionsImmutable(); 98 | } 99 | } 100 | public static final com.google.protobuf.Descriptors.Descriptor 101 | getDescriptor() { 102 | return com.blueapron.connect.protobuf.UInt64ValueOuterClass.internal_static_UInt64Value_descriptor; 103 | } 104 | 105 | @java.lang.Override 106 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 107 | internalGetFieldAccessorTable() { 108 | return com.blueapron.connect.protobuf.UInt64ValueOuterClass.internal_static_UInt64Value_fieldAccessorTable 109 | .ensureFieldAccessorsInitialized( 110 | com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value.class, com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value.Builder.class); 111 | } 112 | 113 | public static final int VALUE_FIELD_NUMBER = 1; 114 | private long value_; 115 | /** 116 | * uint64 value = 1; 117 | * @return The value. 118 | */ 119 | public long getValue() { 120 | return value_; 121 | } 122 | 123 | private byte memoizedIsInitialized = -1; 124 | @java.lang.Override 125 | public final boolean isInitialized() { 126 | byte isInitialized = memoizedIsInitialized; 127 | if (isInitialized == 1) return true; 128 | if (isInitialized == 0) return false; 129 | 130 | memoizedIsInitialized = 1; 131 | return true; 132 | } 133 | 134 | @java.lang.Override 135 | public void writeTo(com.google.protobuf.CodedOutputStream output) 136 | throws java.io.IOException { 137 | if (value_ != 0L) { 138 | output.writeUInt64(1, value_); 139 | } 140 | unknownFields.writeTo(output); 141 | } 142 | 143 | @java.lang.Override 144 | public int getSerializedSize() { 145 | int size = memoizedSize; 146 | if (size != -1) return size; 147 | 148 | size = 0; 149 | if (value_ != 0L) { 150 | size += com.google.protobuf.CodedOutputStream 151 | .computeUInt64Size(1, value_); 152 | } 153 | size += unknownFields.getSerializedSize(); 154 | memoizedSize = size; 155 | return size; 156 | } 157 | 158 | @java.lang.Override 159 | public boolean equals(final java.lang.Object obj) { 160 | if (obj == this) { 161 | return true; 162 | } 163 | if (!(obj instanceof com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value)) { 164 | return super.equals(obj); 165 | } 166 | com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value other = (com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value) obj; 167 | 168 | if (getValue() 169 | != other.getValue()) return false; 170 | if (!unknownFields.equals(other.unknownFields)) return false; 171 | return true; 172 | } 173 | 174 | @java.lang.Override 175 | public int hashCode() { 176 | if (memoizedHashCode != 0) { 177 | return memoizedHashCode; 178 | } 179 | int hash = 41; 180 | hash = (19 * hash) + getDescriptor().hashCode(); 181 | hash = (37 * hash) + VALUE_FIELD_NUMBER; 182 | hash = (53 * hash) + com.google.protobuf.Internal.hashLong( 183 | getValue()); 184 | hash = (29 * hash) + unknownFields.hashCode(); 185 | memoizedHashCode = hash; 186 | return hash; 187 | } 188 | 189 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom( 190 | java.nio.ByteBuffer data) 191 | throws com.google.protobuf.InvalidProtocolBufferException { 192 | return PARSER.parseFrom(data); 193 | } 194 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom( 195 | java.nio.ByteBuffer data, 196 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 197 | throws com.google.protobuf.InvalidProtocolBufferException { 198 | return PARSER.parseFrom(data, extensionRegistry); 199 | } 200 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom( 201 | com.google.protobuf.ByteString data) 202 | throws com.google.protobuf.InvalidProtocolBufferException { 203 | return PARSER.parseFrom(data); 204 | } 205 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom( 206 | com.google.protobuf.ByteString data, 207 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 208 | throws com.google.protobuf.InvalidProtocolBufferException { 209 | return PARSER.parseFrom(data, extensionRegistry); 210 | } 211 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom(byte[] data) 212 | throws com.google.protobuf.InvalidProtocolBufferException { 213 | return PARSER.parseFrom(data); 214 | } 215 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom( 216 | byte[] data, 217 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 218 | throws com.google.protobuf.InvalidProtocolBufferException { 219 | return PARSER.parseFrom(data, extensionRegistry); 220 | } 221 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom(java.io.InputStream input) 222 | throws java.io.IOException { 223 | return com.google.protobuf.GeneratedMessageV3 224 | .parseWithIOException(PARSER, input); 225 | } 226 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom( 227 | java.io.InputStream input, 228 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 229 | throws java.io.IOException { 230 | return com.google.protobuf.GeneratedMessageV3 231 | .parseWithIOException(PARSER, input, extensionRegistry); 232 | } 233 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseDelimitedFrom(java.io.InputStream input) 234 | throws java.io.IOException { 235 | return com.google.protobuf.GeneratedMessageV3 236 | .parseDelimitedWithIOException(PARSER, input); 237 | } 238 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseDelimitedFrom( 239 | java.io.InputStream input, 240 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 241 | throws java.io.IOException { 242 | return com.google.protobuf.GeneratedMessageV3 243 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 244 | } 245 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom( 246 | com.google.protobuf.CodedInputStream input) 247 | throws java.io.IOException { 248 | return com.google.protobuf.GeneratedMessageV3 249 | .parseWithIOException(PARSER, input); 250 | } 251 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parseFrom( 252 | com.google.protobuf.CodedInputStream input, 253 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 254 | throws java.io.IOException { 255 | return com.google.protobuf.GeneratedMessageV3 256 | .parseWithIOException(PARSER, input, extensionRegistry); 257 | } 258 | 259 | @java.lang.Override 260 | public Builder newBuilderForType() { return newBuilder(); } 261 | public static Builder newBuilder() { 262 | return DEFAULT_INSTANCE.toBuilder(); 263 | } 264 | public static Builder newBuilder(com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value prototype) { 265 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 266 | } 267 | @java.lang.Override 268 | public Builder toBuilder() { 269 | return this == DEFAULT_INSTANCE 270 | ? new Builder() : new Builder().mergeFrom(this); 271 | } 272 | 273 | @java.lang.Override 274 | protected Builder newBuilderForType( 275 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 276 | Builder builder = new Builder(parent); 277 | return builder; 278 | } 279 | /** 280 | *
281 |      * Wrapper message for `uint64`.
282 |      * 
283 | * 284 | * Protobuf type {@code UInt64Value} 285 | */ 286 | public static final class Builder extends 287 | com.google.protobuf.GeneratedMessageV3.Builder implements 288 | // @@protoc_insertion_point(builder_implements:UInt64Value) 289 | com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64ValueOrBuilder { 290 | public static final com.google.protobuf.Descriptors.Descriptor 291 | getDescriptor() { 292 | return com.blueapron.connect.protobuf.UInt64ValueOuterClass.internal_static_UInt64Value_descriptor; 293 | } 294 | 295 | @java.lang.Override 296 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 297 | internalGetFieldAccessorTable() { 298 | return com.blueapron.connect.protobuf.UInt64ValueOuterClass.internal_static_UInt64Value_fieldAccessorTable 299 | .ensureFieldAccessorsInitialized( 300 | com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value.class, com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value.Builder.class); 301 | } 302 | 303 | // Construct using com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value.newBuilder() 304 | private Builder() { 305 | maybeForceBuilderInitialization(); 306 | } 307 | 308 | private Builder( 309 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 310 | super(parent); 311 | maybeForceBuilderInitialization(); 312 | } 313 | private void maybeForceBuilderInitialization() { 314 | if (com.google.protobuf.GeneratedMessageV3 315 | .alwaysUseFieldBuilders) { 316 | } 317 | } 318 | @java.lang.Override 319 | public Builder clear() { 320 | super.clear(); 321 | value_ = 0L; 322 | 323 | return this; 324 | } 325 | 326 | @java.lang.Override 327 | public com.google.protobuf.Descriptors.Descriptor 328 | getDescriptorForType() { 329 | return com.blueapron.connect.protobuf.UInt64ValueOuterClass.internal_static_UInt64Value_descriptor; 330 | } 331 | 332 | @java.lang.Override 333 | public com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value getDefaultInstanceForType() { 334 | return com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value.getDefaultInstance(); 335 | } 336 | 337 | @java.lang.Override 338 | public com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value build() { 339 | com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value result = buildPartial(); 340 | if (!result.isInitialized()) { 341 | throw newUninitializedMessageException(result); 342 | } 343 | return result; 344 | } 345 | 346 | @java.lang.Override 347 | public com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value buildPartial() { 348 | com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value result = new com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value(this); 349 | result.value_ = value_; 350 | onBuilt(); 351 | return result; 352 | } 353 | 354 | @java.lang.Override 355 | public Builder clone() { 356 | return super.clone(); 357 | } 358 | @java.lang.Override 359 | public Builder setField( 360 | com.google.protobuf.Descriptors.FieldDescriptor field, 361 | java.lang.Object value) { 362 | return super.setField(field, value); 363 | } 364 | @java.lang.Override 365 | public Builder clearField( 366 | com.google.protobuf.Descriptors.FieldDescriptor field) { 367 | return super.clearField(field); 368 | } 369 | @java.lang.Override 370 | public Builder clearOneof( 371 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 372 | return super.clearOneof(oneof); 373 | } 374 | @java.lang.Override 375 | public Builder setRepeatedField( 376 | com.google.protobuf.Descriptors.FieldDescriptor field, 377 | int index, java.lang.Object value) { 378 | return super.setRepeatedField(field, index, value); 379 | } 380 | @java.lang.Override 381 | public Builder addRepeatedField( 382 | com.google.protobuf.Descriptors.FieldDescriptor field, 383 | java.lang.Object value) { 384 | return super.addRepeatedField(field, value); 385 | } 386 | @java.lang.Override 387 | public Builder mergeFrom(com.google.protobuf.Message other) { 388 | if (other instanceof com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value) { 389 | return mergeFrom((com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value)other); 390 | } else { 391 | super.mergeFrom(other); 392 | return this; 393 | } 394 | } 395 | 396 | public Builder mergeFrom(com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value other) { 397 | if (other == com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value.getDefaultInstance()) return this; 398 | if (other.getValue() != 0L) { 399 | setValue(other.getValue()); 400 | } 401 | this.mergeUnknownFields(other.unknownFields); 402 | onChanged(); 403 | return this; 404 | } 405 | 406 | @java.lang.Override 407 | public final boolean isInitialized() { 408 | return true; 409 | } 410 | 411 | @java.lang.Override 412 | public Builder mergeFrom( 413 | com.google.protobuf.CodedInputStream input, 414 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 415 | throws java.io.IOException { 416 | com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value parsedMessage = null; 417 | try { 418 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 419 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 420 | parsedMessage = (com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value) e.getUnfinishedMessage(); 421 | throw e.unwrapIOException(); 422 | } finally { 423 | if (parsedMessage != null) { 424 | mergeFrom(parsedMessage); 425 | } 426 | } 427 | return this; 428 | } 429 | 430 | private long value_ ; 431 | /** 432 | * uint64 value = 1; 433 | * @return The value. 434 | */ 435 | public long getValue() { 436 | return value_; 437 | } 438 | /** 439 | * uint64 value = 1; 440 | * @param value The value to set. 441 | * @return This builder for chaining. 442 | */ 443 | public Builder setValue(long value) { 444 | 445 | value_ = value; 446 | onChanged(); 447 | return this; 448 | } 449 | /** 450 | * uint64 value = 1; 451 | * @return This builder for chaining. 452 | */ 453 | public Builder clearValue() { 454 | 455 | value_ = 0L; 456 | onChanged(); 457 | return this; 458 | } 459 | @java.lang.Override 460 | public final Builder setUnknownFields( 461 | final com.google.protobuf.UnknownFieldSet unknownFields) { 462 | return super.setUnknownFields(unknownFields); 463 | } 464 | 465 | @java.lang.Override 466 | public final Builder mergeUnknownFields( 467 | final com.google.protobuf.UnknownFieldSet unknownFields) { 468 | return super.mergeUnknownFields(unknownFields); 469 | } 470 | 471 | 472 | // @@protoc_insertion_point(builder_scope:UInt64Value) 473 | } 474 | 475 | // @@protoc_insertion_point(class_scope:UInt64Value) 476 | private static final com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value DEFAULT_INSTANCE; 477 | static { 478 | DEFAULT_INSTANCE = new com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value(); 479 | } 480 | 481 | public static com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value getDefaultInstance() { 482 | return DEFAULT_INSTANCE; 483 | } 484 | 485 | private static final com.google.protobuf.Parser 486 | PARSER = new com.google.protobuf.AbstractParser() { 487 | @java.lang.Override 488 | public UInt64Value parsePartialFrom( 489 | com.google.protobuf.CodedInputStream input, 490 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 491 | throws com.google.protobuf.InvalidProtocolBufferException { 492 | return new UInt64Value(input, extensionRegistry); 493 | } 494 | }; 495 | 496 | public static com.google.protobuf.Parser parser() { 497 | return PARSER; 498 | } 499 | 500 | @java.lang.Override 501 | public com.google.protobuf.Parser getParserForType() { 502 | return PARSER; 503 | } 504 | 505 | @java.lang.Override 506 | public com.blueapron.connect.protobuf.UInt64ValueOuterClass.UInt64Value getDefaultInstanceForType() { 507 | return DEFAULT_INSTANCE; 508 | } 509 | 510 | } 511 | 512 | private static final com.google.protobuf.Descriptors.Descriptor 513 | internal_static_UInt64Value_descriptor; 514 | private static final 515 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 516 | internal_static_UInt64Value_fieldAccessorTable; 517 | 518 | public static com.google.protobuf.Descriptors.FileDescriptor 519 | getDescriptor() { 520 | return descriptor; 521 | } 522 | private static com.google.protobuf.Descriptors.FileDescriptor 523 | descriptor; 524 | static { 525 | java.lang.String[] descriptorData = { 526 | "\n\021UInt64Value.proto\"\034\n\013UInt64Value\022\r\n\005va" + 527 | "lue\030\001 \001(\004B \n\036com.blueapron.connect.proto" + 528 | "bufb\006proto3" 529 | }; 530 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 531 | .internalBuildGeneratedFileFrom(descriptorData, 532 | new com.google.protobuf.Descriptors.FileDescriptor[] { 533 | }); 534 | internal_static_UInt64Value_descriptor = 535 | getDescriptor().getMessageTypes().get(0); 536 | internal_static_UInt64Value_fieldAccessorTable = new 537 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 538 | internal_static_UInt64Value_descriptor, 539 | new java.lang.String[] { "Value", }); 540 | } 541 | 542 | // @@protoc_insertion_point(outer_class_scope) 543 | } 544 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/BytesValueOuterClass.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: BytesValue.proto 3 | 4 | package com.blueapron.connect.protobuf; 5 | 6 | public final class BytesValueOuterClass { 7 | private BytesValueOuterClass() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface BytesValueOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:BytesValue) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | * bytes value = 1; 23 | * @return The value. 24 | */ 25 | com.google.protobuf.ByteString getValue(); 26 | } 27 | /** 28 | * Protobuf type {@code BytesValue} 29 | */ 30 | public static final class BytesValue extends 31 | com.google.protobuf.GeneratedMessageV3 implements 32 | // @@protoc_insertion_point(message_implements:BytesValue) 33 | BytesValueOrBuilder { 34 | private static final long serialVersionUID = 0L; 35 | // Use BytesValue.newBuilder() to construct. 36 | private BytesValue(com.google.protobuf.GeneratedMessageV3.Builder builder) { 37 | super(builder); 38 | } 39 | private BytesValue() { 40 | value_ = com.google.protobuf.ByteString.EMPTY; 41 | } 42 | 43 | @java.lang.Override 44 | @SuppressWarnings({"unused"}) 45 | protected java.lang.Object newInstance( 46 | UnusedPrivateParameter unused) { 47 | return new BytesValue(); 48 | } 49 | 50 | @java.lang.Override 51 | public final com.google.protobuf.UnknownFieldSet 52 | getUnknownFields() { 53 | return this.unknownFields; 54 | } 55 | private BytesValue( 56 | com.google.protobuf.CodedInputStream input, 57 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 58 | throws com.google.protobuf.InvalidProtocolBufferException { 59 | this(); 60 | if (extensionRegistry == null) { 61 | throw new java.lang.NullPointerException(); 62 | } 63 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 64 | com.google.protobuf.UnknownFieldSet.newBuilder(); 65 | try { 66 | boolean done = false; 67 | while (!done) { 68 | int tag = input.readTag(); 69 | switch (tag) { 70 | case 0: 71 | done = true; 72 | break; 73 | case 10: { 74 | 75 | value_ = input.readBytes(); 76 | break; 77 | } 78 | default: { 79 | if (!parseUnknownField( 80 | input, unknownFields, extensionRegistry, tag)) { 81 | done = true; 82 | } 83 | break; 84 | } 85 | } 86 | } 87 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 88 | throw e.setUnfinishedMessage(this); 89 | } catch (java.io.IOException e) { 90 | throw new com.google.protobuf.InvalidProtocolBufferException( 91 | e).setUnfinishedMessage(this); 92 | } finally { 93 | this.unknownFields = unknownFields.build(); 94 | makeExtensionsImmutable(); 95 | } 96 | } 97 | public static final com.google.protobuf.Descriptors.Descriptor 98 | getDescriptor() { 99 | return com.blueapron.connect.protobuf.BytesValueOuterClass.internal_static_BytesValue_descriptor; 100 | } 101 | 102 | @java.lang.Override 103 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 104 | internalGetFieldAccessorTable() { 105 | return com.blueapron.connect.protobuf.BytesValueOuterClass.internal_static_BytesValue_fieldAccessorTable 106 | .ensureFieldAccessorsInitialized( 107 | com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue.class, com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue.Builder.class); 108 | } 109 | 110 | public static final int VALUE_FIELD_NUMBER = 1; 111 | private com.google.protobuf.ByteString value_; 112 | /** 113 | * bytes value = 1; 114 | * @return The value. 115 | */ 116 | public com.google.protobuf.ByteString getValue() { 117 | return value_; 118 | } 119 | 120 | private byte memoizedIsInitialized = -1; 121 | @java.lang.Override 122 | public final boolean isInitialized() { 123 | byte isInitialized = memoizedIsInitialized; 124 | if (isInitialized == 1) return true; 125 | if (isInitialized == 0) return false; 126 | 127 | memoizedIsInitialized = 1; 128 | return true; 129 | } 130 | 131 | @java.lang.Override 132 | public void writeTo(com.google.protobuf.CodedOutputStream output) 133 | throws java.io.IOException { 134 | if (!value_.isEmpty()) { 135 | output.writeBytes(1, value_); 136 | } 137 | unknownFields.writeTo(output); 138 | } 139 | 140 | @java.lang.Override 141 | public int getSerializedSize() { 142 | int size = memoizedSize; 143 | if (size != -1) return size; 144 | 145 | size = 0; 146 | if (!value_.isEmpty()) { 147 | size += com.google.protobuf.CodedOutputStream 148 | .computeBytesSize(1, value_); 149 | } 150 | size += unknownFields.getSerializedSize(); 151 | memoizedSize = size; 152 | return size; 153 | } 154 | 155 | @java.lang.Override 156 | public boolean equals(final java.lang.Object obj) { 157 | if (obj == this) { 158 | return true; 159 | } 160 | if (!(obj instanceof com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue)) { 161 | return super.equals(obj); 162 | } 163 | com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue other = (com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue) obj; 164 | 165 | if (!getValue() 166 | .equals(other.getValue())) return false; 167 | if (!unknownFields.equals(other.unknownFields)) return false; 168 | return true; 169 | } 170 | 171 | @java.lang.Override 172 | public int hashCode() { 173 | if (memoizedHashCode != 0) { 174 | return memoizedHashCode; 175 | } 176 | int hash = 41; 177 | hash = (19 * hash) + getDescriptor().hashCode(); 178 | hash = (37 * hash) + VALUE_FIELD_NUMBER; 179 | hash = (53 * hash) + getValue().hashCode(); 180 | hash = (29 * hash) + unknownFields.hashCode(); 181 | memoizedHashCode = hash; 182 | return hash; 183 | } 184 | 185 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom( 186 | java.nio.ByteBuffer data) 187 | throws com.google.protobuf.InvalidProtocolBufferException { 188 | return PARSER.parseFrom(data); 189 | } 190 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom( 191 | java.nio.ByteBuffer data, 192 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 193 | throws com.google.protobuf.InvalidProtocolBufferException { 194 | return PARSER.parseFrom(data, extensionRegistry); 195 | } 196 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom( 197 | com.google.protobuf.ByteString data) 198 | throws com.google.protobuf.InvalidProtocolBufferException { 199 | return PARSER.parseFrom(data); 200 | } 201 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom( 202 | com.google.protobuf.ByteString data, 203 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 204 | throws com.google.protobuf.InvalidProtocolBufferException { 205 | return PARSER.parseFrom(data, extensionRegistry); 206 | } 207 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom(byte[] data) 208 | throws com.google.protobuf.InvalidProtocolBufferException { 209 | return PARSER.parseFrom(data); 210 | } 211 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom( 212 | byte[] data, 213 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 214 | throws com.google.protobuf.InvalidProtocolBufferException { 215 | return PARSER.parseFrom(data, extensionRegistry); 216 | } 217 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom(java.io.InputStream input) 218 | throws java.io.IOException { 219 | return com.google.protobuf.GeneratedMessageV3 220 | .parseWithIOException(PARSER, input); 221 | } 222 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom( 223 | java.io.InputStream input, 224 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 225 | throws java.io.IOException { 226 | return com.google.protobuf.GeneratedMessageV3 227 | .parseWithIOException(PARSER, input, extensionRegistry); 228 | } 229 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseDelimitedFrom(java.io.InputStream input) 230 | throws java.io.IOException { 231 | return com.google.protobuf.GeneratedMessageV3 232 | .parseDelimitedWithIOException(PARSER, input); 233 | } 234 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseDelimitedFrom( 235 | java.io.InputStream input, 236 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 237 | throws java.io.IOException { 238 | return com.google.protobuf.GeneratedMessageV3 239 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 240 | } 241 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom( 242 | com.google.protobuf.CodedInputStream input) 243 | throws java.io.IOException { 244 | return com.google.protobuf.GeneratedMessageV3 245 | .parseWithIOException(PARSER, input); 246 | } 247 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parseFrom( 248 | com.google.protobuf.CodedInputStream input, 249 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 250 | throws java.io.IOException { 251 | return com.google.protobuf.GeneratedMessageV3 252 | .parseWithIOException(PARSER, input, extensionRegistry); 253 | } 254 | 255 | @java.lang.Override 256 | public Builder newBuilderForType() { return newBuilder(); } 257 | public static Builder newBuilder() { 258 | return DEFAULT_INSTANCE.toBuilder(); 259 | } 260 | public static Builder newBuilder(com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue prototype) { 261 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 262 | } 263 | @java.lang.Override 264 | public Builder toBuilder() { 265 | return this == DEFAULT_INSTANCE 266 | ? new Builder() : new Builder().mergeFrom(this); 267 | } 268 | 269 | @java.lang.Override 270 | protected Builder newBuilderForType( 271 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 272 | Builder builder = new Builder(parent); 273 | return builder; 274 | } 275 | /** 276 | * Protobuf type {@code BytesValue} 277 | */ 278 | public static final class Builder extends 279 | com.google.protobuf.GeneratedMessageV3.Builder implements 280 | // @@protoc_insertion_point(builder_implements:BytesValue) 281 | com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValueOrBuilder { 282 | public static final com.google.protobuf.Descriptors.Descriptor 283 | getDescriptor() { 284 | return com.blueapron.connect.protobuf.BytesValueOuterClass.internal_static_BytesValue_descriptor; 285 | } 286 | 287 | @java.lang.Override 288 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 289 | internalGetFieldAccessorTable() { 290 | return com.blueapron.connect.protobuf.BytesValueOuterClass.internal_static_BytesValue_fieldAccessorTable 291 | .ensureFieldAccessorsInitialized( 292 | com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue.class, com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue.Builder.class); 293 | } 294 | 295 | // Construct using com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue.newBuilder() 296 | private Builder() { 297 | maybeForceBuilderInitialization(); 298 | } 299 | 300 | private Builder( 301 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 302 | super(parent); 303 | maybeForceBuilderInitialization(); 304 | } 305 | private void maybeForceBuilderInitialization() { 306 | if (com.google.protobuf.GeneratedMessageV3 307 | .alwaysUseFieldBuilders) { 308 | } 309 | } 310 | @java.lang.Override 311 | public Builder clear() { 312 | super.clear(); 313 | value_ = com.google.protobuf.ByteString.EMPTY; 314 | 315 | return this; 316 | } 317 | 318 | @java.lang.Override 319 | public com.google.protobuf.Descriptors.Descriptor 320 | getDescriptorForType() { 321 | return com.blueapron.connect.protobuf.BytesValueOuterClass.internal_static_BytesValue_descriptor; 322 | } 323 | 324 | @java.lang.Override 325 | public com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue getDefaultInstanceForType() { 326 | return com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue.getDefaultInstance(); 327 | } 328 | 329 | @java.lang.Override 330 | public com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue build() { 331 | com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue result = buildPartial(); 332 | if (!result.isInitialized()) { 333 | throw newUninitializedMessageException(result); 334 | } 335 | return result; 336 | } 337 | 338 | @java.lang.Override 339 | public com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue buildPartial() { 340 | com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue result = new com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue(this); 341 | result.value_ = value_; 342 | onBuilt(); 343 | return result; 344 | } 345 | 346 | @java.lang.Override 347 | public Builder clone() { 348 | return super.clone(); 349 | } 350 | @java.lang.Override 351 | public Builder setField( 352 | com.google.protobuf.Descriptors.FieldDescriptor field, 353 | java.lang.Object value) { 354 | return super.setField(field, value); 355 | } 356 | @java.lang.Override 357 | public Builder clearField( 358 | com.google.protobuf.Descriptors.FieldDescriptor field) { 359 | return super.clearField(field); 360 | } 361 | @java.lang.Override 362 | public Builder clearOneof( 363 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 364 | return super.clearOneof(oneof); 365 | } 366 | @java.lang.Override 367 | public Builder setRepeatedField( 368 | com.google.protobuf.Descriptors.FieldDescriptor field, 369 | int index, java.lang.Object value) { 370 | return super.setRepeatedField(field, index, value); 371 | } 372 | @java.lang.Override 373 | public Builder addRepeatedField( 374 | com.google.protobuf.Descriptors.FieldDescriptor field, 375 | java.lang.Object value) { 376 | return super.addRepeatedField(field, value); 377 | } 378 | @java.lang.Override 379 | public Builder mergeFrom(com.google.protobuf.Message other) { 380 | if (other instanceof com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue) { 381 | return mergeFrom((com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue)other); 382 | } else { 383 | super.mergeFrom(other); 384 | return this; 385 | } 386 | } 387 | 388 | public Builder mergeFrom(com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue other) { 389 | if (other == com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue.getDefaultInstance()) return this; 390 | if (other.getValue() != com.google.protobuf.ByteString.EMPTY) { 391 | setValue(other.getValue()); 392 | } 393 | this.mergeUnknownFields(other.unknownFields); 394 | onChanged(); 395 | return this; 396 | } 397 | 398 | @java.lang.Override 399 | public final boolean isInitialized() { 400 | return true; 401 | } 402 | 403 | @java.lang.Override 404 | public Builder mergeFrom( 405 | com.google.protobuf.CodedInputStream input, 406 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 407 | throws java.io.IOException { 408 | com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue parsedMessage = null; 409 | try { 410 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 411 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 412 | parsedMessage = (com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue) e.getUnfinishedMessage(); 413 | throw e.unwrapIOException(); 414 | } finally { 415 | if (parsedMessage != null) { 416 | mergeFrom(parsedMessage); 417 | } 418 | } 419 | return this; 420 | } 421 | 422 | private com.google.protobuf.ByteString value_ = com.google.protobuf.ByteString.EMPTY; 423 | /** 424 | * bytes value = 1; 425 | * @return The value. 426 | */ 427 | public com.google.protobuf.ByteString getValue() { 428 | return value_; 429 | } 430 | /** 431 | * bytes value = 1; 432 | * @param value The value to set. 433 | * @return This builder for chaining. 434 | */ 435 | public Builder setValue(com.google.protobuf.ByteString value) { 436 | if (value == null) { 437 | throw new NullPointerException(); 438 | } 439 | 440 | value_ = value; 441 | onChanged(); 442 | return this; 443 | } 444 | /** 445 | * bytes value = 1; 446 | * @return This builder for chaining. 447 | */ 448 | public Builder clearValue() { 449 | 450 | value_ = getDefaultInstance().getValue(); 451 | onChanged(); 452 | return this; 453 | } 454 | @java.lang.Override 455 | public final Builder setUnknownFields( 456 | final com.google.protobuf.UnknownFieldSet unknownFields) { 457 | return super.setUnknownFields(unknownFields); 458 | } 459 | 460 | @java.lang.Override 461 | public final Builder mergeUnknownFields( 462 | final com.google.protobuf.UnknownFieldSet unknownFields) { 463 | return super.mergeUnknownFields(unknownFields); 464 | } 465 | 466 | 467 | // @@protoc_insertion_point(builder_scope:BytesValue) 468 | } 469 | 470 | // @@protoc_insertion_point(class_scope:BytesValue) 471 | private static final com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue DEFAULT_INSTANCE; 472 | static { 473 | DEFAULT_INSTANCE = new com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue(); 474 | } 475 | 476 | public static com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue getDefaultInstance() { 477 | return DEFAULT_INSTANCE; 478 | } 479 | 480 | private static final com.google.protobuf.Parser 481 | PARSER = new com.google.protobuf.AbstractParser() { 482 | @java.lang.Override 483 | public BytesValue parsePartialFrom( 484 | com.google.protobuf.CodedInputStream input, 485 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 486 | throws com.google.protobuf.InvalidProtocolBufferException { 487 | return new BytesValue(input, extensionRegistry); 488 | } 489 | }; 490 | 491 | public static com.google.protobuf.Parser parser() { 492 | return PARSER; 493 | } 494 | 495 | @java.lang.Override 496 | public com.google.protobuf.Parser getParserForType() { 497 | return PARSER; 498 | } 499 | 500 | @java.lang.Override 501 | public com.blueapron.connect.protobuf.BytesValueOuterClass.BytesValue getDefaultInstanceForType() { 502 | return DEFAULT_INSTANCE; 503 | } 504 | 505 | } 506 | 507 | private static final com.google.protobuf.Descriptors.Descriptor 508 | internal_static_BytesValue_descriptor; 509 | private static final 510 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 511 | internal_static_BytesValue_fieldAccessorTable; 512 | 513 | public static com.google.protobuf.Descriptors.FileDescriptor 514 | getDescriptor() { 515 | return descriptor; 516 | } 517 | private static com.google.protobuf.Descriptors.FileDescriptor 518 | descriptor; 519 | static { 520 | java.lang.String[] descriptorData = { 521 | "\n\020BytesValue.proto\"\033\n\nBytesValue\022\r\n\005valu" + 522 | "e\030\001 \001(\014B \n\036com.blueapron.connect.protobu" + 523 | "fb\006proto3" 524 | }; 525 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 526 | .internalBuildGeneratedFileFrom(descriptorData, 527 | new com.google.protobuf.Descriptors.FileDescriptor[] { 528 | }); 529 | internal_static_BytesValue_descriptor = 530 | getDescriptor().getMessageTypes().get(0); 531 | internal_static_BytesValue_fieldAccessorTable = new 532 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 533 | internal_static_BytesValue_descriptor, 534 | new java.lang.String[] { "Value", }); 535 | } 536 | 537 | // @@protoc_insertion_point(outer_class_scope) 538 | } 539 | -------------------------------------------------------------------------------- /src/test/java/com/blueapron/connect/protobuf/DateValueOuterClass.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: DateValue.proto 3 | 4 | package com.blueapron.connect.protobuf; 5 | 6 | public final class DateValueOuterClass { 7 | private DateValueOuterClass() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface DateValueOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:DateValue) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | *
 23 |      * The bytes value.
 24 |      * 
25 | * 26 | * .google.type.Date value = 1; 27 | * @return Whether the value field is set. 28 | */ 29 | boolean hasValue(); 30 | /** 31 | *
 32 |      * The bytes value.
 33 |      * 
34 | * 35 | * .google.type.Date value = 1; 36 | * @return The value. 37 | */ 38 | com.google.type.Date getValue(); 39 | /** 40 | *
 41 |      * The bytes value.
 42 |      * 
43 | * 44 | * .google.type.Date value = 1; 45 | */ 46 | com.google.type.DateOrBuilder getValueOrBuilder(); 47 | } 48 | /** 49 | *
 50 |    * Wrapper message for `Date`.
 51 |    * 
52 | * 53 | * Protobuf type {@code DateValue} 54 | */ 55 | public static final class DateValue extends 56 | com.google.protobuf.GeneratedMessageV3 implements 57 | // @@protoc_insertion_point(message_implements:DateValue) 58 | DateValueOrBuilder { 59 | private static final long serialVersionUID = 0L; 60 | // Use DateValue.newBuilder() to construct. 61 | private DateValue(com.google.protobuf.GeneratedMessageV3.Builder builder) { 62 | super(builder); 63 | } 64 | private DateValue() { 65 | } 66 | 67 | @java.lang.Override 68 | @SuppressWarnings({"unused"}) 69 | protected java.lang.Object newInstance( 70 | UnusedPrivateParameter unused) { 71 | return new DateValue(); 72 | } 73 | 74 | @java.lang.Override 75 | public final com.google.protobuf.UnknownFieldSet 76 | getUnknownFields() { 77 | return this.unknownFields; 78 | } 79 | private DateValue( 80 | com.google.protobuf.CodedInputStream input, 81 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 82 | throws com.google.protobuf.InvalidProtocolBufferException { 83 | this(); 84 | if (extensionRegistry == null) { 85 | throw new java.lang.NullPointerException(); 86 | } 87 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 88 | com.google.protobuf.UnknownFieldSet.newBuilder(); 89 | try { 90 | boolean done = false; 91 | while (!done) { 92 | int tag = input.readTag(); 93 | switch (tag) { 94 | case 0: 95 | done = true; 96 | break; 97 | case 10: { 98 | com.google.type.Date.Builder subBuilder = null; 99 | if (value_ != null) { 100 | subBuilder = value_.toBuilder(); 101 | } 102 | value_ = input.readMessage(com.google.type.Date.parser(), extensionRegistry); 103 | if (subBuilder != null) { 104 | subBuilder.mergeFrom(value_); 105 | value_ = subBuilder.buildPartial(); 106 | } 107 | 108 | break; 109 | } 110 | default: { 111 | if (!parseUnknownField( 112 | input, unknownFields, extensionRegistry, tag)) { 113 | done = true; 114 | } 115 | break; 116 | } 117 | } 118 | } 119 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 120 | throw e.setUnfinishedMessage(this); 121 | } catch (java.io.IOException e) { 122 | throw new com.google.protobuf.InvalidProtocolBufferException( 123 | e).setUnfinishedMessage(this); 124 | } finally { 125 | this.unknownFields = unknownFields.build(); 126 | makeExtensionsImmutable(); 127 | } 128 | } 129 | public static final com.google.protobuf.Descriptors.Descriptor 130 | getDescriptor() { 131 | return com.blueapron.connect.protobuf.DateValueOuterClass.internal_static_DateValue_descriptor; 132 | } 133 | 134 | @java.lang.Override 135 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 136 | internalGetFieldAccessorTable() { 137 | return com.blueapron.connect.protobuf.DateValueOuterClass.internal_static_DateValue_fieldAccessorTable 138 | .ensureFieldAccessorsInitialized( 139 | com.blueapron.connect.protobuf.DateValueOuterClass.DateValue.class, com.blueapron.connect.protobuf.DateValueOuterClass.DateValue.Builder.class); 140 | } 141 | 142 | public static final int VALUE_FIELD_NUMBER = 1; 143 | private com.google.type.Date value_; 144 | /** 145 | *
146 |      * The bytes value.
147 |      * 
148 | * 149 | * .google.type.Date value = 1; 150 | * @return Whether the value field is set. 151 | */ 152 | public boolean hasValue() { 153 | return value_ != null; 154 | } 155 | /** 156 | *
157 |      * The bytes value.
158 |      * 
159 | * 160 | * .google.type.Date value = 1; 161 | * @return The value. 162 | */ 163 | public com.google.type.Date getValue() { 164 | return value_ == null ? com.google.type.Date.getDefaultInstance() : value_; 165 | } 166 | /** 167 | *
168 |      * The bytes value.
169 |      * 
170 | * 171 | * .google.type.Date value = 1; 172 | */ 173 | public com.google.type.DateOrBuilder getValueOrBuilder() { 174 | return getValue(); 175 | } 176 | 177 | private byte memoizedIsInitialized = -1; 178 | @java.lang.Override 179 | public final boolean isInitialized() { 180 | byte isInitialized = memoizedIsInitialized; 181 | if (isInitialized == 1) return true; 182 | if (isInitialized == 0) return false; 183 | 184 | memoizedIsInitialized = 1; 185 | return true; 186 | } 187 | 188 | @java.lang.Override 189 | public void writeTo(com.google.protobuf.CodedOutputStream output) 190 | throws java.io.IOException { 191 | if (value_ != null) { 192 | output.writeMessage(1, getValue()); 193 | } 194 | unknownFields.writeTo(output); 195 | } 196 | 197 | @java.lang.Override 198 | public int getSerializedSize() { 199 | int size = memoizedSize; 200 | if (size != -1) return size; 201 | 202 | size = 0; 203 | if (value_ != null) { 204 | size += com.google.protobuf.CodedOutputStream 205 | .computeMessageSize(1, getValue()); 206 | } 207 | size += unknownFields.getSerializedSize(); 208 | memoizedSize = size; 209 | return size; 210 | } 211 | 212 | @java.lang.Override 213 | public boolean equals(final java.lang.Object obj) { 214 | if (obj == this) { 215 | return true; 216 | } 217 | if (!(obj instanceof com.blueapron.connect.protobuf.DateValueOuterClass.DateValue)) { 218 | return super.equals(obj); 219 | } 220 | com.blueapron.connect.protobuf.DateValueOuterClass.DateValue other = (com.blueapron.connect.protobuf.DateValueOuterClass.DateValue) obj; 221 | 222 | if (hasValue() != other.hasValue()) return false; 223 | if (hasValue()) { 224 | if (!getValue() 225 | .equals(other.getValue())) return false; 226 | } 227 | if (!unknownFields.equals(other.unknownFields)) return false; 228 | return true; 229 | } 230 | 231 | @java.lang.Override 232 | public int hashCode() { 233 | if (memoizedHashCode != 0) { 234 | return memoizedHashCode; 235 | } 236 | int hash = 41; 237 | hash = (19 * hash) + getDescriptor().hashCode(); 238 | if (hasValue()) { 239 | hash = (37 * hash) + VALUE_FIELD_NUMBER; 240 | hash = (53 * hash) + getValue().hashCode(); 241 | } 242 | hash = (29 * hash) + unknownFields.hashCode(); 243 | memoizedHashCode = hash; 244 | return hash; 245 | } 246 | 247 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom( 248 | java.nio.ByteBuffer data) 249 | throws com.google.protobuf.InvalidProtocolBufferException { 250 | return PARSER.parseFrom(data); 251 | } 252 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom( 253 | java.nio.ByteBuffer data, 254 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 255 | throws com.google.protobuf.InvalidProtocolBufferException { 256 | return PARSER.parseFrom(data, extensionRegistry); 257 | } 258 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom( 259 | com.google.protobuf.ByteString data) 260 | throws com.google.protobuf.InvalidProtocolBufferException { 261 | return PARSER.parseFrom(data); 262 | } 263 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom( 264 | com.google.protobuf.ByteString data, 265 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 266 | throws com.google.protobuf.InvalidProtocolBufferException { 267 | return PARSER.parseFrom(data, extensionRegistry); 268 | } 269 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom(byte[] data) 270 | throws com.google.protobuf.InvalidProtocolBufferException { 271 | return PARSER.parseFrom(data); 272 | } 273 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom( 274 | byte[] data, 275 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 276 | throws com.google.protobuf.InvalidProtocolBufferException { 277 | return PARSER.parseFrom(data, extensionRegistry); 278 | } 279 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom(java.io.InputStream input) 280 | throws java.io.IOException { 281 | return com.google.protobuf.GeneratedMessageV3 282 | .parseWithIOException(PARSER, input); 283 | } 284 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom( 285 | java.io.InputStream input, 286 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 287 | throws java.io.IOException { 288 | return com.google.protobuf.GeneratedMessageV3 289 | .parseWithIOException(PARSER, input, extensionRegistry); 290 | } 291 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseDelimitedFrom(java.io.InputStream input) 292 | throws java.io.IOException { 293 | return com.google.protobuf.GeneratedMessageV3 294 | .parseDelimitedWithIOException(PARSER, input); 295 | } 296 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseDelimitedFrom( 297 | java.io.InputStream input, 298 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 299 | throws java.io.IOException { 300 | return com.google.protobuf.GeneratedMessageV3 301 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 302 | } 303 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom( 304 | com.google.protobuf.CodedInputStream input) 305 | throws java.io.IOException { 306 | return com.google.protobuf.GeneratedMessageV3 307 | .parseWithIOException(PARSER, input); 308 | } 309 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parseFrom( 310 | com.google.protobuf.CodedInputStream input, 311 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 312 | throws java.io.IOException { 313 | return com.google.protobuf.GeneratedMessageV3 314 | .parseWithIOException(PARSER, input, extensionRegistry); 315 | } 316 | 317 | @java.lang.Override 318 | public Builder newBuilderForType() { return newBuilder(); } 319 | public static Builder newBuilder() { 320 | return DEFAULT_INSTANCE.toBuilder(); 321 | } 322 | public static Builder newBuilder(com.blueapron.connect.protobuf.DateValueOuterClass.DateValue prototype) { 323 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 324 | } 325 | @java.lang.Override 326 | public Builder toBuilder() { 327 | return this == DEFAULT_INSTANCE 328 | ? new Builder() : new Builder().mergeFrom(this); 329 | } 330 | 331 | @java.lang.Override 332 | protected Builder newBuilderForType( 333 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 334 | Builder builder = new Builder(parent); 335 | return builder; 336 | } 337 | /** 338 | *
339 |      * Wrapper message for `Date`.
340 |      * 
341 | * 342 | * Protobuf type {@code DateValue} 343 | */ 344 | public static final class Builder extends 345 | com.google.protobuf.GeneratedMessageV3.Builder implements 346 | // @@protoc_insertion_point(builder_implements:DateValue) 347 | com.blueapron.connect.protobuf.DateValueOuterClass.DateValueOrBuilder { 348 | public static final com.google.protobuf.Descriptors.Descriptor 349 | getDescriptor() { 350 | return com.blueapron.connect.protobuf.DateValueOuterClass.internal_static_DateValue_descriptor; 351 | } 352 | 353 | @java.lang.Override 354 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 355 | internalGetFieldAccessorTable() { 356 | return com.blueapron.connect.protobuf.DateValueOuterClass.internal_static_DateValue_fieldAccessorTable 357 | .ensureFieldAccessorsInitialized( 358 | com.blueapron.connect.protobuf.DateValueOuterClass.DateValue.class, com.blueapron.connect.protobuf.DateValueOuterClass.DateValue.Builder.class); 359 | } 360 | 361 | // Construct using com.blueapron.connect.protobuf.DateValueOuterClass.DateValue.newBuilder() 362 | private Builder() { 363 | maybeForceBuilderInitialization(); 364 | } 365 | 366 | private Builder( 367 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 368 | super(parent); 369 | maybeForceBuilderInitialization(); 370 | } 371 | private void maybeForceBuilderInitialization() { 372 | if (com.google.protobuf.GeneratedMessageV3 373 | .alwaysUseFieldBuilders) { 374 | } 375 | } 376 | @java.lang.Override 377 | public Builder clear() { 378 | super.clear(); 379 | if (valueBuilder_ == null) { 380 | value_ = null; 381 | } else { 382 | value_ = null; 383 | valueBuilder_ = null; 384 | } 385 | return this; 386 | } 387 | 388 | @java.lang.Override 389 | public com.google.protobuf.Descriptors.Descriptor 390 | getDescriptorForType() { 391 | return com.blueapron.connect.protobuf.DateValueOuterClass.internal_static_DateValue_descriptor; 392 | } 393 | 394 | @java.lang.Override 395 | public com.blueapron.connect.protobuf.DateValueOuterClass.DateValue getDefaultInstanceForType() { 396 | return com.blueapron.connect.protobuf.DateValueOuterClass.DateValue.getDefaultInstance(); 397 | } 398 | 399 | @java.lang.Override 400 | public com.blueapron.connect.protobuf.DateValueOuterClass.DateValue build() { 401 | com.blueapron.connect.protobuf.DateValueOuterClass.DateValue result = buildPartial(); 402 | if (!result.isInitialized()) { 403 | throw newUninitializedMessageException(result); 404 | } 405 | return result; 406 | } 407 | 408 | @java.lang.Override 409 | public com.blueapron.connect.protobuf.DateValueOuterClass.DateValue buildPartial() { 410 | com.blueapron.connect.protobuf.DateValueOuterClass.DateValue result = new com.blueapron.connect.protobuf.DateValueOuterClass.DateValue(this); 411 | if (valueBuilder_ == null) { 412 | result.value_ = value_; 413 | } else { 414 | result.value_ = valueBuilder_.build(); 415 | } 416 | onBuilt(); 417 | return result; 418 | } 419 | 420 | @java.lang.Override 421 | public Builder clone() { 422 | return super.clone(); 423 | } 424 | @java.lang.Override 425 | public Builder setField( 426 | com.google.protobuf.Descriptors.FieldDescriptor field, 427 | java.lang.Object value) { 428 | return super.setField(field, value); 429 | } 430 | @java.lang.Override 431 | public Builder clearField( 432 | com.google.protobuf.Descriptors.FieldDescriptor field) { 433 | return super.clearField(field); 434 | } 435 | @java.lang.Override 436 | public Builder clearOneof( 437 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 438 | return super.clearOneof(oneof); 439 | } 440 | @java.lang.Override 441 | public Builder setRepeatedField( 442 | com.google.protobuf.Descriptors.FieldDescriptor field, 443 | int index, java.lang.Object value) { 444 | return super.setRepeatedField(field, index, value); 445 | } 446 | @java.lang.Override 447 | public Builder addRepeatedField( 448 | com.google.protobuf.Descriptors.FieldDescriptor field, 449 | java.lang.Object value) { 450 | return super.addRepeatedField(field, value); 451 | } 452 | @java.lang.Override 453 | public Builder mergeFrom(com.google.protobuf.Message other) { 454 | if (other instanceof com.blueapron.connect.protobuf.DateValueOuterClass.DateValue) { 455 | return mergeFrom((com.blueapron.connect.protobuf.DateValueOuterClass.DateValue)other); 456 | } else { 457 | super.mergeFrom(other); 458 | return this; 459 | } 460 | } 461 | 462 | public Builder mergeFrom(com.blueapron.connect.protobuf.DateValueOuterClass.DateValue other) { 463 | if (other == com.blueapron.connect.protobuf.DateValueOuterClass.DateValue.getDefaultInstance()) return this; 464 | if (other.hasValue()) { 465 | mergeValue(other.getValue()); 466 | } 467 | this.mergeUnknownFields(other.unknownFields); 468 | onChanged(); 469 | return this; 470 | } 471 | 472 | @java.lang.Override 473 | public final boolean isInitialized() { 474 | return true; 475 | } 476 | 477 | @java.lang.Override 478 | public Builder mergeFrom( 479 | com.google.protobuf.CodedInputStream input, 480 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 481 | throws java.io.IOException { 482 | com.blueapron.connect.protobuf.DateValueOuterClass.DateValue parsedMessage = null; 483 | try { 484 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 485 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 486 | parsedMessage = (com.blueapron.connect.protobuf.DateValueOuterClass.DateValue) e.getUnfinishedMessage(); 487 | throw e.unwrapIOException(); 488 | } finally { 489 | if (parsedMessage != null) { 490 | mergeFrom(parsedMessage); 491 | } 492 | } 493 | return this; 494 | } 495 | 496 | private com.google.type.Date value_; 497 | private com.google.protobuf.SingleFieldBuilderV3< 498 | com.google.type.Date, com.google.type.Date.Builder, com.google.type.DateOrBuilder> valueBuilder_; 499 | /** 500 | *
501 |        * The bytes value.
502 |        * 
503 | * 504 | * .google.type.Date value = 1; 505 | * @return Whether the value field is set. 506 | */ 507 | public boolean hasValue() { 508 | return valueBuilder_ != null || value_ != null; 509 | } 510 | /** 511 | *
512 |        * The bytes value.
513 |        * 
514 | * 515 | * .google.type.Date value = 1; 516 | * @return The value. 517 | */ 518 | public com.google.type.Date getValue() { 519 | if (valueBuilder_ == null) { 520 | return value_ == null ? com.google.type.Date.getDefaultInstance() : value_; 521 | } else { 522 | return valueBuilder_.getMessage(); 523 | } 524 | } 525 | /** 526 | *
527 |        * The bytes value.
528 |        * 
529 | * 530 | * .google.type.Date value = 1; 531 | */ 532 | public Builder setValue(com.google.type.Date value) { 533 | if (valueBuilder_ == null) { 534 | if (value == null) { 535 | throw new NullPointerException(); 536 | } 537 | value_ = value; 538 | onChanged(); 539 | } else { 540 | valueBuilder_.setMessage(value); 541 | } 542 | 543 | return this; 544 | } 545 | /** 546 | *
547 |        * The bytes value.
548 |        * 
549 | * 550 | * .google.type.Date value = 1; 551 | */ 552 | public Builder setValue( 553 | com.google.type.Date.Builder builderForValue) { 554 | if (valueBuilder_ == null) { 555 | value_ = builderForValue.build(); 556 | onChanged(); 557 | } else { 558 | valueBuilder_.setMessage(builderForValue.build()); 559 | } 560 | 561 | return this; 562 | } 563 | /** 564 | *
565 |        * The bytes value.
566 |        * 
567 | * 568 | * .google.type.Date value = 1; 569 | */ 570 | public Builder mergeValue(com.google.type.Date value) { 571 | if (valueBuilder_ == null) { 572 | if (value_ != null) { 573 | value_ = 574 | com.google.type.Date.newBuilder(value_).mergeFrom(value).buildPartial(); 575 | } else { 576 | value_ = value; 577 | } 578 | onChanged(); 579 | } else { 580 | valueBuilder_.mergeFrom(value); 581 | } 582 | 583 | return this; 584 | } 585 | /** 586 | *
587 |        * The bytes value.
588 |        * 
589 | * 590 | * .google.type.Date value = 1; 591 | */ 592 | public Builder clearValue() { 593 | if (valueBuilder_ == null) { 594 | value_ = null; 595 | onChanged(); 596 | } else { 597 | value_ = null; 598 | valueBuilder_ = null; 599 | } 600 | 601 | return this; 602 | } 603 | /** 604 | *
605 |        * The bytes value.
606 |        * 
607 | * 608 | * .google.type.Date value = 1; 609 | */ 610 | public com.google.type.Date.Builder getValueBuilder() { 611 | 612 | onChanged(); 613 | return getValueFieldBuilder().getBuilder(); 614 | } 615 | /** 616 | *
617 |        * The bytes value.
618 |        * 
619 | * 620 | * .google.type.Date value = 1; 621 | */ 622 | public com.google.type.DateOrBuilder getValueOrBuilder() { 623 | if (valueBuilder_ != null) { 624 | return valueBuilder_.getMessageOrBuilder(); 625 | } else { 626 | return value_ == null ? 627 | com.google.type.Date.getDefaultInstance() : value_; 628 | } 629 | } 630 | /** 631 | *
632 |        * The bytes value.
633 |        * 
634 | * 635 | * .google.type.Date value = 1; 636 | */ 637 | private com.google.protobuf.SingleFieldBuilderV3< 638 | com.google.type.Date, com.google.type.Date.Builder, com.google.type.DateOrBuilder> 639 | getValueFieldBuilder() { 640 | if (valueBuilder_ == null) { 641 | valueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< 642 | com.google.type.Date, com.google.type.Date.Builder, com.google.type.DateOrBuilder>( 643 | getValue(), 644 | getParentForChildren(), 645 | isClean()); 646 | value_ = null; 647 | } 648 | return valueBuilder_; 649 | } 650 | @java.lang.Override 651 | public final Builder setUnknownFields( 652 | final com.google.protobuf.UnknownFieldSet unknownFields) { 653 | return super.setUnknownFields(unknownFields); 654 | } 655 | 656 | @java.lang.Override 657 | public final Builder mergeUnknownFields( 658 | final com.google.protobuf.UnknownFieldSet unknownFields) { 659 | return super.mergeUnknownFields(unknownFields); 660 | } 661 | 662 | 663 | // @@protoc_insertion_point(builder_scope:DateValue) 664 | } 665 | 666 | // @@protoc_insertion_point(class_scope:DateValue) 667 | private static final com.blueapron.connect.protobuf.DateValueOuterClass.DateValue DEFAULT_INSTANCE; 668 | static { 669 | DEFAULT_INSTANCE = new com.blueapron.connect.protobuf.DateValueOuterClass.DateValue(); 670 | } 671 | 672 | public static com.blueapron.connect.protobuf.DateValueOuterClass.DateValue getDefaultInstance() { 673 | return DEFAULT_INSTANCE; 674 | } 675 | 676 | private static final com.google.protobuf.Parser 677 | PARSER = new com.google.protobuf.AbstractParser() { 678 | @java.lang.Override 679 | public DateValue parsePartialFrom( 680 | com.google.protobuf.CodedInputStream input, 681 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 682 | throws com.google.protobuf.InvalidProtocolBufferException { 683 | return new DateValue(input, extensionRegistry); 684 | } 685 | }; 686 | 687 | public static com.google.protobuf.Parser parser() { 688 | return PARSER; 689 | } 690 | 691 | @java.lang.Override 692 | public com.google.protobuf.Parser getParserForType() { 693 | return PARSER; 694 | } 695 | 696 | @java.lang.Override 697 | public com.blueapron.connect.protobuf.DateValueOuterClass.DateValue getDefaultInstanceForType() { 698 | return DEFAULT_INSTANCE; 699 | } 700 | 701 | } 702 | 703 | private static final com.google.protobuf.Descriptors.Descriptor 704 | internal_static_DateValue_descriptor; 705 | private static final 706 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 707 | internal_static_DateValue_fieldAccessorTable; 708 | 709 | public static com.google.protobuf.Descriptors.FileDescriptor 710 | getDescriptor() { 711 | return descriptor; 712 | } 713 | private static com.google.protobuf.Descriptors.FileDescriptor 714 | descriptor; 715 | static { 716 | java.lang.String[] descriptorData = { 717 | "\n\017DateValue.proto\032\026google/type/date.prot" + 718 | "o\"-\n\tDateValue\022 \n\005value\030\001 \001(\0132\021.google.t" + 719 | "ype.DateB \n\036com.blueapron.connect.protob" + 720 | "ufb\006proto3" 721 | }; 722 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 723 | .internalBuildGeneratedFileFrom(descriptorData, 724 | new com.google.protobuf.Descriptors.FileDescriptor[] { 725 | com.google.type.DateProto.getDescriptor(), 726 | }); 727 | internal_static_DateValue_descriptor = 728 | getDescriptor().getMessageTypes().get(0); 729 | internal_static_DateValue_fieldAccessorTable = new 730 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 731 | internal_static_DateValue_descriptor, 732 | new java.lang.String[] { "Value", }); 733 | com.google.type.DateProto.getDescriptor(); 734 | } 735 | 736 | // @@protoc_insertion_point(outer_class_scope) 737 | } 738 | --------------------------------------------------------------------------------