You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/04/11 18:04:47 UTC
[1/5] camel git commit: CAMEL-11135: fixing sourcecheck issues
Repository: camel
Updated Branches:
refs/heads/master 3b977b01c -> ab1842307
CAMEL-11135: fixing sourcecheck issues
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/04d584f5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/04d584f5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/04d584f5
Branch: refs/heads/master
Commit: 04d584f5beaa0ef05e940e90953703086dd4ed0a
Parents: 327dfcb
Author: Dmitry Volodin <dm...@gmail.com>
Authored: Tue Apr 11 17:59:38 2017 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Apr 11 19:53:20 2017 +0200
----------------------------------------------------------------------
.../apache/camel/dataformat/protobuf/ProtobufDataFormat.java | 2 +-
.../protobuf/ProtobufMarshalAndUnmarshalJsonTest.java | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/04d584f5/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java b/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java
index b8cba4f..991599c 100755
--- a/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java
+++ b/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java
@@ -47,7 +47,7 @@ public class ProtobufDataFormat extends ServiceSupport implements DataFormat, Da
private CamelContext camelContext;
private Message defaultInstance;
private String instanceClassName;
- private boolean contentTypeHeader = false;
+ private boolean contentTypeHeader;
private String contentTypeFormat = CONTENT_TYPE_FORMAT_NATIVE;
public ProtobufDataFormat() {
http://git-wip-us.apache.org/repos/asf/camel/blob/04d584f5/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java
index b1e789e..f66be1b 100644
--- a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java
+++ b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java
@@ -25,9 +25,9 @@ import org.junit.Test;
public class ProtobufMarshalAndUnmarshalJsonTest extends CamelTestSupport {
- private final static String PERSON_TEST_NAME = "Martin";
- private final static int PERSON_TEST_ID = 1234;
- private final static String PERSON_TEST_JSON = "{\"name\": \"Martin\",\"id\": 1234}";
+ private static final String PERSON_TEST_NAME = "Martin";
+ private static final String PERSON_TEST_JSON = "{\"name\": \"Martin\",\"id\": 1234}";
+ private static final int PERSON_TEST_ID = 1234;
@Test
public void testMarshalAndUnmarshal() throws Exception {
[3/5] camel git commit: CAMEL-11135: camel-protobuf component
improvements
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/generated/AddressBookProtos.java
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/generated/AddressBookProtos.java b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/generated/AddressBookProtos.java
deleted file mode 100644
index fc54b04..0000000
--- a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/generated/AddressBookProtos.java
+++ /dev/null
@@ -1,2548 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: addressbook.proto
-package org.apache.camel.dataformat.protobuf.generated;
-
-//CHECKSTYLE:OFF
-public final class AddressBookProtos {
- private AddressBookProtos() {}
- public static void registerAllExtensions(
- com.google.protobuf.ExtensionRegistry registry) {
- }
- public interface PersonOrBuilder extends
- // @@protoc_insertion_point(interface_extends:org.apache.camel.dataformat.protobuf.generated.Person)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>required string name = 1;</code>
- */
- boolean hasName();
- /**
- * <code>required string name = 1;</code>
- */
- java.lang.String getName();
- /**
- * <code>required string name = 1;</code>
- */
- com.google.protobuf.ByteString
- getNameBytes();
-
- /**
- * <code>required int32 id = 2;</code>
- */
- boolean hasId();
- /**
- * <code>required int32 id = 2;</code>
- */
- int getId();
-
- /**
- * <code>optional string email = 3;</code>
- */
- boolean hasEmail();
- /**
- * <code>optional string email = 3;</code>
- */
- java.lang.String getEmail();
- /**
- * <code>optional string email = 3;</code>
- */
- com.google.protobuf.ByteString
- getEmailBytes();
-
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber>
- getPhoneList();
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber getPhone(int index);
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- int getPhoneCount();
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- java.util.List<? extends org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder>
- getPhoneOrBuilderList();
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder getPhoneOrBuilder(
- int index);
- }
- /**
- * Protobuf type {@code org.apache.camel.dataformat.protobuf.generated.Person}
- */
- public static final class Person extends
- com.google.protobuf.GeneratedMessage implements
- // @@protoc_insertion_point(message_implements:org.apache.camel.dataformat.protobuf.generated.Person)
- PersonOrBuilder {
- // Use Person.newBuilder() to construct.
- private Person(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
- super(builder);
- this.unknownFields = builder.getUnknownFields();
- }
- private Person(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
- private static final Person defaultInstance;
- public static Person getDefaultInstance() {
- return defaultInstance;
- }
-
- public Person getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- private final com.google.protobuf.UnknownFieldSet unknownFields;
- @java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
- private Person(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- initFields();
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- case 10: {
- com.google.protobuf.ByteString bs = input.readBytes();
- bitField0_ |= 0x00000001;
- name_ = bs;
- break;
- }
- case 16: {
- bitField0_ |= 0x00000002;
- id_ = input.readInt32();
- break;
- }
- case 26: {
- com.google.protobuf.ByteString bs = input.readBytes();
- bitField0_ |= 0x00000004;
- email_ = bs;
- break;
- }
- case 34: {
- if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
- phone_ = new java.util.ArrayList<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber>();
- mutable_bitField0_ |= 0x00000008;
- }
- phone_.add(input.readMessage(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.PARSER, extensionRegistry));
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
- } finally {
- if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
- phone_ = java.util.Collections.unmodifiableList(phone_);
- }
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.class, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.Builder.class);
- }
-
- public static com.google.protobuf.Parser<Person> PARSER =
- new com.google.protobuf.AbstractParser<Person>() {
- public Person parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new Person(input, extensionRegistry);
- }
- };
-
- @java.lang.Override
- public com.google.protobuf.Parser<Person> getParserForType() {
- return PARSER;
- }
-
- /**
- * Protobuf enum {@code org.apache.camel.dataformat.protobuf.generated.Person.PhoneType}
- */
- public enum PhoneType
- implements com.google.protobuf.ProtocolMessageEnum {
- /**
- * <code>MOBILE = 0;</code>
- */
- MOBILE(0, 0),
- /**
- * <code>HOME = 1;</code>
- */
- HOME(1, 1),
- /**
- * <code>WORK = 2;</code>
- */
- WORK(2, 2),
- ;
-
- /**
- * <code>MOBILE = 0;</code>
- */
- public static final int MOBILE_VALUE = 0;
- /**
- * <code>HOME = 1;</code>
- */
- public static final int HOME_VALUE = 1;
- /**
- * <code>WORK = 2;</code>
- */
- public static final int WORK_VALUE = 2;
-
-
- public final int getNumber() { return value; }
-
- public static PhoneType valueOf(int value) {
- switch (value) {
- case 0: return MOBILE;
- case 1: return HOME;
- case 2: return WORK;
- default: return null;
- }
- }
-
- public static com.google.protobuf.Internal.EnumLiteMap<PhoneType>
- internalGetValueMap() {
- return internalValueMap;
- }
- private static com.google.protobuf.Internal.EnumLiteMap<PhoneType>
- internalValueMap =
- new com.google.protobuf.Internal.EnumLiteMap<PhoneType>() {
- public PhoneType findValueByNumber(int number) {
- return PhoneType.valueOf(number);
- }
- };
-
- public final com.google.protobuf.Descriptors.EnumValueDescriptor
- getValueDescriptor() {
- return getDescriptor().getValues().get(index);
- }
- public final com.google.protobuf.Descriptors.EnumDescriptor
- getDescriptorForType() {
- return getDescriptor();
- }
- public static final com.google.protobuf.Descriptors.EnumDescriptor
- getDescriptor() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.getDescriptor().getEnumTypes().get(0);
- }
-
- private static final PhoneType[] VALUES = values();
-
- public static PhoneType valueOf(
- com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
- if (desc.getType() != getDescriptor()) {
- throw new java.lang.IllegalArgumentException(
- "EnumValueDescriptor is not for this type.");
- }
- return VALUES[desc.getIndex()];
- }
-
- private final int index;
- private final int value;
-
- private PhoneType(int index, int value) {
- this.index = index;
- this.value = value;
- }
-
- // @@protoc_insertion_point(enum_scope:org.apache.camel.dataformat.protobuf.generated.Person.PhoneType)
- }
-
- public interface PhoneNumberOrBuilder extends
- // @@protoc_insertion_point(interface_extends:org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>required string number = 1;</code>
- */
- boolean hasNumber();
- /**
- * <code>required string number = 1;</code>
- */
- java.lang.String getNumber();
- /**
- * <code>required string number = 1;</code>
- */
- com.google.protobuf.ByteString
- getNumberBytes();
-
- /**
- * <code>optional .org.apache.camel.dataformat.protobuf.generated.Person.PhoneType type = 2 [default = HOME];</code>
- */
- boolean hasType();
- /**
- * <code>optional .org.apache.camel.dataformat.protobuf.generated.Person.PhoneType type = 2 [default = HOME];</code>
- */
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType getType();
- }
- /**
- * Protobuf type {@code org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber}
- */
- public static final class PhoneNumber extends
- com.google.protobuf.GeneratedMessage implements
- // @@protoc_insertion_point(message_implements:org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber)
- PhoneNumberOrBuilder {
- // Use PhoneNumber.newBuilder() to construct.
- private PhoneNumber(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
- super(builder);
- this.unknownFields = builder.getUnknownFields();
- }
- private PhoneNumber(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
- private static final PhoneNumber defaultInstance;
- public static PhoneNumber getDefaultInstance() {
- return defaultInstance;
- }
-
- public PhoneNumber getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- private final com.google.protobuf.UnknownFieldSet unknownFields;
- @java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
- private PhoneNumber(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- initFields();
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- case 10: {
- com.google.protobuf.ByteString bs = input.readBytes();
- bitField0_ |= 0x00000001;
- number_ = bs;
- break;
- }
- case 16: {
- int rawValue = input.readEnum();
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType value = org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType.valueOf(rawValue);
- if (value == null) {
- unknownFields.mergeVarintField(2, rawValue);
- } else {
- bitField0_ |= 0x00000002;
- type_ = value;
- }
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
- } finally {
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_PhoneNumber_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_PhoneNumber_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.class, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder.class);
- }
-
- public static com.google.protobuf.Parser<PhoneNumber> PARSER =
- new com.google.protobuf.AbstractParser<PhoneNumber>() {
- public PhoneNumber parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new PhoneNumber(input, extensionRegistry);
- }
- };
-
- @java.lang.Override
- public com.google.protobuf.Parser<PhoneNumber> getParserForType() {
- return PARSER;
- }
-
- private int bitField0_;
- public static final int NUMBER_FIELD_NUMBER = 1;
- private java.lang.Object number_;
- /**
- * <code>required string number = 1;</code>
- */
- public boolean hasNumber() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>required string number = 1;</code>
- */
- public java.lang.String getNumber() {
- java.lang.Object ref = number_;
- if (ref instanceof java.lang.String) {
- return (java.lang.String) ref;
- } else {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- if (bs.isValidUtf8()) {
- number_ = s;
- }
- return s;
- }
- }
- /**
- * <code>required string number = 1;</code>
- */
- public com.google.protobuf.ByteString
- getNumberBytes() {
- java.lang.Object ref = number_;
- if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- number_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- public static final int TYPE_FIELD_NUMBER = 2;
- private org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType type_;
- /**
- * <code>optional .org.apache.camel.dataformat.protobuf.generated.Person.PhoneType type = 2 [default = HOME];</code>
- */
- public boolean hasType() {
- return ((bitField0_ & 0x00000002) == 0x00000002);
- }
- /**
- * <code>optional .org.apache.camel.dataformat.protobuf.generated.Person.PhoneType type = 2 [default = HOME];</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType getType() {
- return type_;
- }
-
- private void initFields() {
- number_ = "";
- type_ = org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType.HOME;
- }
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- if (!hasNumber()) {
- memoizedIsInitialized = 0;
- return false;
- }
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeBytes(1, getNumberBytes());
- }
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- output.writeEnum(2, type_.getNumber());
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(1, getNumberBytes());
- }
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- size += com.google.protobuf.CodedOutputStream
- .computeEnumSize(2, type_.getNumber());
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
- return super.writeReplace();
- }
-
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber)
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_PhoneNumber_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_PhoneNumber_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.class, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder.class);
- }
-
- // Construct using org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- }
- }
- private static Builder create() {
- return new Builder();
- }
-
- public Builder clear() {
- super.clear();
- number_ = "";
- bitField0_ = (bitField0_ & ~0x00000001);
- type_ = org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType.HOME;
- bitField0_ = (bitField0_ & ~0x00000002);
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(buildPartial());
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_PhoneNumber_descriptor;
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber getDefaultInstanceForType() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.getDefaultInstance();
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber build() {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber buildPartial() {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber result = new org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber(this);
- int from_bitField0_ = bitField0_;
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
- to_bitField0_ |= 0x00000001;
- }
- result.number_ = number_;
- if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
- to_bitField0_ |= 0x00000002;
- }
- result.type_ = type_;
- result.bitField0_ = to_bitField0_;
- onBuilt();
- return result;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber) {
- return mergeFrom((org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber other) {
- if (other == org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.getDefaultInstance()) return this;
- if (other.hasNumber()) {
- bitField0_ |= 0x00000001;
- number_ = other.number_;
- onChanged();
- }
- if (other.hasType()) {
- setType(other.getType());
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public final boolean isInitialized() {
- if (!hasNumber()) {
-
- return false;
- }
- return true;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber) e.getUnfinishedMessage();
- throw e;
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- private java.lang.Object number_ = "";
- /**
- * <code>required string number = 1;</code>
- */
- public boolean hasNumber() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>required string number = 1;</code>
- */
- public java.lang.String getNumber() {
- java.lang.Object ref = number_;
- if (!(ref instanceof java.lang.String)) {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- if (bs.isValidUtf8()) {
- number_ = s;
- }
- return s;
- } else {
- return (java.lang.String) ref;
- }
- }
- /**
- * <code>required string number = 1;</code>
- */
- public com.google.protobuf.ByteString
- getNumberBytes() {
- java.lang.Object ref = number_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- number_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
- /**
- * <code>required string number = 1;</code>
- */
- public Builder setNumber(
- java.lang.String value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000001;
- number_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>required string number = 1;</code>
- */
- public Builder clearNumber() {
- bitField0_ = (bitField0_ & ~0x00000001);
- number_ = getDefaultInstance().getNumber();
- onChanged();
- return this;
- }
- /**
- * <code>required string number = 1;</code>
- */
- public Builder setNumberBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000001;
- number_ = value;
- onChanged();
- return this;
- }
-
- private org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType type_ = org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType.HOME;
- /**
- * <code>optional .org.apache.camel.dataformat.protobuf.generated.Person.PhoneType type = 2 [default = HOME];</code>
- */
- public boolean hasType() {
- return ((bitField0_ & 0x00000002) == 0x00000002);
- }
- /**
- * <code>optional .org.apache.camel.dataformat.protobuf.generated.Person.PhoneType type = 2 [default = HOME];</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType getType() {
- return type_;
- }
- /**
- * <code>optional .org.apache.camel.dataformat.protobuf.generated.Person.PhoneType type = 2 [default = HOME];</code>
- */
- public Builder setType(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000002;
- type_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional .org.apache.camel.dataformat.protobuf.generated.Person.PhoneType type = 2 [default = HOME];</code>
- */
- public Builder clearType() {
- bitField0_ = (bitField0_ & ~0x00000002);
- type_ = org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneType.HOME;
- onChanged();
- return this;
- }
-
- // @@protoc_insertion_point(builder_scope:org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber)
- }
-
- static {
- defaultInstance = new PhoneNumber(true);
- defaultInstance.initFields();
- }
-
- // @@protoc_insertion_point(class_scope:org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber)
- }
-
- private int bitField0_;
- public static final int NAME_FIELD_NUMBER = 1;
- private java.lang.Object name_;
- /**
- * <code>required string name = 1;</code>
- */
- public boolean hasName() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>required string name = 1;</code>
- */
- public java.lang.String getName() {
- java.lang.Object ref = name_;
- if (ref instanceof java.lang.String) {
- return (java.lang.String) ref;
- } else {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- if (bs.isValidUtf8()) {
- name_ = s;
- }
- return s;
- }
- }
- /**
- * <code>required string name = 1;</code>
- */
- public com.google.protobuf.ByteString
- getNameBytes() {
- java.lang.Object ref = name_;
- if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- name_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- public static final int ID_FIELD_NUMBER = 2;
- private int id_;
- /**
- * <code>required int32 id = 2;</code>
- */
- public boolean hasId() {
- return ((bitField0_ & 0x00000002) == 0x00000002);
- }
- /**
- * <code>required int32 id = 2;</code>
- */
- public int getId() {
- return id_;
- }
-
- public static final int EMAIL_FIELD_NUMBER = 3;
- private java.lang.Object email_;
- /**
- * <code>optional string email = 3;</code>
- */
- public boolean hasEmail() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
- }
- /**
- * <code>optional string email = 3;</code>
- */
- public java.lang.String getEmail() {
- java.lang.Object ref = email_;
- if (ref instanceof java.lang.String) {
- return (java.lang.String) ref;
- } else {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- if (bs.isValidUtf8()) {
- email_ = s;
- }
- return s;
- }
- }
- /**
- * <code>optional string email = 3;</code>
- */
- public com.google.protobuf.ByteString
- getEmailBytes() {
- java.lang.Object ref = email_;
- if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- email_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- public static final int PHONE_FIELD_NUMBER = 4;
- private java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber> phone_;
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber> getPhoneList() {
- return phone_;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public java.util.List<? extends org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder>
- getPhoneOrBuilderList() {
- return phone_;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public int getPhoneCount() {
- return phone_.size();
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber getPhone(int index) {
- return phone_.get(index);
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder getPhoneOrBuilder(
- int index) {
- return phone_.get(index);
- }
-
- private void initFields() {
- name_ = "";
- id_ = 0;
- email_ = "";
- phone_ = java.util.Collections.emptyList();
- }
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- if (!hasName()) {
- memoizedIsInitialized = 0;
- return false;
- }
- if (!hasId()) {
- memoizedIsInitialized = 0;
- return false;
- }
- for (int i = 0; i < getPhoneCount(); i++) {
- if (!getPhone(i).isInitialized()) {
- memoizedIsInitialized = 0;
- return false;
- }
- }
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeBytes(1, getNameBytes());
- }
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- output.writeInt32(2, id_);
- }
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
- output.writeBytes(3, getEmailBytes());
- }
- for (int i = 0; i < phone_.size(); i++) {
- output.writeMessage(4, phone_.get(i));
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(1, getNameBytes());
- }
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(2, id_);
- }
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
- size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(3, getEmailBytes());
- }
- for (int i = 0; i < phone_.size(); i++) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(4, phone_.get(i));
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
- return super.writeReplace();
- }
-
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code org.apache.camel.dataformat.protobuf.generated.Person}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:org.apache.camel.dataformat.protobuf.generated.Person)
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.PersonOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.class, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.Builder.class);
- }
-
- // Construct using org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- getPhoneFieldBuilder();
- }
- }
- private static Builder create() {
- return new Builder();
- }
-
- public Builder clear() {
- super.clear();
- name_ = "";
- bitField0_ = (bitField0_ & ~0x00000001);
- id_ = 0;
- bitField0_ = (bitField0_ & ~0x00000002);
- email_ = "";
- bitField0_ = (bitField0_ & ~0x00000004);
- if (phoneBuilder_ == null) {
- phone_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000008);
- } else {
- phoneBuilder_.clear();
- }
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(buildPartial());
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_Person_descriptor;
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person getDefaultInstanceForType() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.getDefaultInstance();
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person build() {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person buildPartial() {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person result = new org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person(this);
- int from_bitField0_ = bitField0_;
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
- to_bitField0_ |= 0x00000001;
- }
- result.name_ = name_;
- if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
- to_bitField0_ |= 0x00000002;
- }
- result.id_ = id_;
- if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
- to_bitField0_ |= 0x00000004;
- }
- result.email_ = email_;
- if (phoneBuilder_ == null) {
- if (((bitField0_ & 0x00000008) == 0x00000008)) {
- phone_ = java.util.Collections.unmodifiableList(phone_);
- bitField0_ = (bitField0_ & ~0x00000008);
- }
- result.phone_ = phone_;
- } else {
- result.phone_ = phoneBuilder_.build();
- }
- result.bitField0_ = to_bitField0_;
- onBuilt();
- return result;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person) {
- return mergeFrom((org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person other) {
- if (other == org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.getDefaultInstance()) return this;
- if (other.hasName()) {
- bitField0_ |= 0x00000001;
- name_ = other.name_;
- onChanged();
- }
- if (other.hasId()) {
- setId(other.getId());
- }
- if (other.hasEmail()) {
- bitField0_ |= 0x00000004;
- email_ = other.email_;
- onChanged();
- }
- if (phoneBuilder_ == null) {
- if (!other.phone_.isEmpty()) {
- if (phone_.isEmpty()) {
- phone_ = other.phone_;
- bitField0_ = (bitField0_ & ~0x00000008);
- } else {
- ensurePhoneIsMutable();
- phone_.addAll(other.phone_);
- }
- onChanged();
- }
- } else {
- if (!other.phone_.isEmpty()) {
- if (phoneBuilder_.isEmpty()) {
- phoneBuilder_.dispose();
- phoneBuilder_ = null;
- phone_ = other.phone_;
- bitField0_ = (bitField0_ & ~0x00000008);
- phoneBuilder_ =
- com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
- getPhoneFieldBuilder() : null;
- } else {
- phoneBuilder_.addAllMessages(other.phone_);
- }
- }
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public final boolean isInitialized() {
- if (!hasName()) {
-
- return false;
- }
- if (!hasId()) {
-
- return false;
- }
- for (int i = 0; i < getPhoneCount(); i++) {
- if (!getPhone(i).isInitialized()) {
-
- return false;
- }
- }
- return true;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person) e.getUnfinishedMessage();
- throw e;
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- private java.lang.Object name_ = "";
- /**
- * <code>required string name = 1;</code>
- */
- public boolean hasName() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>required string name = 1;</code>
- */
- public java.lang.String getName() {
- java.lang.Object ref = name_;
- if (!(ref instanceof java.lang.String)) {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- if (bs.isValidUtf8()) {
- name_ = s;
- }
- return s;
- } else {
- return (java.lang.String) ref;
- }
- }
- /**
- * <code>required string name = 1;</code>
- */
- public com.google.protobuf.ByteString
- getNameBytes() {
- java.lang.Object ref = name_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- name_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
- /**
- * <code>required string name = 1;</code>
- */
- public Builder setName(
- java.lang.String value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000001;
- name_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>required string name = 1;</code>
- */
- public Builder clearName() {
- bitField0_ = (bitField0_ & ~0x00000001);
- name_ = getDefaultInstance().getName();
- onChanged();
- return this;
- }
- /**
- * <code>required string name = 1;</code>
- */
- public Builder setNameBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000001;
- name_ = value;
- onChanged();
- return this;
- }
-
- private int id_ ;
- /**
- * <code>required int32 id = 2;</code>
- */
- public boolean hasId() {
- return ((bitField0_ & 0x00000002) == 0x00000002);
- }
- /**
- * <code>required int32 id = 2;</code>
- */
- public int getId() {
- return id_;
- }
- /**
- * <code>required int32 id = 2;</code>
- */
- public Builder setId(int value) {
- bitField0_ |= 0x00000002;
- id_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>required int32 id = 2;</code>
- */
- public Builder clearId() {
- bitField0_ = (bitField0_ & ~0x00000002);
- id_ = 0;
- onChanged();
- return this;
- }
-
- private java.lang.Object email_ = "";
- /**
- * <code>optional string email = 3;</code>
- */
- public boolean hasEmail() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
- }
- /**
- * <code>optional string email = 3;</code>
- */
- public java.lang.String getEmail() {
- java.lang.Object ref = email_;
- if (!(ref instanceof java.lang.String)) {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- if (bs.isValidUtf8()) {
- email_ = s;
- }
- return s;
- } else {
- return (java.lang.String) ref;
- }
- }
- /**
- * <code>optional string email = 3;</code>
- */
- public com.google.protobuf.ByteString
- getEmailBytes() {
- java.lang.Object ref = email_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- email_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
- /**
- * <code>optional string email = 3;</code>
- */
- public Builder setEmail(
- java.lang.String value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000004;
- email_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional string email = 3;</code>
- */
- public Builder clearEmail() {
- bitField0_ = (bitField0_ & ~0x00000004);
- email_ = getDefaultInstance().getEmail();
- onChanged();
- return this;
- }
- /**
- * <code>optional string email = 3;</code>
- */
- public Builder setEmailBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000004;
- email_ = value;
- onChanged();
- return this;
- }
-
- private java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber> phone_ =
- java.util.Collections.emptyList();
- private void ensurePhoneIsMutable() {
- if (!((bitField0_ & 0x00000008) == 0x00000008)) {
- phone_ = new java.util.ArrayList<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber>(phone_);
- bitField0_ |= 0x00000008;
- }
- }
-
- private com.google.protobuf.RepeatedFieldBuilder<
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder> phoneBuilder_;
-
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber> getPhoneList() {
- if (phoneBuilder_ == null) {
- return java.util.Collections.unmodifiableList(phone_);
- } else {
- return phoneBuilder_.getMessageList();
- }
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public int getPhoneCount() {
- if (phoneBuilder_ == null) {
- return phone_.size();
- } else {
- return phoneBuilder_.getCount();
- }
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber getPhone(int index) {
- if (phoneBuilder_ == null) {
- return phone_.get(index);
- } else {
- return phoneBuilder_.getMessage(index);
- }
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder setPhone(
- int index, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber value) {
- if (phoneBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensurePhoneIsMutable();
- phone_.set(index, value);
- onChanged();
- } else {
- phoneBuilder_.setMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder setPhone(
- int index, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
- if (phoneBuilder_ == null) {
- ensurePhoneIsMutable();
- phone_.set(index, builderForValue.build());
- onChanged();
- } else {
- phoneBuilder_.setMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder addPhone(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber value) {
- if (phoneBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensurePhoneIsMutable();
- phone_.add(value);
- onChanged();
- } else {
- phoneBuilder_.addMessage(value);
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder addPhone(
- int index, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber value) {
- if (phoneBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensurePhoneIsMutable();
- phone_.add(index, value);
- onChanged();
- } else {
- phoneBuilder_.addMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder addPhone(
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
- if (phoneBuilder_ == null) {
- ensurePhoneIsMutable();
- phone_.add(builderForValue.build());
- onChanged();
- } else {
- phoneBuilder_.addMessage(builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder addPhone(
- int index, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
- if (phoneBuilder_ == null) {
- ensurePhoneIsMutable();
- phone_.add(index, builderForValue.build());
- onChanged();
- } else {
- phoneBuilder_.addMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder addAllPhone(
- java.lang.Iterable<? extends org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber> values) {
- if (phoneBuilder_ == null) {
- ensurePhoneIsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, phone_);
- onChanged();
- } else {
- phoneBuilder_.addAllMessages(values);
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder clearPhone() {
- if (phoneBuilder_ == null) {
- phone_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000008);
- onChanged();
- } else {
- phoneBuilder_.clear();
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public Builder removePhone(int index) {
- if (phoneBuilder_ == null) {
- ensurePhoneIsMutable();
- phone_.remove(index);
- onChanged();
- } else {
- phoneBuilder_.remove(index);
- }
- return this;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder getPhoneBuilder(
- int index) {
- return getPhoneFieldBuilder().getBuilder(index);
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder getPhoneOrBuilder(
- int index) {
- if (phoneBuilder_ == null) {
- return phone_.get(index); } else {
- return phoneBuilder_.getMessageOrBuilder(index);
- }
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public java.util.List<? extends org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder>
- getPhoneOrBuilderList() {
- if (phoneBuilder_ != null) {
- return phoneBuilder_.getMessageOrBuilderList();
- } else {
- return java.util.Collections.unmodifiableList(phone_);
- }
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder addPhoneBuilder() {
- return getPhoneFieldBuilder().addBuilder(
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.getDefaultInstance());
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder addPhoneBuilder(
- int index) {
- return getPhoneFieldBuilder().addBuilder(
- index, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.getDefaultInstance());
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person.PhoneNumber phone = 4;</code>
- */
- public java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder>
- getPhoneBuilderList() {
- return getPhoneFieldBuilder().getBuilderList();
- }
- private com.google.protobuf.RepeatedFieldBuilder<
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder>
- getPhoneFieldBuilder() {
- if (phoneBuilder_ == null) {
- phoneBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumber.Builder, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PhoneNumberOrBuilder>(
- phone_,
- ((bitField0_ & 0x00000008) == 0x00000008),
- getParentForChildren(),
- isClean());
- phone_ = null;
- }
- return phoneBuilder_;
- }
-
- // @@protoc_insertion_point(builder_scope:org.apache.camel.dataformat.protobuf.generated.Person)
- }
-
- static {
- defaultInstance = new Person(true);
- defaultInstance.initFields();
- }
-
- // @@protoc_insertion_point(class_scope:org.apache.camel.dataformat.protobuf.generated.Person)
- }
-
- public interface AddressBookOrBuilder extends
- // @@protoc_insertion_point(interface_extends:org.apache.camel.dataformat.protobuf.generated.AddressBook)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person>
- getPersonList();
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person getPerson(int index);
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- int getPersonCount();
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- java.util.List<? extends org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.PersonOrBuilder>
- getPersonOrBuilderList();
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.PersonOrBuilder getPersonOrBuilder(
- int index);
- }
- /**
- * Protobuf type {@code org.apache.camel.dataformat.protobuf.generated.AddressBook}
- */
- public static final class AddressBook extends
- com.google.protobuf.GeneratedMessage implements
- // @@protoc_insertion_point(message_implements:org.apache.camel.dataformat.protobuf.generated.AddressBook)
- AddressBookOrBuilder {
- // Use AddressBook.newBuilder() to construct.
- private AddressBook(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
- super(builder);
- this.unknownFields = builder.getUnknownFields();
- }
- private AddressBook(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
- private static final AddressBook defaultInstance;
- public static AddressBook getDefaultInstance() {
- return defaultInstance;
- }
-
- public AddressBook getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- private final com.google.protobuf.UnknownFieldSet unknownFields;
- @java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
- private AddressBook(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- initFields();
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- case 10: {
- if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
- person_ = new java.util.ArrayList<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person>();
- mutable_bitField0_ |= 0x00000001;
- }
- person_.add(input.readMessage(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person.PARSER, extensionRegistry));
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
- } finally {
- if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
- person_ = java.util.Collections.unmodifiableList(person_);
- }
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_AddressBook_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_AddressBook_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook.class, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook.Builder.class);
- }
-
- public static com.google.protobuf.Parser<AddressBook> PARSER =
- new com.google.protobuf.AbstractParser<AddressBook>() {
- public AddressBook parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new AddressBook(input, extensionRegistry);
- }
- };
-
- @java.lang.Override
- public com.google.protobuf.Parser<AddressBook> getParserForType() {
- return PARSER;
- }
-
- public static final int PERSON_FIELD_NUMBER = 1;
- private java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person> person_;
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- public java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person> getPersonList() {
- return person_;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- public java.util.List<? extends org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.PersonOrBuilder>
- getPersonOrBuilderList() {
- return person_;
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- public int getPersonCount() {
- return person_.size();
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person getPerson(int index) {
- return person_.get(index);
- }
- /**
- * <code>repeated .org.apache.camel.dataformat.protobuf.generated.Person person = 1;</code>
- */
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.PersonOrBuilder getPersonOrBuilder(
- int index) {
- return person_.get(index);
- }
-
- private void initFields() {
- person_ = java.util.Collections.emptyList();
- }
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- for (int i = 0; i < getPersonCount(); i++) {
- if (!getPerson(i).isInitialized()) {
- memoizedIsInitialized = 0;
- return false;
- }
- }
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- for (int i = 0; i < person_.size(); i++) {
- output.writeMessage(1, person_.get(i));
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- for (int i = 0; i < person_.size(); i++) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(1, person_.get(i));
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
- return super.writeReplace();
- }
-
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input, extensionRegistry);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code org.apache.camel.dataformat.protobuf.generated.AddressBook}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:org.apache.camel.dataformat.protobuf.generated.AddressBook)
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBookOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_AddressBook_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_AddressBook_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook.class, org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook.Builder.class);
- }
-
- // Construct using org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- getPersonFieldBuilder();
- }
- }
- private static Builder create() {
- return new Builder();
- }
-
- public Builder clear() {
- super.clear();
- if (personBuilder_ == null) {
- person_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000001);
- } else {
- personBuilder_.clear();
- }
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(buildPartial());
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.internal_static_org_apache_camel_dataformat_protobuf_generated_AddressBook_descriptor;
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook getDefaultInstanceForType() {
- return org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook.getDefaultInstance();
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook build() {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook buildPartial() {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook result = new org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook(this);
- int from_bitField0_ = bitField0_;
- if (personBuilder_ == null) {
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- person_ = java.util.Collections.unmodifiableList(person_);
- bitField0_ = (bitField0_ & ~0x00000001);
- }
- result.person_ = person_;
- } else {
- result.person_ = personBuilder_.build();
- }
- onBuilt();
- return result;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook) {
- return mergeFrom((org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook other) {
- if (other == org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook.getDefaultInstance()) return this;
- if (personBuilder_ == null) {
- if (!other.person_.isEmpty()) {
- if (person_.isEmpty()) {
- person_ = other.person_;
- bitField0_ = (bitField0_ & ~0x00000001);
- } else {
- ensurePersonIsMutable();
- person_.addAll(other.person_);
- }
- onChanged();
- }
- } else {
- if (!other.person_.isEmpty()) {
- if (personBuilder_.isEmpty()) {
- personBuilder_.dispose();
- personBuilder_ = null;
- person_ = other.person_;
- bitField0_ = (bitField0_ & ~0x00000001);
- personBuilder_ =
- com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
- getPersonFieldBuilder() : null;
- } else {
- personBuilder_.addAllMessages(other.person_);
- }
- }
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public final boolean isInitialized() {
- for (int i = 0; i < getPersonCount(); i++) {
- if (!getPerson(i).isInitialized()) {
-
- return false;
- }
- }
- return true;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.AddressBook) e.getUnfinishedMessage();
- throw e;
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- private java.util.List<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person> person_ =
- java.util.Collections.emptyList();
- private void ensurePersonIsMutable() {
- if (!((bitField0_ & 0x00000001) == 0x00000001)) {
- person_ = new java.util.ArrayList<org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person>(person_);
- bitField0_ |= 0x00000001;
- }
- }
-
- private com.google.protobuf.RepeatedFieldBuilder<
- org.apache.camel.dataformat.protobuf
<TRUNCATED>
[4/5] camel git commit: CAMEL-11135: camel-protobuf component
improvements
Posted by da...@apache.org.
CAMEL-11135: camel-protobuf component improvements
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/327dfcbd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/327dfcbd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/327dfcbd
Branch: refs/heads/master
Commit: 327dfcbd8f312c78ffe1cc4a293612c2432d3867
Parents: 3b977b0
Author: Dmitry Volodin <dm...@gmail.com>
Authored: Tue Apr 11 17:49:27 2017 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Apr 11 19:53:20 2017 +0200
----------------------------------------------------------------------
.../apache/camel/builder/DataFormatClause.java | 11 +
.../model/dataformat/ProtobufDataFormat.java | 20 +
components/camel-protobuf/ReadMe.md | 5 +-
components/camel-protobuf/pom.xml | 42 +-
.../src/main/docs/protobuf-dataformat.adoc | 82 +-
.../dataformat/protobuf/ProtobufDataFormat.java | 84 +-
.../ProtobufMarshalAndUnmarshalJsonTest.java | 73 +
.../ProtobufMarshalAndUnmarshalSpringTest.java | 2 +-
.../ProtobufMarshalAndUnmarshalTest.java | 97 +
.../ProtobufMarshalAndUnmarshallTest.java | 100 -
.../protobuf/generated/AddressBookProtos.java | 2548 ------------------
.../src/test/proto/addressbook.proto | 29 +
.../camel-protobuf/src/test/proto/readme.txt | 5 +
.../src/test/resources/addressbook.proto | 27 -
.../src/test/resources/readme.txt | 5 -
.../ProtobufDataFormatConfiguration.java | 14 +
16 files changed, 432 insertions(+), 2712 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java b/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
index 25bea0f..0b18e91 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
@@ -714,10 +714,21 @@ public class DataFormatClause<T extends ProcessorDefinition<?>> {
dataFormat.setDefaultInstance(defaultInstance);
return dataFormat(dataFormat);
}
+
+ public T protobuf(Object defaultInstance, String contentTypeFormat) {
+ ProtobufDataFormat dataFormat = new ProtobufDataFormat();
+ dataFormat.setDefaultInstance(defaultInstance);
+ dataFormat.setContentTypeFormat(contentTypeFormat);
+ return dataFormat(dataFormat);
+ }
public T protobuf(String instanceClassName) {
return dataFormat(new ProtobufDataFormat(instanceClassName));
}
+
+ public T protobuf(String instanceClassName, String contentTypeFormat) {
+ return dataFormat(new ProtobufDataFormat(instanceClassName, contentTypeFormat));
+ }
/**
* Uses the RSS data format
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
index 723a6f6..dee0ec4 100644
--- a/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
+++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
@@ -38,6 +38,8 @@ import org.apache.camel.spi.Metadata;
public class ProtobufDataFormat extends DataFormatDefinition {
@XmlAttribute
private String instanceClass;
+ @XmlAttribute
+ private String contentTypeFormat;
@XmlTransient
private Object defaultInstance;
@@ -49,6 +51,12 @@ public class ProtobufDataFormat extends DataFormatDefinition {
this();
setInstanceClass(instanceClass);
}
+
+ public ProtobufDataFormat(String instanceClass, String contentTypeFormat) {
+ this();
+ setInstanceClass(instanceClass);
+ setContentTypeFormat(contentTypeFormat);
+ }
public String getInstanceClass() {
return instanceClass;
@@ -60,6 +68,15 @@ public class ProtobufDataFormat extends DataFormatDefinition {
public void setInstanceClass(String instanceClass) {
this.instanceClass = instanceClass;
}
+
+ /**
+ * Defines a content type format in which protobuf message will be
+ * serialized/deserialized from(to) the Java been. It can be native protobuf
+ * format or json fields representation. The default value is 'native'.
+ */
+ public void setContentTypeFormat(String contentTypeFormat) {
+ this.contentTypeFormat = contentTypeFormat;
+ }
public Object getDefaultInstance() {
return defaultInstance;
@@ -74,6 +91,9 @@ public class ProtobufDataFormat extends DataFormatDefinition {
if (this.instanceClass != null) {
setProperty(camelContext, dataFormat, "instanceClass", instanceClass);
}
+ if (this.contentTypeFormat != null) {
+ setProperty(camelContext, dataFormat, "contentTypeFormat", contentTypeFormat);
+ }
if (this.defaultInstance != null) {
setProperty(camelContext, dataFormat, "defaultInstance", defaultInstance);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/ReadMe.md
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/ReadMe.md b/components/camel-protobuf/ReadMe.md
index e7a7c35..a04e533 100644
--- a/components/camel-protobuf/ReadMe.md
+++ b/components/camel-protobuf/ReadMe.md
@@ -1,4 +1,5 @@
# How to upgrade protobuf
+# Use this guide, if your operating system is not supporting by Protobuf Java code generator maven plugin
You need to install the protoc compiler from
@@ -18,10 +19,10 @@ To list the version of the proto compiler.
You then need to compile the sample test source for the `camel-protobuf` component.
-The sample test source is an example taken from the Protobuf Java tutorial at: http://code.google.com/apis/protocolbuffers/docs/javatutorial.html
+The sample test source is an example taken from the Protobuf Java tutorial at: https://developers.google.com/protocol-buffers/docs/javatutorial
cd components/camel-protobuf
- cd src/test/resources
+ cd src/test/proto
protoc --java_out=../java ./addressbook.proto
The generate source code will override the existing. You then need to insert back the checkstyle:off rule. For that take a git diff to see the code changes.
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/pom.xml b/components/camel-protobuf/pom.xml
old mode 100755
new mode 100644
index 1a7e538..6785890
--- a/components/camel-protobuf/pom.xml
+++ b/components/camel-protobuf/pom.xml
@@ -45,6 +45,15 @@
<artifactId>protobuf-java</artifactId>
<version>${protobuf-version}</version>
</dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java-util</artifactId>
+ <version>${protobuf-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
<!-- testing -->
<dependency>
@@ -73,4 +82,35 @@
<scope>test</scope>
</dependency>
</dependencies>
-</project>
+
+ <build>
+ <extensions>
+ <!-- Operating system and CPU architecture detection extension -->
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.4.1.Final</version>
+ </extension>
+ </extensions>
+
+ <plugins>
+ <!-- Protobuf Java code generator plugin -->
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.5.0</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-compile</goal>
+ </goals>
+ <configuration>
+ <protocArtifact>com.google.protobuf:protoc:${protobuf-version}:exe:${os.detected.classifier}</protocArtifact>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc b/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc
index b35cfc3..61276e3 100644
--- a/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc
+++ b/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc
@@ -10,21 +10,21 @@ Protobuf - Protocol Buffers
Camel provides a link:data-format.html[Data Format] to serialse between
Java and the Protocol Buffer protocol. The project's site details why
you may wish to
-http://code.google.com/apis/protocolbuffers/docs/overview.html[choose
+https://developers.google.com/protocol-buffers/docs/overview[choose
this format over xml]. Protocol Buffer is language-neutral and
platform-neutral, so messages produced by your Camel routes may be
consumed by other language implementations.
-http://code.google.com/apis/protocolbuffers/[API Site] +
- http://code.google.com/p/protobuf/[Protobuf Implementation] +
+https://developers.google.com/protocol-buffers/docs/reference/java/[API Site] +
+https://github.com/google/protobuf[Protobuf Implementation] +
-http://code.google.com/apis/protocolbuffers/docs/javatutorial.html[Protobuf
+https://developers.google.com/protocol-buffers/docs/javatutorial[Protobuf
Java Tutorial]
### Protobuf Options
// dataformat options: START
-The Protobuf dataformat supports 2 options which are listed below.
+The Protobuf dataformat supports 3 options which are listed below.
@@ -32,10 +32,26 @@ The Protobuf dataformat supports 2 options which are listed below.
|=======================================================================
| Name | Default | Java Type | Description
| instanceClass | | String | Name of class to use when unarmshalling
+| contentTypeFormat | | String | Defines a content type format in which protobuf message will be serialized/deserialized from(to) the Java been. It can be native protobuf format or json fields representation. The default value is 'native'.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML or application/json for data formats marshalling to JSon etc.
|=======================================================================
// dataformat options: END
+### Content type format (starting from *Camel 2.19*)
+
+It's possible to parse JSON message to convert it to the protobuf format and unparse it back using native util converter.
+To use this option, set contentTypeFormat value to 'json' or call protobuf with second parameter.
+If default instance is not specified, always use native protobuf format.
+The sample code shows below:
+
+[source,java]
+--------------------------------------------------------------------------------------------------
+from("direct:marshal")
+ .unmarshal()
+ .protobuf("org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person", "json")
+ .to("mock:reverse");
+--------------------------------------------------------------------------------------------------
+
### Protobuf overview
This quick overview of how to use Protobuf. For more detail see the
@@ -51,6 +67,7 @@ This is defined in a .proto file as so:
[source,java]
------------------------------------------------------------
+syntax = "proto2";
package org.apache.camel.component.protobuf;
@@ -84,10 +101,46 @@ message AddressBook {
### Generating Java classes
The Protobuf SDK provides a compiler which will generate the Java
-classes for the format we defined in our .proto file. You can run the
-compiler for any additional supported languages you require.
-
-`protoc --java_out=. ./addressbook.proto`
+classes for the format we defined in our .proto file.
+If your operating system is supporting by https://www.xolstice.org/protobuf-maven-plugin[Protobuf Java code generator maven plugin],
+you can automate protobuf Java code generating by adding following configurations to your pom.xml:
+
+Insert operating system and CPU architecture detection extension inside **<build>** tag of the project pom.xml or set ${os.detected.classifier} parameter manually
+[source,xml]
+-------------------------------------------------------------------------
+<extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.4.1.Final</version>
+ </extension>
+</extensions>
+-------------------------------------------------------------------------
+Insert gRPC and protobuf Java code generator plugin **<plugins>** tag of the project pom.xml
+[source,xml]
+-------------------------------------------------------------------------
+<plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.5.0</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-compile</goal>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <protocArtifact>com.google.protobuf:protoc:${protobuf-version}:exe:${os.detected.classifier}</protocArtifact>
+ </configuration>
+ </execution>
+ </executions>
+</plugin>
+-------------------------------------------------------------------------
+
+You can also run the compiler for any additional supported languages you require manually.
+
+`protoc --java_out=. ./proto/addressbook.proto`
This will generate a single Java class named AddressBookProtos which
contains inner classes for Person and AddressBook. Builders are also
@@ -150,15 +203,14 @@ configuring the protobuf data type
To use Protobuf in your camel routes you need to add the a dependency on
*camel-protobuf* which implements this data format.
-If you use maven you could just add the following to your pom.xml,
-substituting the version number for the latest & greatest release (see
-link:download.html[the download page for the latest versions]).
-
-[source,java]
+[source,xml]
-----------------------------------------
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-protobuf</artifactId>
- <version>2.2.0</version>
+ <version>x.x.x</version>
+ <!-- use the same version as your Camel core version -->
</dependency>
-----------------------------------------
+### See Also
+* link:grpc.html[Camel gRPC component]
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java b/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java
index dcd7f4c..b8cba4f 100755
--- a/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java
+++ b/components/camel-protobuf/src/main/java/org/apache/camel/dataformat/protobuf/ProtobufDataFormat.java
@@ -17,11 +17,13 @@
package org.apache.camel.dataformat.protobuf;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.Method;
+
import com.google.protobuf.Message;
import com.google.protobuf.Message.Builder;
-
+import com.google.protobuf.util.JsonFormat;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.CamelException;
@@ -31,13 +33,23 @@ import org.apache.camel.spi.DataFormat;
import org.apache.camel.spi.DataFormatName;
import org.apache.camel.support.ServiceSupport;
import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
+import org.apache.commons.io.IOUtils;
public class ProtobufDataFormat extends ServiceSupport implements DataFormat, DataFormatName, CamelContextAware {
+ public static final String CONTENT_TYPE_FORMAT_NATIVE = "native";
+ public static final String CONTENT_TYPE_FORMAT_JSON = "json";
+
+ private static final String CONTENT_TYPE_HEADER_NATIVE = "application/octet-stream";
+ private static final String CONTENT_TYPE_HEADER_JSON = "application/json";
+
private CamelContext camelContext;
private Message defaultInstance;
private String instanceClassName;
-
+ private boolean contentTypeHeader = false;
+ private String contentTypeFormat = CONTENT_TYPE_FORMAT_NATIVE;
+
public ProtobufDataFormat() {
}
@@ -45,6 +57,11 @@ public class ProtobufDataFormat extends ServiceSupport implements DataFormat, Da
this.defaultInstance = defaultInstance;
}
+ public ProtobufDataFormat(Message defaultInstance, String contentTypeFormat) {
+ this.defaultInstance = defaultInstance;
+ this.contentTypeFormat = contentTypeFormat;
+ }
+
@Override
public String getDataFormatName() {
return "protobuf";
@@ -61,27 +78,61 @@ public class ProtobufDataFormat extends ServiceSupport implements DataFormat, Da
public void setDefaultInstance(Message instance) {
this.defaultInstance = instance;
}
-
+
public void setDefaultInstance(Object instance) {
if (instance instanceof Message) {
- this.defaultInstance = (Message) instance;
+ this.defaultInstance = (Message)instance;
} else {
throw new IllegalArgumentException("The argument for setDefaultInstance should be subClass of com.google.protobuf.Message");
}
}
-
+
public void setInstanceClass(String className) throws Exception {
ObjectHelper.notNull(className, "ProtobufDataFormat instaceClass");
instanceClassName = className;
}
-
+
+ public void setContentTypeHeader(boolean contentTypeHeader) {
+ this.contentTypeHeader = contentTypeHeader;
+ }
+
+ public boolean isContentTypeHeader() {
+ return contentTypeHeader;
+ }
+
+ /*
+ * Defines a content type format in which protobuf message will be
+ * serialized/deserialized from(to) the Java been. It can be native protobuf
+ * format or json fields representation. The default value is 'native'.
+ */
+ public void setContentTypeFormat(String contentTypeFormat) {
+ StringHelper.notEmpty(contentTypeFormat, "ProtobufDataFormat contentTypeFormat");
+ this.contentTypeFormat = contentTypeFormat;
+ }
+
/*
* (non-Javadoc)
* @see org.apache.camel.spi.DataFormat#marshal(org.apache.camel.Exchange,
* java.lang.Object, java.io.OutputStream)
*/
public void marshal(final Exchange exchange, final Object graph, final OutputStream outputStream) throws Exception {
- ((Message)graph).writeTo(outputStream);
+ String contentTypeHeader = CONTENT_TYPE_HEADER_NATIVE;
+ if (contentTypeFormat.equals(CONTENT_TYPE_FORMAT_JSON)) {
+ IOUtils.write(JsonFormat.printer().print((Message)graph), outputStream, "UTF-8");
+ contentTypeHeader = CONTENT_TYPE_HEADER_JSON;
+ } else if (contentTypeFormat.equals(CONTENT_TYPE_FORMAT_NATIVE)) {
+ ((Message)graph).writeTo(outputStream);
+ } else {
+ throw new CamelException("Invalid protobuf content type format: " + contentTypeFormat);
+ }
+
+ if (isContentTypeHeader()) {
+ if (exchange.hasOut()) {
+ exchange.getOut().setHeader(Exchange.CONTENT_TYPE, contentTypeHeader);
+ } else {
+ exchange.getIn().setHeader(Exchange.CONTENT_TYPE, contentTypeHeader);
+ }
+ }
}
/*
@@ -91,8 +142,16 @@ public class ProtobufDataFormat extends ServiceSupport implements DataFormat, Da
*/
public Object unmarshal(final Exchange exchange, final InputStream inputStream) throws Exception {
ObjectHelper.notNull(defaultInstance, "defaultInstance or instanceClassName must be set", this);
+ Builder builder = defaultInstance.newBuilderForType();
+
+ if (contentTypeFormat.equals(CONTENT_TYPE_FORMAT_JSON)) {
+ JsonFormat.parser().ignoringUnknownFields().merge(new InputStreamReader(inputStream), builder);
+ } else if (contentTypeFormat.equals(CONTENT_TYPE_FORMAT_NATIVE)) {
+ builder = defaultInstance.newBuilderForType().mergeFrom(inputStream);
+ } else {
+ throw new CamelException("Invalid protobuf content type format: " + contentTypeFormat);
+ }
- Builder builder = defaultInstance.newBuilderForType().mergeFrom(inputStream);
if (!builder.isInitialized()) {
// TODO which exception should be thrown here?
throw new InvalidPayloadException(exchange, defaultInstance.getClass());
@@ -106,14 +165,13 @@ public class ProtobufDataFormat extends ServiceSupport implements DataFormat, Da
if (Message.class.isAssignableFrom(instanceClass)) {
try {
Method method = instanceClass.getMethod("getDefaultInstance");
- return (Message) method.invoke(null);
+ return (Message)method.invoke(null);
} catch (final Exception ex) {
- throw new CamelException("Can't set the defaultInstance of ProtobufferDataFormat with "
- + className + ", caused by " + ex);
+ throw new CamelException("Can't set the defaultInstance of ProtobufferDataFormat with " + className + ", caused by " + ex);
}
} else {
- throw new CamelException("Can't set the defaultInstance of ProtobufferDataFormat with "
- + className + ", as the class is not a subClass of com.google.protobuf.Message");
+ throw new CamelException("Can't set the defaultInstance of ProtobufferDataFormat with " + className
+ + ", as the class is not a subClass of com.google.protobuf.Message");
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java
new file mode 100644
index 0000000..b1e789e
--- /dev/null
+++ b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalJsonTest.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.protobuf;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.protobuf.generated.AddressBookProtos;
+import org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class ProtobufMarshalAndUnmarshalJsonTest extends CamelTestSupport {
+
+ private final static String PERSON_TEST_NAME = "Martin";
+ private final static int PERSON_TEST_ID = 1234;
+ private final static String PERSON_TEST_JSON = "{\"name\": \"Martin\",\"id\": 1234}";
+
+ @Test
+ public void testMarshalAndUnmarshal() throws Exception {
+ marshalAndUnmarshal("direct:in", "direct:back");
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalWithDSL() throws Exception {
+ marshalAndUnmarshal("direct:marshal", "direct:unmarshalA");
+ }
+
+ private void marshalAndUnmarshal(String inURI, String outURI) throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:reverse");
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(Person.class);
+
+ Object marshalled = template.requestBody(inURI, PERSON_TEST_JSON);
+
+ template.sendBody(outURI, marshalled);
+
+ mock.assertIsSatisfied();
+
+ Person output = mock.getReceivedExchanges().get(0).getIn().getBody(Person.class);
+ assertEquals(PERSON_TEST_NAME, output.getName());
+ assertEquals(PERSON_TEST_ID, output.getId());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ ProtobufDataFormat format = new ProtobufDataFormat(Person.getDefaultInstance(), ProtobufDataFormat.CONTENT_TYPE_FORMAT_JSON);
+
+ from("direct:in").unmarshal(format).to("mock:reverse");
+ from("direct:back").marshal(format);
+
+ from("direct:marshal").unmarshal().protobuf("org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person", "json").to("mock:reverse");
+ from("direct:unmarshalA").marshal().protobuf();
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
index 5a40f44..9ec978e 100644
--- a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
+++ b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.dataformat.protobuf;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-public class ProtobufMarshalAndUnmarshalSpringTest extends ProtobufMarshalAndUnmarshallTest {
+public class ProtobufMarshalAndUnmarshalSpringTest extends ProtobufMarshalAndUnmarshalTest {
protected ClassPathXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("org/apache/camel/dataformat/protobuf/springDataFormat.xml");
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java
new file mode 100644
index 0000000..b407dac
--- /dev/null
+++ b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalTest.java
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.protobuf;
+
+import org.apache.camel.CamelException;
+import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.protobuf.generated.AddressBookProtos;
+import org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class ProtobufMarshalAndUnmarshalTest extends CamelTestSupport {
+
+ @Test
+ public void testMarshalAndUnmarshalWithDataFormat() throws Exception {
+ marshalAndUnmarshal("direct:in", "direct:back");
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalWithDSL1() throws Exception {
+ marshalAndUnmarshal("direct:marshal", "direct:unmarshalA");
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalWithDSL2() throws Exception {
+ marshalAndUnmarshal("direct:marshal", "direct:unmarshalB");
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalWithDSL3() throws Exception {
+ try {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:unmarshalC").unmarshal().protobuf(new CamelException("wrong instance")).to("mock:reverse");
+ }
+ });
+ fail("Expect the exception here");
+ } catch (Exception ex) {
+ assertTrue("Expect FailedToCreateRouteException", ex instanceof FailedToCreateRouteException);
+ assertTrue("Get a wrong reason", ex.getCause() instanceof IllegalArgumentException);
+ }
+ }
+
+ private void marshalAndUnmarshal(String inURI, String outURI) throws Exception {
+ AddressBookProtos.Person input = AddressBookProtos.Person.newBuilder().setName("Martin").setId(1234).build();
+
+ MockEndpoint mock = getMockEndpoint("mock:reverse");
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(Person.class);
+ mock.message(0).body().isEqualTo(input);
+
+ Object marshalled = template.requestBody(inURI, input);
+
+ template.sendBody(outURI, marshalled);
+
+ mock.assertIsSatisfied();
+
+ Person output = mock.getReceivedExchanges().get(0).getIn().getBody(Person.class);
+ assertEquals("Martin", output.getName());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ ProtobufDataFormat format = new ProtobufDataFormat(Person.getDefaultInstance());
+
+ from("direct:in").marshal(format);
+ from("direct:back").unmarshal(format).to("mock:reverse");
+
+ from("direct:marshal").marshal().protobuf();
+ from("direct:unmarshalA").unmarshal().protobuf("org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person").to("mock:reverse");
+
+ from("direct:unmarshalB").unmarshal().protobuf(Person.getDefaultInstance()).to("mock:reverse");
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java b/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java
deleted file mode 100755
index 302f74e..0000000
--- a/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.dataformat.protobuf;
-
-import org.apache.camel.CamelException;
-import org.apache.camel.FailedToCreateRouteException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.dataformat.protobuf.generated.AddressBookProtos;
-import org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class ProtobufMarshalAndUnmarshallTest extends CamelTestSupport {
-
- @Test
- public void testMarshalAndUnmarshalWithDataFormat() throws Exception {
- marshalAndUnmarshal("direct:in", "direct:back");
- }
-
- @Test
- public void testMarshalAndUnmarshalWithDSL1() throws Exception {
- marshalAndUnmarshal("direct:marshal", "direct:unmarshalA");
- }
-
- @Test
- public void testMarshalAndUnmarshalWithDSL2() throws Exception {
- marshalAndUnmarshal("direct:marshal", "direct:unmarshalB");
- }
-
- @Test
- public void testMarshalAndUnmarshalWithDSL3() throws Exception {
- try {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:unmarshalC").unmarshal().protobuf(new CamelException("wrong instance"))
- .to("mock:reverse");
- }
- });
- fail("Expect the exception here");
- } catch (Exception ex) {
- assertTrue("Expect FailedToCreateRouteException", ex instanceof FailedToCreateRouteException);
- assertTrue("Get a wrong reason", ex.getCause() instanceof IllegalArgumentException);
- }
- }
-
-
- private void marshalAndUnmarshal(String inURI, String outURI) throws Exception {
- org.apache.camel.dataformat.protobuf.generated.AddressBookProtos.Person input = AddressBookProtos.Person
- .newBuilder().setName("Martin").setId(1234).build();
-
- MockEndpoint mock = getMockEndpoint("mock:reverse");
- mock.expectedMessageCount(1);
- mock.message(0).body().isInstanceOf(Person.class);
- mock.message(0).body().isEqualTo(input);
-
- Object marshalled = template.requestBody(inURI, input);
-
- template.sendBody(outURI, marshalled);
-
- mock.assertIsSatisfied();
-
- Person output = mock.getReceivedExchanges().get(0).getIn().getBody(Person.class);
- assertEquals("Martin", output.getName());
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- ProtobufDataFormat format = new ProtobufDataFormat(Person.getDefaultInstance());
-
- from("direct:in").marshal(format);
- from("direct:back").unmarshal(format).to("mock:reverse");
-
- from("direct:marshal").marshal().protobuf();
- from("direct:unmarshalA").unmarshal().protobuf("org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person").to("mock:reverse");
-
- from("direct:unmarshalB").unmarshal().protobuf(Person.getDefaultInstance()).to("mock:reverse");
- }
- };
- }
-
-}
[2/5] camel git commit: CAMEL-11135: camel-protobuf component
improvements
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/proto/addressbook.proto
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/proto/addressbook.proto b/components/camel-protobuf/src/test/proto/addressbook.proto
new file mode 100644
index 0000000..7fce508
--- /dev/null
+++ b/components/camel-protobuf/src/test/proto/addressbook.proto
@@ -0,0 +1,29 @@
+syntax = "proto2";
+
+package org.apache.camel.dataformat.protobuf.generated;
+
+option java_package = "org.apache.camel.dataformat.protobuf.generated";
+option java_outer_classname = "AddressBookProtos";
+
+message Person {
+ required string name = 1;
+ required int32 id = 2;
+ optional string email = 3;
+
+ enum PhoneType {
+ MOBILE = 0;
+ HOME = 1;
+ WORK = 2;
+ }
+
+ message PhoneNumber {
+ required string number = 1;
+ required PhoneType type = 2 [default = HOME];
+ }
+
+ repeated PhoneNumber phone = 4;
+}
+
+message AddressBook {
+ repeated Person person = 1;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/proto/readme.txt
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/proto/readme.txt b/components/camel-protobuf/src/test/proto/readme.txt
new file mode 100644
index 0000000..633a81a
--- /dev/null
+++ b/components/camel-protobuf/src/test/proto/readme.txt
@@ -0,0 +1,5 @@
+Examples taken from the Protobuf Java tutorial https://developers.google.com/protocol-buffers/docs/javatutorial
+
+AddressBookProtos.java generation (if your operating system is not supporting by Protobuf Java code generator maven plugin)
+ cd src/test/resources
+ protoc --java_out=. ./addressbook.proto
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/resources/addressbook.proto
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/resources/addressbook.proto b/components/camel-protobuf/src/test/resources/addressbook.proto
deleted file mode 100755
index 7832032..0000000
--- a/components/camel-protobuf/src/test/resources/addressbook.proto
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.camel.dataformat.protobuf.generated;
-
-option java_package = "org.apache.camel.dataformat.protobuf.generated";
-option java_outer_classname = "AddressBookProtos";
-
-message Person {
- required string name = 1;
- required int32 id = 2;
- optional string email = 3;
-
- enum PhoneType {
- MOBILE = 0;
- HOME = 1;
- WORK = 2;
- }
-
- message PhoneNumber {
- required string number = 1;
- optional PhoneType type = 2 [default = HOME];
- }
-
- repeated PhoneNumber phone = 4;
-}
-
-message AddressBook {
- repeated Person person = 1;
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/components/camel-protobuf/src/test/resources/readme.txt
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/test/resources/readme.txt b/components/camel-protobuf/src/test/resources/readme.txt
deleted file mode 100755
index 5d1b22e..0000000
--- a/components/camel-protobuf/src/test/resources/readme.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Examples taken from the Protobuf Java tutorial http://code.google.com/apis/protocolbuffers/docs/javatutorial.html
-
-AddressBookProtos.java generation
- cd src/test/resources
- protoc --java_out=. ./addressbook.proto
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/327dfcbd/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java
index 02fbd99..be7267c 100644
--- a/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java
@@ -31,6 +31,12 @@ public class ProtobufDataFormatConfiguration {
*/
private String instanceClass;
/**
+ * Defines a content type format in which protobuf message will be
+ * serialized/deserialized from(to) the Java been. It can be native protobuf
+ * format or json fields representation. The default value is 'native'.
+ */
+ private String contentTypeFormat;
+ /**
* Whether the data format should set the Content-Type header with the type
* from the data format if the data format is capable of doing so. For
* example application/xml for data formats marshalling to XML or
@@ -46,6 +52,14 @@ public class ProtobufDataFormatConfiguration {
this.instanceClass = instanceClass;
}
+ public String getContentTypeFormat() {
+ return contentTypeFormat;
+ }
+
+ public void setContentTypeFormat(String contentTypeFormat) {
+ this.contentTypeFormat = contentTypeFormat;
+ }
+
public Boolean getContentTypeHeader() {
return contentTypeHeader;
}
[5/5] camel git commit: CAMEL-11135: Polished. This closes #1614
Posted by da...@apache.org.
CAMEL-11135: Polished. This closes #1614
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ab184230
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ab184230
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ab184230
Branch: refs/heads/master
Commit: ab184230708b868ac643de4db5609c1a18f36fcf
Parents: 04d584f
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Apr 11 20:04:39 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Apr 11 20:04:39 2017 +0200
----------------------------------------------------------------------
.../org/apache/camel/model/dataformat/ProtobufDataFormat.java | 7 ++++---
.../camel-protobuf/src/main/docs/protobuf-dataformat.adoc | 2 +-
.../protobuf/springboot/ProtobufDataFormatConfiguration.java | 5 +++--
3 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ab184230/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
index dee0ec4..1d1146b1 100644
--- a/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
+++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
@@ -38,7 +38,7 @@ import org.apache.camel.spi.Metadata;
public class ProtobufDataFormat extends DataFormatDefinition {
@XmlAttribute
private String instanceClass;
- @XmlAttribute
+ @XmlAttribute @Metadata(enums = "native,json", defaultValue = "native")
private String contentTypeFormat;
@XmlTransient
private Object defaultInstance;
@@ -71,8 +71,9 @@ public class ProtobufDataFormat extends DataFormatDefinition {
/**
* Defines a content type format in which protobuf message will be
- * serialized/deserialized from(to) the Java been. It can be native protobuf
- * format or json fields representation. The default value is 'native'.
+ * serialized/deserialized from(to) the Java been.
+ * The format can either be native or json for either native protobuf or json fields representation.
+ * The default value is native.
*/
public void setContentTypeFormat(String contentTypeFormat) {
this.contentTypeFormat = contentTypeFormat;
http://git-wip-us.apache.org/repos/asf/camel/blob/ab184230/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc
----------------------------------------------------------------------
diff --git a/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc b/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc
index 61276e3..c832c73 100644
--- a/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc
+++ b/components/camel-protobuf/src/main/docs/protobuf-dataformat.adoc
@@ -32,7 +32,7 @@ The Protobuf dataformat supports 3 options which are listed below.
|=======================================================================
| Name | Default | Java Type | Description
| instanceClass | | String | Name of class to use when unarmshalling
-| contentTypeFormat | | String | Defines a content type format in which protobuf message will be serialized/deserialized from(to) the Java been. It can be native protobuf format or json fields representation. The default value is 'native'.
+| contentTypeFormat | native | String | Defines a content type format in which protobuf message will be serialized/deserialized from(to) the Java been. The format can either be native or json for either native protobuf or json fields representation. The default value is native.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML or application/json for data formats marshalling to JSon etc.
|=======================================================================
// dataformat options: END
http://git-wip-us.apache.org/repos/asf/camel/blob/ab184230/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java
index be7267c..7b693cc 100644
--- a/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatConfiguration.java
@@ -32,8 +32,9 @@ public class ProtobufDataFormatConfiguration {
private String instanceClass;
/**
* Defines a content type format in which protobuf message will be
- * serialized/deserialized from(to) the Java been. It can be native protobuf
- * format or json fields representation. The default value is 'native'.
+ * serialized/deserialized from(to) the Java been. The format can either be
+ * native or json for either native protobuf or json fields representation.
+ * The default value is native.
*/
private String contentTypeFormat;
/**