├── README.md ├── inventory ├── service-impl │ ├── .gitignore │ ├── .ballerina │ │ └── .gitignore │ ├── Ballerina.toml │ └── mfe.ch03.grpc │ │ ├── inventory_service.bal │ │ └── inventory_pb.bal ├── README.md └── inventory.proto └── product-search ├── .ballerina └── .gitignore └── inventory-client ├── README.md ├── src └── main │ ├── proto │ └── inventory.proto │ └── java │ └── mfe │ └── ch03 │ └── grpc │ ├── InventoryClient.java │ ├── InventoryServiceGrpc.java │ └── Inventory.java └── pom.xml /README.md: -------------------------------------------------------------------------------- 1 | # grpc-microservices -------------------------------------------------------------------------------- /inventory/service-impl/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /product-search/.ballerina/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /inventory/service-impl/.ballerina/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /inventory/service-impl/Ballerina.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | org-name = "kasun" 3 | version = "0.0.1" 4 | 5 | -------------------------------------------------------------------------------- /inventory/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | - Generating Service Skeleton 5 | ``` 6 | ballerina grpc --input inventory.proto --output service-skeleton --mode service 7 | ``` 8 | 9 | 10 | - Generating clinet Stub 11 | 12 | ``` 13 | ballerina grpc --input inventory.proto --output bal-client --mode client 14 | 15 | ``` 16 | 17 | 18 | -------------------------------------------------------------------------------- /product-search/inventory-client/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Running the Java gRPC Client for Inventory Service 3 | 4 | - You can invoke the inventory service via Java gRPC client by running: 5 | ``` mvn exec:java -Dexec.mainClass="mfe.ch03.grpc.InventoryClient" ``` 6 | 7 | - You should see the following output upon the successful invocation of the service. 8 | ``` 9 | ... 10 | Response : Sample Inventory Item Desc for 123 11 | ... 12 | 13 | ``` -------------------------------------------------------------------------------- /inventory/inventory.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package mfe.ch03.grpc; 3 | import "google/protobuf/wrappers.proto"; 4 | 5 | service InventoryService { 6 | rpc getItemByName(google.protobuf.StringValue) returns (Items); 7 | rpc getItemByID(google.protobuf.StringValue) returns (Item); 8 | rpc addItem(Item) returns (google.protobuf.BoolValue); 9 | } 10 | 11 | message Items { 12 | string itemDesc = 1; 13 | repeated Item items = 2; 14 | } 15 | message Item { 16 | string id = 1; 17 | string name = 2; 18 | string description = 3; 19 | } 20 | -------------------------------------------------------------------------------- /product-search/inventory-client/src/main/proto/inventory.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package mfe.ch03.grpc; 3 | import "google/protobuf/wrappers.proto"; 4 | 5 | service InventoryService { 6 | rpc getItemByName(google.protobuf.StringValue) returns (Items); 7 | rpc getItemByID(google.protobuf.StringValue) returns (Item); 8 | rpc addItem(Item) returns (google.protobuf.BoolValue); 9 | } 10 | 11 | message Items { 12 | string itemDesc = 1; 13 | repeated Item items = 2; 14 | } 15 | message Item { 16 | string id = 1; 17 | string name = 2; 18 | string description = 3; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /product-search/inventory-client/src/main/java/mfe/ch03/grpc/InventoryClient.java: -------------------------------------------------------------------------------- 1 | package mfe.ch03.grpc; 2 | 3 | import com.google.protobuf.StringValue; 4 | import io.grpc.ManagedChannel; 5 | import io.grpc.ManagedChannelBuilder; 6 | 7 | public class InventoryClient { 8 | 9 | public static void main(String[] args) { 10 | ManagedChannel channel = ManagedChannelBuilder.forAddress("127.0.0.1", 9000) 11 | .usePlaintext() 12 | .build(); 13 | 14 | InventoryServiceGrpc.InventoryServiceBlockingStub stub 15 | = InventoryServiceGrpc.newBlockingStub(channel); 16 | 17 | Inventory.Item item = stub.getItemByID(StringValue.newBuilder().setValue("123").build()); 18 | System.out.println("Response : " + item.getDescription()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /inventory/service-impl/mfe.ch03.grpc/inventory_service.bal: -------------------------------------------------------------------------------- 1 | import ballerina/grpc; 2 | import ballerina/io; 3 | 4 | endpoint grpc:Listener listener { 5 | host:"localhost", 6 | port:9000 7 | }; 8 | 9 | @grpc:ServiceConfig 10 | 11 | service InventoryService bind listener { 12 | 13 | getItemByName(endpoint caller, string value) { 14 | // Implementation goes here. 15 | 16 | // You should return a Items 17 | } 18 | getItemByID(endpoint caller, string value) { 19 | // Implementation goes here. 20 | Item requested_item; 21 | 22 | // Creating a dummy inventory item 23 | requested_item.id = value; 24 | requested_item.name = "Sample Inventory Item " + value ; 25 | requested_item.description = "Sample Inventory Item Desc for " + value; 26 | 27 | _ = caller->send(requested_item); 28 | _ = caller->complete(); 29 | // You should return a Item 30 | } 31 | addItem(endpoint caller, Item value) { 32 | // Implementation goes here. 33 | 34 | // You should return a boolean 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /product-search/inventory-client/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | mfe.ch03.grpc 5 | inventory-client 6 | jar 7 | 1.0-SNAPSHOT 8 | inventory-client 9 | http://maven.apache.org 10 | 11 | 12 | 13 | io.grpc 14 | grpc-netty-shaded 15 | 1.16.1 16 | 17 | 18 | io.grpc 19 | grpc-protobuf 20 | 1.16.1 21 | 22 | 23 | io.grpc 24 | grpc-stub 25 | 1.16.1 26 | 27 | 28 | 29 | 30 | 31 | 32 | kr.motd.maven 33 | os-maven-plugin 34 | 1.5.0.Final 35 | 36 | 37 | 38 | 39 | org.xolstice.maven.plugins 40 | protobuf-maven-plugin 41 | 0.5.0 42 | 43 | com.google.protobuf:protoc:3.4.0:exe:${os.detected.classifier} 44 | grpc-java 45 | io.grpc:protoc-gen-grpc-java:1.7.0:exe:${os.detected.classifier} 46 | 47 | 48 | 49 | 50 | compile 51 | compile-custom 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /inventory/service-impl/mfe.ch03.grpc/inventory_pb.bal: -------------------------------------------------------------------------------- 1 | import ballerina/grpc; 2 | import ballerina/io; 3 | 4 | public type InventoryServiceBlockingStub object { 5 | public grpc:Client clientEndpoint; 6 | public grpc:Stub stub; 7 | 8 | function initStub (grpc:Client ep) { 9 | grpc:Stub navStub = new; 10 | navStub.initStub(ep, "blocking", DESCRIPTOR_KEY, descriptorMap); 11 | self.stub = navStub; 12 | } 13 | 14 | function getItemByName (string req, grpc:Headers? headers = ()) returns ((Items, grpc:Headers)|error) { 15 | 16 | var unionResp = self.stub.blockingExecute("mfe.ch03.grpc.InventoryService/getItemByName", req, headers = headers); 17 | match unionResp { 18 | error payloadError => { 19 | return payloadError; 20 | } 21 | (any, grpc:Headers) payload => { 22 | grpc:Headers resHeaders; 23 | any result; 24 | (result, resHeaders) = payload; 25 | return (check result, resHeaders); 26 | } 27 | } 28 | } 29 | 30 | function getItemByID (string req, grpc:Headers? headers = ()) returns ((Item, grpc:Headers)|error) { 31 | 32 | var unionResp = self.stub.blockingExecute("mfe.ch03.grpc.InventoryService/getItemByID", req, headers = headers); 33 | match unionResp { 34 | error payloadError => { 35 | return payloadError; 36 | } 37 | (any, grpc:Headers) payload => { 38 | grpc:Headers resHeaders; 39 | any result; 40 | (result, resHeaders) = payload; 41 | return (check result, resHeaders); 42 | } 43 | } 44 | } 45 | 46 | function addItem (Item req, grpc:Headers? headers = ()) returns ((boolean, grpc:Headers)|error) { 47 | 48 | var unionResp = self.stub.blockingExecute("mfe.ch03.grpc.InventoryService/addItem", req, headers = headers); 49 | match unionResp { 50 | error payloadError => { 51 | return payloadError; 52 | } 53 | (any, grpc:Headers) payload => { 54 | grpc:Headers resHeaders; 55 | any result; 56 | (result, resHeaders) = payload; 57 | return (check result, resHeaders); 58 | } 59 | } 60 | } 61 | 62 | }; 63 | 64 | public type InventoryServiceStub object { 65 | public grpc:Client clientEndpoint; 66 | public grpc:Stub stub; 67 | 68 | function initStub (grpc:Client ep) { 69 | grpc:Stub navStub = new; 70 | navStub.initStub(ep, "non-blocking", DESCRIPTOR_KEY, descriptorMap); 71 | self.stub = navStub; 72 | } 73 | 74 | function getItemByName (string req, typedesc listener, grpc:Headers? headers = ()) returns (error?) { 75 | 76 | return self.stub.nonBlockingExecute("mfe.ch03.grpc.InventoryService/getItemByName", req, listener, headers = headers); 77 | } 78 | 79 | function getItemByID (string req, typedesc listener, grpc:Headers? headers = ()) returns (error?) { 80 | 81 | return self.stub.nonBlockingExecute("mfe.ch03.grpc.InventoryService/getItemByID", req, listener, headers = headers); 82 | } 83 | 84 | function addItem (Item req, typedesc listener, grpc:Headers? headers = ()) returns (error?) { 85 | 86 | return self.stub.nonBlockingExecute("mfe.ch03.grpc.InventoryService/addItem", req, listener, headers = headers); 87 | } 88 | 89 | }; 90 | 91 | 92 | public type InventoryServiceBlockingClient object { 93 | public grpc:Client client; 94 | public InventoryServiceBlockingStub stub; 95 | 96 | public function init (grpc:ClientEndpointConfig config) { 97 | // initialize client endpoint. 98 | grpc:Client c = new; 99 | c.init(config); 100 | self.client = c; 101 | // initialize service stub. 102 | InventoryServiceBlockingStub s = new; 103 | s.initStub(c); 104 | self.stub = s; 105 | } 106 | 107 | public function getCallerActions () returns InventoryServiceBlockingStub { 108 | return self.stub; 109 | } 110 | }; 111 | 112 | public type InventoryServiceClient object { 113 | public grpc:Client client; 114 | public InventoryServiceStub stub; 115 | 116 | public function init (grpc:ClientEndpointConfig config) { 117 | // initialize client endpoint. 118 | grpc:Client c = new; 119 | c.init(config); 120 | self.client = c; 121 | // initialize service stub. 122 | InventoryServiceStub s = new; 123 | s.initStub(c); 124 | self.stub = s; 125 | } 126 | 127 | public function getCallerActions () returns InventoryServiceStub { 128 | return self.stub; 129 | } 130 | }; 131 | 132 | 133 | type Items record { 134 | string itemDesc; 135 | Item[] items; 136 | 137 | }; 138 | 139 | type Item record { 140 | string id; 141 | string name; 142 | string description; 143 | 144 | }; 145 | 146 | 147 | @final string DESCRIPTOR_KEY = "mfe.ch03.grpc.inventory.proto"; 148 | map descriptorMap = { 149 | "mfe.ch03.grpc.inventory.proto":"0A0F696E76656E746F72792E70726F746F120D6D66652E636830332E677270631A1E676F6F676C652F70726F746F6275662F77726170706572732E70726F746F224E0A054974656D73121A0A086974656D4465736318012001280952086974656D4465736312290A056974656D7318022003280B32132E6D66652E636830332E677270632E4974656D52056974656D73224C0A044974656D120E0A0269641801200128095202696412120A046E616D6518022001280952046E616D6512200A0B6465736372697074696F6E180320012809520B6465736372697074696F6E32D5010A10496E76656E746F72795365727669636512430A0D6765744974656D42794E616D65121C2E676F6F676C652E70726F746F6275662E537472696E6756616C75651A142E6D66652E636830332E677270632E4974656D7312400A0B6765744974656D42794944121C2E676F6F676C652E70726F746F6275662E537472696E6756616C75651A132E6D66652E636830332E677270632E4974656D123A0A076164644974656D12132E6D66652E636830332E677270632E4974656D1A1A2E676F6F676C652E70726F746F6275662E426F6F6C56616C7565620670726F746F33", 150 | "google.protobuf.wrappers.proto":"0A0E77726170706572732E70726F746F120F676F6F676C652E70726F746F62756622230A0B446F75626C6556616C756512140A0576616C7565180120012801520576616C756522220A0A466C6F617456616C756512140A0576616C7565180120012802520576616C756522220A0A496E74363456616C756512140A0576616C7565180120012803520576616C756522230A0B55496E74363456616C756512140A0576616C7565180120012804520576616C756522220A0A496E74333256616C756512140A0576616C7565180120012805520576616C756522230A0B55496E74333256616C756512140A0576616C756518012001280D520576616C756522210A09426F6F6C56616C756512140A0576616C7565180120012808520576616C756522230A0B537472696E6756616C756512140A0576616C7565180120012809520576616C756522220A0A427974657356616C756512140A0576616C756518012001280C520576616C756542570A13636F6D2E676F6F676C652E70726F746F627566420D577261707065727350726F746F50015A057479706573F80101A20203475042AA021E476F6F676C652E50726F746F6275662E57656C6C4B6E6F776E5479706573620670726F746F33" 151 | 152 | }; 153 | -------------------------------------------------------------------------------- /product-search/inventory-client/src/main/java/mfe/ch03/grpc/InventoryServiceGrpc.java: -------------------------------------------------------------------------------- 1 | package mfe.ch03.grpc; 2 | 3 | import static io.grpc.stub.ClientCalls.asyncUnaryCall; 4 | import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; 5 | import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; 6 | import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; 7 | import static io.grpc.stub.ClientCalls.blockingUnaryCall; 8 | import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; 9 | import static io.grpc.stub.ClientCalls.futureUnaryCall; 10 | import static io.grpc.MethodDescriptor.generateFullMethodName; 11 | import static io.grpc.stub.ServerCalls.asyncUnaryCall; 12 | import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; 13 | import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; 14 | import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; 15 | import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; 16 | import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; 17 | 18 | /** 19 | */ 20 | @javax.annotation.Generated( 21 | value = "by gRPC proto compiler (version 1.7.0)", 22 | comments = "Source: inventory.proto") 23 | public final class InventoryServiceGrpc { 24 | 25 | private InventoryServiceGrpc() {} 26 | 27 | public static final String SERVICE_NAME = "mfe.ch03.grpc.InventoryService"; 28 | 29 | // Static method descriptors that strictly reflect the proto. 30 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") 31 | public static final io.grpc.MethodDescriptor METHOD_GET_ITEM_BY_NAME = 33 | io.grpc.MethodDescriptor.newBuilder() 34 | .setType(io.grpc.MethodDescriptor.MethodType.UNARY) 35 | .setFullMethodName(generateFullMethodName( 36 | "mfe.ch03.grpc.InventoryService", "getItemByName")) 37 | .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 38 | com.google.protobuf.StringValue.getDefaultInstance())) 39 | .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 40 | mfe.ch03.grpc.Inventory.Items.getDefaultInstance())) 41 | .setSchemaDescriptor(new InventoryServiceMethodDescriptorSupplier("getItemByName")) 42 | .build(); 43 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") 44 | public static final io.grpc.MethodDescriptor METHOD_GET_ITEM_BY_ID = 46 | io.grpc.MethodDescriptor.newBuilder() 47 | .setType(io.grpc.MethodDescriptor.MethodType.UNARY) 48 | .setFullMethodName(generateFullMethodName( 49 | "mfe.ch03.grpc.InventoryService", "getItemByID")) 50 | .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 51 | com.google.protobuf.StringValue.getDefaultInstance())) 52 | .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 53 | mfe.ch03.grpc.Inventory.Item.getDefaultInstance())) 54 | .setSchemaDescriptor(new InventoryServiceMethodDescriptorSupplier("getItemByID")) 55 | .build(); 56 | @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") 57 | public static final io.grpc.MethodDescriptor METHOD_ADD_ITEM = 59 | io.grpc.MethodDescriptor.newBuilder() 60 | .setType(io.grpc.MethodDescriptor.MethodType.UNARY) 61 | .setFullMethodName(generateFullMethodName( 62 | "mfe.ch03.grpc.InventoryService", "addItem")) 63 | .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 64 | mfe.ch03.grpc.Inventory.Item.getDefaultInstance())) 65 | .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 66 | com.google.protobuf.BoolValue.getDefaultInstance())) 67 | .setSchemaDescriptor(new InventoryServiceMethodDescriptorSupplier("addItem")) 68 | .build(); 69 | 70 | /** 71 | * Creates a new async stub that supports all call types for the service 72 | */ 73 | public static InventoryServiceStub newStub(io.grpc.Channel channel) { 74 | return new InventoryServiceStub(channel); 75 | } 76 | 77 | /** 78 | * Creates a new blocking-style stub that supports unary and streaming output calls on the service 79 | */ 80 | public static InventoryServiceBlockingStub newBlockingStub( 81 | io.grpc.Channel channel) { 82 | return new InventoryServiceBlockingStub(channel); 83 | } 84 | 85 | /** 86 | * Creates a new ListenableFuture-style stub that supports unary calls on the service 87 | */ 88 | public static InventoryServiceFutureStub newFutureStub( 89 | io.grpc.Channel channel) { 90 | return new InventoryServiceFutureStub(channel); 91 | } 92 | 93 | /** 94 | */ 95 | public static abstract class InventoryServiceImplBase implements io.grpc.BindableService { 96 | 97 | /** 98 | */ 99 | public void getItemByName(com.google.protobuf.StringValue request, 100 | io.grpc.stub.StreamObserver responseObserver) { 101 | asyncUnimplementedUnaryCall(METHOD_GET_ITEM_BY_NAME, responseObserver); 102 | } 103 | 104 | /** 105 | */ 106 | public void getItemByID(com.google.protobuf.StringValue request, 107 | io.grpc.stub.StreamObserver responseObserver) { 108 | asyncUnimplementedUnaryCall(METHOD_GET_ITEM_BY_ID, responseObserver); 109 | } 110 | 111 | /** 112 | */ 113 | public void addItem(mfe.ch03.grpc.Inventory.Item request, 114 | io.grpc.stub.StreamObserver responseObserver) { 115 | asyncUnimplementedUnaryCall(METHOD_ADD_ITEM, responseObserver); 116 | } 117 | 118 | @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { 119 | return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) 120 | .addMethod( 121 | METHOD_GET_ITEM_BY_NAME, 122 | asyncUnaryCall( 123 | new MethodHandlers< 124 | com.google.protobuf.StringValue, 125 | mfe.ch03.grpc.Inventory.Items>( 126 | this, METHODID_GET_ITEM_BY_NAME))) 127 | .addMethod( 128 | METHOD_GET_ITEM_BY_ID, 129 | asyncUnaryCall( 130 | new MethodHandlers< 131 | com.google.protobuf.StringValue, 132 | mfe.ch03.grpc.Inventory.Item>( 133 | this, METHODID_GET_ITEM_BY_ID))) 134 | .addMethod( 135 | METHOD_ADD_ITEM, 136 | asyncUnaryCall( 137 | new MethodHandlers< 138 | mfe.ch03.grpc.Inventory.Item, 139 | com.google.protobuf.BoolValue>( 140 | this, METHODID_ADD_ITEM))) 141 | .build(); 142 | } 143 | } 144 | 145 | /** 146 | */ 147 | public static final class InventoryServiceStub extends io.grpc.stub.AbstractStub { 148 | private InventoryServiceStub(io.grpc.Channel channel) { 149 | super(channel); 150 | } 151 | 152 | private InventoryServiceStub(io.grpc.Channel channel, 153 | io.grpc.CallOptions callOptions) { 154 | super(channel, callOptions); 155 | } 156 | 157 | @java.lang.Override 158 | protected InventoryServiceStub build(io.grpc.Channel channel, 159 | io.grpc.CallOptions callOptions) { 160 | return new InventoryServiceStub(channel, callOptions); 161 | } 162 | 163 | /** 164 | */ 165 | public void getItemByName(com.google.protobuf.StringValue request, 166 | io.grpc.stub.StreamObserver responseObserver) { 167 | asyncUnaryCall( 168 | getChannel().newCall(METHOD_GET_ITEM_BY_NAME, getCallOptions()), request, responseObserver); 169 | } 170 | 171 | /** 172 | */ 173 | public void getItemByID(com.google.protobuf.StringValue request, 174 | io.grpc.stub.StreamObserver responseObserver) { 175 | asyncUnaryCall( 176 | getChannel().newCall(METHOD_GET_ITEM_BY_ID, getCallOptions()), request, responseObserver); 177 | } 178 | 179 | /** 180 | */ 181 | public void addItem(mfe.ch03.grpc.Inventory.Item request, 182 | io.grpc.stub.StreamObserver responseObserver) { 183 | asyncUnaryCall( 184 | getChannel().newCall(METHOD_ADD_ITEM, getCallOptions()), request, responseObserver); 185 | } 186 | } 187 | 188 | /** 189 | */ 190 | public static final class InventoryServiceBlockingStub extends io.grpc.stub.AbstractStub { 191 | private InventoryServiceBlockingStub(io.grpc.Channel channel) { 192 | super(channel); 193 | } 194 | 195 | private InventoryServiceBlockingStub(io.grpc.Channel channel, 196 | io.grpc.CallOptions callOptions) { 197 | super(channel, callOptions); 198 | } 199 | 200 | @java.lang.Override 201 | protected InventoryServiceBlockingStub build(io.grpc.Channel channel, 202 | io.grpc.CallOptions callOptions) { 203 | return new InventoryServiceBlockingStub(channel, callOptions); 204 | } 205 | 206 | /** 207 | */ 208 | public mfe.ch03.grpc.Inventory.Items getItemByName(com.google.protobuf.StringValue request) { 209 | return blockingUnaryCall( 210 | getChannel(), METHOD_GET_ITEM_BY_NAME, getCallOptions(), request); 211 | } 212 | 213 | /** 214 | */ 215 | public mfe.ch03.grpc.Inventory.Item getItemByID(com.google.protobuf.StringValue request) { 216 | return blockingUnaryCall( 217 | getChannel(), METHOD_GET_ITEM_BY_ID, getCallOptions(), request); 218 | } 219 | 220 | /** 221 | */ 222 | public com.google.protobuf.BoolValue addItem(mfe.ch03.grpc.Inventory.Item request) { 223 | return blockingUnaryCall( 224 | getChannel(), METHOD_ADD_ITEM, getCallOptions(), request); 225 | } 226 | } 227 | 228 | /** 229 | */ 230 | public static final class InventoryServiceFutureStub extends io.grpc.stub.AbstractStub { 231 | private InventoryServiceFutureStub(io.grpc.Channel channel) { 232 | super(channel); 233 | } 234 | 235 | private InventoryServiceFutureStub(io.grpc.Channel channel, 236 | io.grpc.CallOptions callOptions) { 237 | super(channel, callOptions); 238 | } 239 | 240 | @java.lang.Override 241 | protected InventoryServiceFutureStub build(io.grpc.Channel channel, 242 | io.grpc.CallOptions callOptions) { 243 | return new InventoryServiceFutureStub(channel, callOptions); 244 | } 245 | 246 | /** 247 | */ 248 | public com.google.common.util.concurrent.ListenableFuture getItemByName( 249 | com.google.protobuf.StringValue request) { 250 | return futureUnaryCall( 251 | getChannel().newCall(METHOD_GET_ITEM_BY_NAME, getCallOptions()), request); 252 | } 253 | 254 | /** 255 | */ 256 | public com.google.common.util.concurrent.ListenableFuture getItemByID( 257 | com.google.protobuf.StringValue request) { 258 | return futureUnaryCall( 259 | getChannel().newCall(METHOD_GET_ITEM_BY_ID, getCallOptions()), request); 260 | } 261 | 262 | /** 263 | */ 264 | public com.google.common.util.concurrent.ListenableFuture addItem( 265 | mfe.ch03.grpc.Inventory.Item request) { 266 | return futureUnaryCall( 267 | getChannel().newCall(METHOD_ADD_ITEM, getCallOptions()), request); 268 | } 269 | } 270 | 271 | private static final int METHODID_GET_ITEM_BY_NAME = 0; 272 | private static final int METHODID_GET_ITEM_BY_ID = 1; 273 | private static final int METHODID_ADD_ITEM = 2; 274 | 275 | private static final class MethodHandlers implements 276 | io.grpc.stub.ServerCalls.UnaryMethod, 277 | io.grpc.stub.ServerCalls.ServerStreamingMethod, 278 | io.grpc.stub.ServerCalls.ClientStreamingMethod, 279 | io.grpc.stub.ServerCalls.BidiStreamingMethod { 280 | private final InventoryServiceImplBase serviceImpl; 281 | private final int methodId; 282 | 283 | MethodHandlers(InventoryServiceImplBase serviceImpl, int methodId) { 284 | this.serviceImpl = serviceImpl; 285 | this.methodId = methodId; 286 | } 287 | 288 | @java.lang.Override 289 | @java.lang.SuppressWarnings("unchecked") 290 | public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { 291 | switch (methodId) { 292 | case METHODID_GET_ITEM_BY_NAME: 293 | serviceImpl.getItemByName((com.google.protobuf.StringValue) request, 294 | (io.grpc.stub.StreamObserver) responseObserver); 295 | break; 296 | case METHODID_GET_ITEM_BY_ID: 297 | serviceImpl.getItemByID((com.google.protobuf.StringValue) request, 298 | (io.grpc.stub.StreamObserver) responseObserver); 299 | break; 300 | case METHODID_ADD_ITEM: 301 | serviceImpl.addItem((mfe.ch03.grpc.Inventory.Item) request, 302 | (io.grpc.stub.StreamObserver) responseObserver); 303 | break; 304 | default: 305 | throw new AssertionError(); 306 | } 307 | } 308 | 309 | @java.lang.Override 310 | @java.lang.SuppressWarnings("unchecked") 311 | public io.grpc.stub.StreamObserver invoke( 312 | io.grpc.stub.StreamObserver responseObserver) { 313 | switch (methodId) { 314 | default: 315 | throw new AssertionError(); 316 | } 317 | } 318 | } 319 | 320 | private static abstract class InventoryServiceBaseDescriptorSupplier 321 | implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { 322 | InventoryServiceBaseDescriptorSupplier() {} 323 | 324 | @java.lang.Override 325 | public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { 326 | return mfe.ch03.grpc.Inventory.getDescriptor(); 327 | } 328 | 329 | @java.lang.Override 330 | public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { 331 | return getFileDescriptor().findServiceByName("InventoryService"); 332 | } 333 | } 334 | 335 | private static final class InventoryServiceFileDescriptorSupplier 336 | extends InventoryServiceBaseDescriptorSupplier { 337 | InventoryServiceFileDescriptorSupplier() {} 338 | } 339 | 340 | private static final class InventoryServiceMethodDescriptorSupplier 341 | extends InventoryServiceBaseDescriptorSupplier 342 | implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { 343 | private final String methodName; 344 | 345 | InventoryServiceMethodDescriptorSupplier(String methodName) { 346 | this.methodName = methodName; 347 | } 348 | 349 | @java.lang.Override 350 | public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { 351 | return getServiceDescriptor().findMethodByName(methodName); 352 | } 353 | } 354 | 355 | private static volatile io.grpc.ServiceDescriptor serviceDescriptor; 356 | 357 | public static io.grpc.ServiceDescriptor getServiceDescriptor() { 358 | io.grpc.ServiceDescriptor result = serviceDescriptor; 359 | if (result == null) { 360 | synchronized (InventoryServiceGrpc.class) { 361 | result = serviceDescriptor; 362 | if (result == null) { 363 | serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) 364 | .setSchemaDescriptor(new InventoryServiceFileDescriptorSupplier()) 365 | .addMethod(METHOD_GET_ITEM_BY_NAME) 366 | .addMethod(METHOD_GET_ITEM_BY_ID) 367 | .addMethod(METHOD_ADD_ITEM) 368 | .build(); 369 | } 370 | } 371 | } 372 | return result; 373 | } 374 | } 375 | -------------------------------------------------------------------------------- /product-search/inventory-client/src/main/java/mfe/ch03/grpc/Inventory.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: inventory.proto 3 | 4 | package mfe.ch03.grpc; 5 | 6 | public final class Inventory { 7 | private Inventory() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface ItemsOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:mfe.ch03.grpc.Items) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | * string itemDesc = 1; 23 | */ 24 | String getItemDesc(); 25 | /** 26 | * string itemDesc = 1; 27 | */ 28 | com.google.protobuf.ByteString 29 | getItemDescBytes(); 30 | 31 | /** 32 | * repeated .mfe.ch03.grpc.Item items = 2; 33 | */ 34 | java.util.List 35 | getItemsList(); 36 | /** 37 | * repeated .mfe.ch03.grpc.Item items = 2; 38 | */ 39 | Inventory.Item getItems(int index); 40 | /** 41 | * repeated .mfe.ch03.grpc.Item items = 2; 42 | */ 43 | int getItemsCount(); 44 | /** 45 | * repeated .mfe.ch03.grpc.Item items = 2; 46 | */ 47 | java.util.List 48 | getItemsOrBuilderList(); 49 | /** 50 | * repeated .mfe.ch03.grpc.Item items = 2; 51 | */ 52 | Inventory.ItemOrBuilder getItemsOrBuilder( 53 | int index); 54 | } 55 | /** 56 | * Protobuf type {@code mfe.ch03.grpc.Items} 57 | */ 58 | public static final class Items extends 59 | com.google.protobuf.GeneratedMessageV3 implements 60 | // @@protoc_insertion_point(message_implements:mfe.ch03.grpc.Items) 61 | ItemsOrBuilder { 62 | private static final long serialVersionUID = 0L; 63 | // Use Items.newBuilder() to construct. 64 | private Items(com.google.protobuf.GeneratedMessageV3.Builder builder) { 65 | super(builder); 66 | } 67 | private Items() { 68 | itemDesc_ = ""; 69 | items_ = java.util.Collections.emptyList(); 70 | } 71 | 72 | @Override 73 | public final com.google.protobuf.UnknownFieldSet 74 | getUnknownFields() { 75 | return this.unknownFields; 76 | } 77 | private Items( 78 | com.google.protobuf.CodedInputStream input, 79 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 80 | throws com.google.protobuf.InvalidProtocolBufferException { 81 | this(); 82 | int mutable_bitField0_ = 0; 83 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 84 | com.google.protobuf.UnknownFieldSet.newBuilder(); 85 | try { 86 | boolean done = false; 87 | while (!done) { 88 | int tag = input.readTag(); 89 | switch (tag) { 90 | case 0: 91 | done = true; 92 | break; 93 | default: { 94 | if (!parseUnknownFieldProto3( 95 | input, unknownFields, extensionRegistry, tag)) { 96 | done = true; 97 | } 98 | break; 99 | } 100 | case 10: { 101 | String s = input.readStringRequireUtf8(); 102 | 103 | itemDesc_ = s; 104 | break; 105 | } 106 | case 18: { 107 | if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { 108 | items_ = new java.util.ArrayList(); 109 | mutable_bitField0_ |= 0x00000002; 110 | } 111 | items_.add( 112 | input.readMessage(Inventory.Item.parser(), extensionRegistry)); 113 | break; 114 | } 115 | } 116 | } 117 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 118 | throw e.setUnfinishedMessage(this); 119 | } catch (java.io.IOException e) { 120 | throw new com.google.protobuf.InvalidProtocolBufferException( 121 | e).setUnfinishedMessage(this); 122 | } finally { 123 | if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { 124 | items_ = java.util.Collections.unmodifiableList(items_); 125 | } 126 | this.unknownFields = unknownFields.build(); 127 | makeExtensionsImmutable(); 128 | } 129 | } 130 | public static final com.google.protobuf.Descriptors.Descriptor 131 | getDescriptor() { 132 | return Inventory.internal_static_mfe_ch03_grpc_Items_descriptor; 133 | } 134 | 135 | protected FieldAccessorTable 136 | internalGetFieldAccessorTable() { 137 | return Inventory.internal_static_mfe_ch03_grpc_Items_fieldAccessorTable 138 | .ensureFieldAccessorsInitialized( 139 | Inventory.Items.class, Inventory.Items.Builder.class); 140 | } 141 | 142 | private int bitField0_; 143 | public static final int ITEMDESC_FIELD_NUMBER = 1; 144 | private volatile Object itemDesc_; 145 | /** 146 | * string itemDesc = 1; 147 | */ 148 | public String getItemDesc() { 149 | Object ref = itemDesc_; 150 | if (ref instanceof String) { 151 | return (String) ref; 152 | } else { 153 | com.google.protobuf.ByteString bs = 154 | (com.google.protobuf.ByteString) ref; 155 | String s = bs.toStringUtf8(); 156 | itemDesc_ = s; 157 | return s; 158 | } 159 | } 160 | /** 161 | * string itemDesc = 1; 162 | */ 163 | public com.google.protobuf.ByteString 164 | getItemDescBytes() { 165 | Object ref = itemDesc_; 166 | if (ref instanceof String) { 167 | com.google.protobuf.ByteString b = 168 | com.google.protobuf.ByteString.copyFromUtf8( 169 | (String) ref); 170 | itemDesc_ = b; 171 | return b; 172 | } else { 173 | return (com.google.protobuf.ByteString) ref; 174 | } 175 | } 176 | 177 | public static final int ITEMS_FIELD_NUMBER = 2; 178 | private java.util.List items_; 179 | /** 180 | * repeated .mfe.ch03.grpc.Item items = 2; 181 | */ 182 | public java.util.List getItemsList() { 183 | return items_; 184 | } 185 | /** 186 | * repeated .mfe.ch03.grpc.Item items = 2; 187 | */ 188 | public java.util.List 189 | getItemsOrBuilderList() { 190 | return items_; 191 | } 192 | /** 193 | * repeated .mfe.ch03.grpc.Item items = 2; 194 | */ 195 | public int getItemsCount() { 196 | return items_.size(); 197 | } 198 | /** 199 | * repeated .mfe.ch03.grpc.Item items = 2; 200 | */ 201 | public Inventory.Item getItems(int index) { 202 | return items_.get(index); 203 | } 204 | /** 205 | * repeated .mfe.ch03.grpc.Item items = 2; 206 | */ 207 | public Inventory.ItemOrBuilder getItemsOrBuilder( 208 | int index) { 209 | return items_.get(index); 210 | } 211 | 212 | private byte memoizedIsInitialized = -1; 213 | public final boolean isInitialized() { 214 | byte isInitialized = memoizedIsInitialized; 215 | if (isInitialized == 1) return true; 216 | if (isInitialized == 0) return false; 217 | 218 | memoizedIsInitialized = 1; 219 | return true; 220 | } 221 | 222 | public void writeTo(com.google.protobuf.CodedOutputStream output) 223 | throws java.io.IOException { 224 | if (!getItemDescBytes().isEmpty()) { 225 | com.google.protobuf.GeneratedMessageV3.writeString(output, 1, itemDesc_); 226 | } 227 | for (int i = 0; i < items_.size(); i++) { 228 | output.writeMessage(2, items_.get(i)); 229 | } 230 | unknownFields.writeTo(output); 231 | } 232 | 233 | public int getSerializedSize() { 234 | int size = memoizedSize; 235 | if (size != -1) return size; 236 | 237 | size = 0; 238 | if (!getItemDescBytes().isEmpty()) { 239 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, itemDesc_); 240 | } 241 | for (int i = 0; i < items_.size(); i++) { 242 | size += com.google.protobuf.CodedOutputStream 243 | .computeMessageSize(2, items_.get(i)); 244 | } 245 | size += unknownFields.getSerializedSize(); 246 | memoizedSize = size; 247 | return size; 248 | } 249 | 250 | @Override 251 | public boolean equals(final Object obj) { 252 | if (obj == this) { 253 | return true; 254 | } 255 | if (!(obj instanceof Inventory.Items)) { 256 | return super.equals(obj); 257 | } 258 | Inventory.Items other = (Inventory.Items) obj; 259 | 260 | boolean result = true; 261 | result = result && getItemDesc() 262 | .equals(other.getItemDesc()); 263 | result = result && getItemsList() 264 | .equals(other.getItemsList()); 265 | result = result && unknownFields.equals(other.unknownFields); 266 | return result; 267 | } 268 | 269 | @Override 270 | public int hashCode() { 271 | if (memoizedHashCode != 0) { 272 | return memoizedHashCode; 273 | } 274 | int hash = 41; 275 | hash = (19 * hash) + getDescriptor().hashCode(); 276 | hash = (37 * hash) + ITEMDESC_FIELD_NUMBER; 277 | hash = (53 * hash) + getItemDesc().hashCode(); 278 | if (getItemsCount() > 0) { 279 | hash = (37 * hash) + ITEMS_FIELD_NUMBER; 280 | hash = (53 * hash) + getItemsList().hashCode(); 281 | } 282 | hash = (29 * hash) + unknownFields.hashCode(); 283 | memoizedHashCode = hash; 284 | return hash; 285 | } 286 | 287 | public static Inventory.Items parseFrom( 288 | java.nio.ByteBuffer data) 289 | throws com.google.protobuf.InvalidProtocolBufferException { 290 | return PARSER.parseFrom(data); 291 | } 292 | public static Inventory.Items parseFrom( 293 | java.nio.ByteBuffer data, 294 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 295 | throws com.google.protobuf.InvalidProtocolBufferException { 296 | return PARSER.parseFrom(data, extensionRegistry); 297 | } 298 | public static Inventory.Items parseFrom( 299 | com.google.protobuf.ByteString data) 300 | throws com.google.protobuf.InvalidProtocolBufferException { 301 | return PARSER.parseFrom(data); 302 | } 303 | public static Inventory.Items parseFrom( 304 | com.google.protobuf.ByteString data, 305 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 306 | throws com.google.protobuf.InvalidProtocolBufferException { 307 | return PARSER.parseFrom(data, extensionRegistry); 308 | } 309 | public static Inventory.Items parseFrom(byte[] data) 310 | throws com.google.protobuf.InvalidProtocolBufferException { 311 | return PARSER.parseFrom(data); 312 | } 313 | public static Inventory.Items parseFrom( 314 | byte[] data, 315 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 316 | throws com.google.protobuf.InvalidProtocolBufferException { 317 | return PARSER.parseFrom(data, extensionRegistry); 318 | } 319 | public static Inventory.Items parseFrom(java.io.InputStream input) 320 | throws java.io.IOException { 321 | return com.google.protobuf.GeneratedMessageV3 322 | .parseWithIOException(PARSER, input); 323 | } 324 | public static Inventory.Items parseFrom( 325 | java.io.InputStream input, 326 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 327 | throws java.io.IOException { 328 | return com.google.protobuf.GeneratedMessageV3 329 | .parseWithIOException(PARSER, input, extensionRegistry); 330 | } 331 | public static Inventory.Items parseDelimitedFrom(java.io.InputStream input) 332 | throws java.io.IOException { 333 | return com.google.protobuf.GeneratedMessageV3 334 | .parseDelimitedWithIOException(PARSER, input); 335 | } 336 | public static Inventory.Items parseDelimitedFrom( 337 | java.io.InputStream input, 338 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 339 | throws java.io.IOException { 340 | return com.google.protobuf.GeneratedMessageV3 341 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 342 | } 343 | public static Inventory.Items parseFrom( 344 | com.google.protobuf.CodedInputStream input) 345 | throws java.io.IOException { 346 | return com.google.protobuf.GeneratedMessageV3 347 | .parseWithIOException(PARSER, input); 348 | } 349 | public static Inventory.Items parseFrom( 350 | com.google.protobuf.CodedInputStream input, 351 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 352 | throws java.io.IOException { 353 | return com.google.protobuf.GeneratedMessageV3 354 | .parseWithIOException(PARSER, input, extensionRegistry); 355 | } 356 | 357 | public Builder newBuilderForType() { return newBuilder(); } 358 | public static Builder newBuilder() { 359 | return DEFAULT_INSTANCE.toBuilder(); 360 | } 361 | public static Builder newBuilder(Inventory.Items prototype) { 362 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 363 | } 364 | public Builder toBuilder() { 365 | return this == DEFAULT_INSTANCE 366 | ? new Builder() : new Builder().mergeFrom(this); 367 | } 368 | 369 | @Override 370 | protected Builder newBuilderForType( 371 | BuilderParent parent) { 372 | Builder builder = new Builder(parent); 373 | return builder; 374 | } 375 | /** 376 | * Protobuf type {@code mfe.ch03.grpc.Items} 377 | */ 378 | public static final class Builder extends 379 | com.google.protobuf.GeneratedMessageV3.Builder implements 380 | // @@protoc_insertion_point(builder_implements:mfe.ch03.grpc.Items) 381 | Inventory.ItemsOrBuilder { 382 | public static final com.google.protobuf.Descriptors.Descriptor 383 | getDescriptor() { 384 | return Inventory.internal_static_mfe_ch03_grpc_Items_descriptor; 385 | } 386 | 387 | protected FieldAccessorTable 388 | internalGetFieldAccessorTable() { 389 | return Inventory.internal_static_mfe_ch03_grpc_Items_fieldAccessorTable 390 | .ensureFieldAccessorsInitialized( 391 | Inventory.Items.class, Inventory.Items.Builder.class); 392 | } 393 | 394 | // Construct using mfe.ch03.grpc.Inventory.Items.newBuilder() 395 | private Builder() { 396 | maybeForceBuilderInitialization(); 397 | } 398 | 399 | private Builder( 400 | BuilderParent parent) { 401 | super(parent); 402 | maybeForceBuilderInitialization(); 403 | } 404 | private void maybeForceBuilderInitialization() { 405 | if (com.google.protobuf.GeneratedMessageV3 406 | .alwaysUseFieldBuilders) { 407 | getItemsFieldBuilder(); 408 | } 409 | } 410 | public Builder clear() { 411 | super.clear(); 412 | itemDesc_ = ""; 413 | 414 | if (itemsBuilder_ == null) { 415 | items_ = java.util.Collections.emptyList(); 416 | bitField0_ = (bitField0_ & ~0x00000002); 417 | } else { 418 | itemsBuilder_.clear(); 419 | } 420 | return this; 421 | } 422 | 423 | public com.google.protobuf.Descriptors.Descriptor 424 | getDescriptorForType() { 425 | return Inventory.internal_static_mfe_ch03_grpc_Items_descriptor; 426 | } 427 | 428 | public Inventory.Items getDefaultInstanceForType() { 429 | return Inventory.Items.getDefaultInstance(); 430 | } 431 | 432 | public Inventory.Items build() { 433 | Inventory.Items result = buildPartial(); 434 | if (!result.isInitialized()) { 435 | throw newUninitializedMessageException(result); 436 | } 437 | return result; 438 | } 439 | 440 | public Inventory.Items buildPartial() { 441 | Inventory.Items result = new Inventory.Items(this); 442 | int from_bitField0_ = bitField0_; 443 | int to_bitField0_ = 0; 444 | result.itemDesc_ = itemDesc_; 445 | if (itemsBuilder_ == null) { 446 | if (((bitField0_ & 0x00000002) == 0x00000002)) { 447 | items_ = java.util.Collections.unmodifiableList(items_); 448 | bitField0_ = (bitField0_ & ~0x00000002); 449 | } 450 | result.items_ = items_; 451 | } else { 452 | result.items_ = itemsBuilder_.build(); 453 | } 454 | result.bitField0_ = to_bitField0_; 455 | onBuilt(); 456 | return result; 457 | } 458 | 459 | public Builder clone() { 460 | return (Builder) super.clone(); 461 | } 462 | public Builder setField( 463 | com.google.protobuf.Descriptors.FieldDescriptor field, 464 | Object value) { 465 | return (Builder) super.setField(field, value); 466 | } 467 | public Builder clearField( 468 | com.google.protobuf.Descriptors.FieldDescriptor field) { 469 | return (Builder) super.clearField(field); 470 | } 471 | public Builder clearOneof( 472 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 473 | return (Builder) super.clearOneof(oneof); 474 | } 475 | public Builder setRepeatedField( 476 | com.google.protobuf.Descriptors.FieldDescriptor field, 477 | int index, Object value) { 478 | return (Builder) super.setRepeatedField(field, index, value); 479 | } 480 | public Builder addRepeatedField( 481 | com.google.protobuf.Descriptors.FieldDescriptor field, 482 | Object value) { 483 | return (Builder) super.addRepeatedField(field, value); 484 | } 485 | public Builder mergeFrom(com.google.protobuf.Message other) { 486 | if (other instanceof Inventory.Items) { 487 | return mergeFrom((Inventory.Items)other); 488 | } else { 489 | super.mergeFrom(other); 490 | return this; 491 | } 492 | } 493 | 494 | public Builder mergeFrom(Inventory.Items other) { 495 | if (other == Inventory.Items.getDefaultInstance()) return this; 496 | if (!other.getItemDesc().isEmpty()) { 497 | itemDesc_ = other.itemDesc_; 498 | onChanged(); 499 | } 500 | if (itemsBuilder_ == null) { 501 | if (!other.items_.isEmpty()) { 502 | if (items_.isEmpty()) { 503 | items_ = other.items_; 504 | bitField0_ = (bitField0_ & ~0x00000002); 505 | } else { 506 | ensureItemsIsMutable(); 507 | items_.addAll(other.items_); 508 | } 509 | onChanged(); 510 | } 511 | } else { 512 | if (!other.items_.isEmpty()) { 513 | if (itemsBuilder_.isEmpty()) { 514 | itemsBuilder_.dispose(); 515 | itemsBuilder_ = null; 516 | items_ = other.items_; 517 | bitField0_ = (bitField0_ & ~0x00000002); 518 | itemsBuilder_ = 519 | com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? 520 | getItemsFieldBuilder() : null; 521 | } else { 522 | itemsBuilder_.addAllMessages(other.items_); 523 | } 524 | } 525 | } 526 | this.mergeUnknownFields(other.unknownFields); 527 | onChanged(); 528 | return this; 529 | } 530 | 531 | public final boolean isInitialized() { 532 | return true; 533 | } 534 | 535 | public Builder mergeFrom( 536 | com.google.protobuf.CodedInputStream input, 537 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 538 | throws java.io.IOException { 539 | Inventory.Items parsedMessage = null; 540 | try { 541 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 542 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 543 | parsedMessage = (Inventory.Items) e.getUnfinishedMessage(); 544 | throw e.unwrapIOException(); 545 | } finally { 546 | if (parsedMessage != null) { 547 | mergeFrom(parsedMessage); 548 | } 549 | } 550 | return this; 551 | } 552 | private int bitField0_; 553 | 554 | private Object itemDesc_ = ""; 555 | /** 556 | * string itemDesc = 1; 557 | */ 558 | public String getItemDesc() { 559 | Object ref = itemDesc_; 560 | if (!(ref instanceof String)) { 561 | com.google.protobuf.ByteString bs = 562 | (com.google.protobuf.ByteString) ref; 563 | String s = bs.toStringUtf8(); 564 | itemDesc_ = s; 565 | return s; 566 | } else { 567 | return (String) ref; 568 | } 569 | } 570 | /** 571 | * string itemDesc = 1; 572 | */ 573 | public com.google.protobuf.ByteString 574 | getItemDescBytes() { 575 | Object ref = itemDesc_; 576 | if (ref instanceof String) { 577 | com.google.protobuf.ByteString b = 578 | com.google.protobuf.ByteString.copyFromUtf8( 579 | (String) ref); 580 | itemDesc_ = b; 581 | return b; 582 | } else { 583 | return (com.google.protobuf.ByteString) ref; 584 | } 585 | } 586 | /** 587 | * string itemDesc = 1; 588 | */ 589 | public Builder setItemDesc( 590 | String value) { 591 | if (value == null) { 592 | throw new NullPointerException(); 593 | } 594 | 595 | itemDesc_ = value; 596 | onChanged(); 597 | return this; 598 | } 599 | /** 600 | * string itemDesc = 1; 601 | */ 602 | public Builder clearItemDesc() { 603 | 604 | itemDesc_ = getDefaultInstance().getItemDesc(); 605 | onChanged(); 606 | return this; 607 | } 608 | /** 609 | * string itemDesc = 1; 610 | */ 611 | public Builder setItemDescBytes( 612 | com.google.protobuf.ByteString value) { 613 | if (value == null) { 614 | throw new NullPointerException(); 615 | } 616 | checkByteStringIsUtf8(value); 617 | 618 | itemDesc_ = value; 619 | onChanged(); 620 | return this; 621 | } 622 | 623 | private java.util.List items_ = 624 | java.util.Collections.emptyList(); 625 | private void ensureItemsIsMutable() { 626 | if (!((bitField0_ & 0x00000002) == 0x00000002)) { 627 | items_ = new java.util.ArrayList(items_); 628 | bitField0_ |= 0x00000002; 629 | } 630 | } 631 | 632 | private com.google.protobuf.RepeatedFieldBuilderV3< 633 | Item, Item.Builder, ItemOrBuilder> itemsBuilder_; 634 | 635 | /** 636 | * repeated .mfe.ch03.grpc.Item items = 2; 637 | */ 638 | public java.util.List getItemsList() { 639 | if (itemsBuilder_ == null) { 640 | return java.util.Collections.unmodifiableList(items_); 641 | } else { 642 | return itemsBuilder_.getMessageList(); 643 | } 644 | } 645 | /** 646 | * repeated .mfe.ch03.grpc.Item items = 2; 647 | */ 648 | public int getItemsCount() { 649 | if (itemsBuilder_ == null) { 650 | return items_.size(); 651 | } else { 652 | return itemsBuilder_.getCount(); 653 | } 654 | } 655 | /** 656 | * repeated .mfe.ch03.grpc.Item items = 2; 657 | */ 658 | public Inventory.Item getItems(int index) { 659 | if (itemsBuilder_ == null) { 660 | return items_.get(index); 661 | } else { 662 | return itemsBuilder_.getMessage(index); 663 | } 664 | } 665 | /** 666 | * repeated .mfe.ch03.grpc.Item items = 2; 667 | */ 668 | public Builder setItems( 669 | int index, Inventory.Item value) { 670 | if (itemsBuilder_ == null) { 671 | if (value == null) { 672 | throw new NullPointerException(); 673 | } 674 | ensureItemsIsMutable(); 675 | items_.set(index, value); 676 | onChanged(); 677 | } else { 678 | itemsBuilder_.setMessage(index, value); 679 | } 680 | return this; 681 | } 682 | /** 683 | * repeated .mfe.ch03.grpc.Item items = 2; 684 | */ 685 | public Builder setItems( 686 | int index, Inventory.Item.Builder builderForValue) { 687 | if (itemsBuilder_ == null) { 688 | ensureItemsIsMutable(); 689 | items_.set(index, builderForValue.build()); 690 | onChanged(); 691 | } else { 692 | itemsBuilder_.setMessage(index, builderForValue.build()); 693 | } 694 | return this; 695 | } 696 | /** 697 | * repeated .mfe.ch03.grpc.Item items = 2; 698 | */ 699 | public Builder addItems(Inventory.Item value) { 700 | if (itemsBuilder_ == null) { 701 | if (value == null) { 702 | throw new NullPointerException(); 703 | } 704 | ensureItemsIsMutable(); 705 | items_.add(value); 706 | onChanged(); 707 | } else { 708 | itemsBuilder_.addMessage(value); 709 | } 710 | return this; 711 | } 712 | /** 713 | * repeated .mfe.ch03.grpc.Item items = 2; 714 | */ 715 | public Builder addItems( 716 | int index, Inventory.Item value) { 717 | if (itemsBuilder_ == null) { 718 | if (value == null) { 719 | throw new NullPointerException(); 720 | } 721 | ensureItemsIsMutable(); 722 | items_.add(index, value); 723 | onChanged(); 724 | } else { 725 | itemsBuilder_.addMessage(index, value); 726 | } 727 | return this; 728 | } 729 | /** 730 | * repeated .mfe.ch03.grpc.Item items = 2; 731 | */ 732 | public Builder addItems( 733 | Inventory.Item.Builder builderForValue) { 734 | if (itemsBuilder_ == null) { 735 | ensureItemsIsMutable(); 736 | items_.add(builderForValue.build()); 737 | onChanged(); 738 | } else { 739 | itemsBuilder_.addMessage(builderForValue.build()); 740 | } 741 | return this; 742 | } 743 | /** 744 | * repeated .mfe.ch03.grpc.Item items = 2; 745 | */ 746 | public Builder addItems( 747 | int index, Inventory.Item.Builder builderForValue) { 748 | if (itemsBuilder_ == null) { 749 | ensureItemsIsMutable(); 750 | items_.add(index, builderForValue.build()); 751 | onChanged(); 752 | } else { 753 | itemsBuilder_.addMessage(index, builderForValue.build()); 754 | } 755 | return this; 756 | } 757 | /** 758 | * repeated .mfe.ch03.grpc.Item items = 2; 759 | */ 760 | public Builder addAllItems( 761 | Iterable values) { 762 | if (itemsBuilder_ == null) { 763 | ensureItemsIsMutable(); 764 | com.google.protobuf.AbstractMessageLite.Builder.addAll( 765 | values, items_); 766 | onChanged(); 767 | } else { 768 | itemsBuilder_.addAllMessages(values); 769 | } 770 | return this; 771 | } 772 | /** 773 | * repeated .mfe.ch03.grpc.Item items = 2; 774 | */ 775 | public Builder clearItems() { 776 | if (itemsBuilder_ == null) { 777 | items_ = java.util.Collections.emptyList(); 778 | bitField0_ = (bitField0_ & ~0x00000002); 779 | onChanged(); 780 | } else { 781 | itemsBuilder_.clear(); 782 | } 783 | return this; 784 | } 785 | /** 786 | * repeated .mfe.ch03.grpc.Item items = 2; 787 | */ 788 | public Builder removeItems(int index) { 789 | if (itemsBuilder_ == null) { 790 | ensureItemsIsMutable(); 791 | items_.remove(index); 792 | onChanged(); 793 | } else { 794 | itemsBuilder_.remove(index); 795 | } 796 | return this; 797 | } 798 | /** 799 | * repeated .mfe.ch03.grpc.Item items = 2; 800 | */ 801 | public Inventory.Item.Builder getItemsBuilder( 802 | int index) { 803 | return getItemsFieldBuilder().getBuilder(index); 804 | } 805 | /** 806 | * repeated .mfe.ch03.grpc.Item items = 2; 807 | */ 808 | public Inventory.ItemOrBuilder getItemsOrBuilder( 809 | int index) { 810 | if (itemsBuilder_ == null) { 811 | return items_.get(index); } else { 812 | return itemsBuilder_.getMessageOrBuilder(index); 813 | } 814 | } 815 | /** 816 | * repeated .mfe.ch03.grpc.Item items = 2; 817 | */ 818 | public java.util.List 819 | getItemsOrBuilderList() { 820 | if (itemsBuilder_ != null) { 821 | return itemsBuilder_.getMessageOrBuilderList(); 822 | } else { 823 | return java.util.Collections.unmodifiableList(items_); 824 | } 825 | } 826 | /** 827 | * repeated .mfe.ch03.grpc.Item items = 2; 828 | */ 829 | public Inventory.Item.Builder addItemsBuilder() { 830 | return getItemsFieldBuilder().addBuilder( 831 | Inventory.Item.getDefaultInstance()); 832 | } 833 | /** 834 | * repeated .mfe.ch03.grpc.Item items = 2; 835 | */ 836 | public Inventory.Item.Builder addItemsBuilder( 837 | int index) { 838 | return getItemsFieldBuilder().addBuilder( 839 | index, Inventory.Item.getDefaultInstance()); 840 | } 841 | /** 842 | * repeated .mfe.ch03.grpc.Item items = 2; 843 | */ 844 | public java.util.List 845 | getItemsBuilderList() { 846 | return getItemsFieldBuilder().getBuilderList(); 847 | } 848 | private com.google.protobuf.RepeatedFieldBuilderV3< 849 | Item, Item.Builder, ItemOrBuilder> 850 | getItemsFieldBuilder() { 851 | if (itemsBuilder_ == null) { 852 | itemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< 853 | Item, Item.Builder, ItemOrBuilder>( 854 | items_, 855 | ((bitField0_ & 0x00000002) == 0x00000002), 856 | getParentForChildren(), 857 | isClean()); 858 | items_ = null; 859 | } 860 | return itemsBuilder_; 861 | } 862 | public final Builder setUnknownFields( 863 | final com.google.protobuf.UnknownFieldSet unknownFields) { 864 | return super.setUnknownFieldsProto3(unknownFields); 865 | } 866 | 867 | public final Builder mergeUnknownFields( 868 | final com.google.protobuf.UnknownFieldSet unknownFields) { 869 | return super.mergeUnknownFields(unknownFields); 870 | } 871 | 872 | 873 | // @@protoc_insertion_point(builder_scope:mfe.ch03.grpc.Items) 874 | } 875 | 876 | // @@protoc_insertion_point(class_scope:mfe.ch03.grpc.Items) 877 | private static final Inventory.Items DEFAULT_INSTANCE; 878 | static { 879 | DEFAULT_INSTANCE = new Inventory.Items(); 880 | } 881 | 882 | public static Inventory.Items getDefaultInstance() { 883 | return DEFAULT_INSTANCE; 884 | } 885 | 886 | private static final com.google.protobuf.Parser 887 | PARSER = new com.google.protobuf.AbstractParser() { 888 | public Items parsePartialFrom( 889 | com.google.protobuf.CodedInputStream input, 890 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 891 | throws com.google.protobuf.InvalidProtocolBufferException { 892 | return new Items(input, extensionRegistry); 893 | } 894 | }; 895 | 896 | public static com.google.protobuf.Parser parser() { 897 | return PARSER; 898 | } 899 | 900 | @Override 901 | public com.google.protobuf.Parser getParserForType() { 902 | return PARSER; 903 | } 904 | 905 | public Inventory.Items getDefaultInstanceForType() { 906 | return DEFAULT_INSTANCE; 907 | } 908 | 909 | } 910 | 911 | public interface ItemOrBuilder extends 912 | // @@protoc_insertion_point(interface_extends:mfe.ch03.grpc.Item) 913 | com.google.protobuf.MessageOrBuilder { 914 | 915 | /** 916 | * string id = 1; 917 | */ 918 | String getId(); 919 | /** 920 | * string id = 1; 921 | */ 922 | com.google.protobuf.ByteString 923 | getIdBytes(); 924 | 925 | /** 926 | * string name = 2; 927 | */ 928 | String getName(); 929 | /** 930 | * string name = 2; 931 | */ 932 | com.google.protobuf.ByteString 933 | getNameBytes(); 934 | 935 | /** 936 | * string description = 3; 937 | */ 938 | String getDescription(); 939 | /** 940 | * string description = 3; 941 | */ 942 | com.google.protobuf.ByteString 943 | getDescriptionBytes(); 944 | } 945 | /** 946 | * Protobuf type {@code mfe.ch03.grpc.Item} 947 | */ 948 | public static final class Item extends 949 | com.google.protobuf.GeneratedMessageV3 implements 950 | // @@protoc_insertion_point(message_implements:mfe.ch03.grpc.Item) 951 | ItemOrBuilder { 952 | private static final long serialVersionUID = 0L; 953 | // Use Item.newBuilder() to construct. 954 | private Item(com.google.protobuf.GeneratedMessageV3.Builder builder) { 955 | super(builder); 956 | } 957 | private Item() { 958 | id_ = ""; 959 | name_ = ""; 960 | description_ = ""; 961 | } 962 | 963 | @Override 964 | public final com.google.protobuf.UnknownFieldSet 965 | getUnknownFields() { 966 | return this.unknownFields; 967 | } 968 | private Item( 969 | com.google.protobuf.CodedInputStream input, 970 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 971 | throws com.google.protobuf.InvalidProtocolBufferException { 972 | this(); 973 | int mutable_bitField0_ = 0; 974 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 975 | com.google.protobuf.UnknownFieldSet.newBuilder(); 976 | try { 977 | boolean done = false; 978 | while (!done) { 979 | int tag = input.readTag(); 980 | switch (tag) { 981 | case 0: 982 | done = true; 983 | break; 984 | default: { 985 | if (!parseUnknownFieldProto3( 986 | input, unknownFields, extensionRegistry, tag)) { 987 | done = true; 988 | } 989 | break; 990 | } 991 | case 10: { 992 | String s = input.readStringRequireUtf8(); 993 | 994 | id_ = s; 995 | break; 996 | } 997 | case 18: { 998 | String s = input.readStringRequireUtf8(); 999 | 1000 | name_ = s; 1001 | break; 1002 | } 1003 | case 26: { 1004 | String s = input.readStringRequireUtf8(); 1005 | 1006 | description_ = s; 1007 | break; 1008 | } 1009 | } 1010 | } 1011 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 1012 | throw e.setUnfinishedMessage(this); 1013 | } catch (java.io.IOException e) { 1014 | throw new com.google.protobuf.InvalidProtocolBufferException( 1015 | e).setUnfinishedMessage(this); 1016 | } finally { 1017 | this.unknownFields = unknownFields.build(); 1018 | makeExtensionsImmutable(); 1019 | } 1020 | } 1021 | public static final com.google.protobuf.Descriptors.Descriptor 1022 | getDescriptor() { 1023 | return Inventory.internal_static_mfe_ch03_grpc_Item_descriptor; 1024 | } 1025 | 1026 | protected FieldAccessorTable 1027 | internalGetFieldAccessorTable() { 1028 | return Inventory.internal_static_mfe_ch03_grpc_Item_fieldAccessorTable 1029 | .ensureFieldAccessorsInitialized( 1030 | Inventory.Item.class, Inventory.Item.Builder.class); 1031 | } 1032 | 1033 | public static final int ID_FIELD_NUMBER = 1; 1034 | private volatile Object id_; 1035 | /** 1036 | * string id = 1; 1037 | */ 1038 | public String getId() { 1039 | Object ref = id_; 1040 | if (ref instanceof String) { 1041 | return (String) ref; 1042 | } else { 1043 | com.google.protobuf.ByteString bs = 1044 | (com.google.protobuf.ByteString) ref; 1045 | String s = bs.toStringUtf8(); 1046 | id_ = s; 1047 | return s; 1048 | } 1049 | } 1050 | /** 1051 | * string id = 1; 1052 | */ 1053 | public com.google.protobuf.ByteString 1054 | getIdBytes() { 1055 | Object ref = id_; 1056 | if (ref instanceof String) { 1057 | com.google.protobuf.ByteString b = 1058 | com.google.protobuf.ByteString.copyFromUtf8( 1059 | (String) ref); 1060 | id_ = b; 1061 | return b; 1062 | } else { 1063 | return (com.google.protobuf.ByteString) ref; 1064 | } 1065 | } 1066 | 1067 | public static final int NAME_FIELD_NUMBER = 2; 1068 | private volatile Object name_; 1069 | /** 1070 | * string name = 2; 1071 | */ 1072 | public String getName() { 1073 | Object ref = name_; 1074 | if (ref instanceof String) { 1075 | return (String) ref; 1076 | } else { 1077 | com.google.protobuf.ByteString bs = 1078 | (com.google.protobuf.ByteString) ref; 1079 | String s = bs.toStringUtf8(); 1080 | name_ = s; 1081 | return s; 1082 | } 1083 | } 1084 | /** 1085 | * string name = 2; 1086 | */ 1087 | public com.google.protobuf.ByteString 1088 | getNameBytes() { 1089 | Object ref = name_; 1090 | if (ref instanceof String) { 1091 | com.google.protobuf.ByteString b = 1092 | com.google.protobuf.ByteString.copyFromUtf8( 1093 | (String) ref); 1094 | name_ = b; 1095 | return b; 1096 | } else { 1097 | return (com.google.protobuf.ByteString) ref; 1098 | } 1099 | } 1100 | 1101 | public static final int DESCRIPTION_FIELD_NUMBER = 3; 1102 | private volatile Object description_; 1103 | /** 1104 | * string description = 3; 1105 | */ 1106 | public String getDescription() { 1107 | Object ref = description_; 1108 | if (ref instanceof String) { 1109 | return (String) ref; 1110 | } else { 1111 | com.google.protobuf.ByteString bs = 1112 | (com.google.protobuf.ByteString) ref; 1113 | String s = bs.toStringUtf8(); 1114 | description_ = s; 1115 | return s; 1116 | } 1117 | } 1118 | /** 1119 | * string description = 3; 1120 | */ 1121 | public com.google.protobuf.ByteString 1122 | getDescriptionBytes() { 1123 | Object ref = description_; 1124 | if (ref instanceof String) { 1125 | com.google.protobuf.ByteString b = 1126 | com.google.protobuf.ByteString.copyFromUtf8( 1127 | (String) ref); 1128 | description_ = b; 1129 | return b; 1130 | } else { 1131 | return (com.google.protobuf.ByteString) ref; 1132 | } 1133 | } 1134 | 1135 | private byte memoizedIsInitialized = -1; 1136 | public final boolean isInitialized() { 1137 | byte isInitialized = memoizedIsInitialized; 1138 | if (isInitialized == 1) return true; 1139 | if (isInitialized == 0) return false; 1140 | 1141 | memoizedIsInitialized = 1; 1142 | return true; 1143 | } 1144 | 1145 | public void writeTo(com.google.protobuf.CodedOutputStream output) 1146 | throws java.io.IOException { 1147 | if (!getIdBytes().isEmpty()) { 1148 | com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_); 1149 | } 1150 | if (!getNameBytes().isEmpty()) { 1151 | com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); 1152 | } 1153 | if (!getDescriptionBytes().isEmpty()) { 1154 | com.google.protobuf.GeneratedMessageV3.writeString(output, 3, description_); 1155 | } 1156 | unknownFields.writeTo(output); 1157 | } 1158 | 1159 | public int getSerializedSize() { 1160 | int size = memoizedSize; 1161 | if (size != -1) return size; 1162 | 1163 | size = 0; 1164 | if (!getIdBytes().isEmpty()) { 1165 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_); 1166 | } 1167 | if (!getNameBytes().isEmpty()) { 1168 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); 1169 | } 1170 | if (!getDescriptionBytes().isEmpty()) { 1171 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, description_); 1172 | } 1173 | size += unknownFields.getSerializedSize(); 1174 | memoizedSize = size; 1175 | return size; 1176 | } 1177 | 1178 | @Override 1179 | public boolean equals(final Object obj) { 1180 | if (obj == this) { 1181 | return true; 1182 | } 1183 | if (!(obj instanceof Inventory.Item)) { 1184 | return super.equals(obj); 1185 | } 1186 | Inventory.Item other = (Inventory.Item) obj; 1187 | 1188 | boolean result = true; 1189 | result = result && getId() 1190 | .equals(other.getId()); 1191 | result = result && getName() 1192 | .equals(other.getName()); 1193 | result = result && getDescription() 1194 | .equals(other.getDescription()); 1195 | result = result && unknownFields.equals(other.unknownFields); 1196 | return result; 1197 | } 1198 | 1199 | @Override 1200 | public int hashCode() { 1201 | if (memoizedHashCode != 0) { 1202 | return memoizedHashCode; 1203 | } 1204 | int hash = 41; 1205 | hash = (19 * hash) + getDescriptor().hashCode(); 1206 | hash = (37 * hash) + ID_FIELD_NUMBER; 1207 | hash = (53 * hash) + getId().hashCode(); 1208 | hash = (37 * hash) + NAME_FIELD_NUMBER; 1209 | hash = (53 * hash) + getName().hashCode(); 1210 | hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER; 1211 | hash = (53 * hash) + getDescription().hashCode(); 1212 | hash = (29 * hash) + unknownFields.hashCode(); 1213 | memoizedHashCode = hash; 1214 | return hash; 1215 | } 1216 | 1217 | public static Inventory.Item parseFrom( 1218 | java.nio.ByteBuffer data) 1219 | throws com.google.protobuf.InvalidProtocolBufferException { 1220 | return PARSER.parseFrom(data); 1221 | } 1222 | public static Inventory.Item parseFrom( 1223 | java.nio.ByteBuffer data, 1224 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1225 | throws com.google.protobuf.InvalidProtocolBufferException { 1226 | return PARSER.parseFrom(data, extensionRegistry); 1227 | } 1228 | public static Inventory.Item parseFrom( 1229 | com.google.protobuf.ByteString data) 1230 | throws com.google.protobuf.InvalidProtocolBufferException { 1231 | return PARSER.parseFrom(data); 1232 | } 1233 | public static Inventory.Item parseFrom( 1234 | com.google.protobuf.ByteString data, 1235 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1236 | throws com.google.protobuf.InvalidProtocolBufferException { 1237 | return PARSER.parseFrom(data, extensionRegistry); 1238 | } 1239 | public static Inventory.Item parseFrom(byte[] data) 1240 | throws com.google.protobuf.InvalidProtocolBufferException { 1241 | return PARSER.parseFrom(data); 1242 | } 1243 | public static Inventory.Item parseFrom( 1244 | byte[] data, 1245 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1246 | throws com.google.protobuf.InvalidProtocolBufferException { 1247 | return PARSER.parseFrom(data, extensionRegistry); 1248 | } 1249 | public static Inventory.Item parseFrom(java.io.InputStream input) 1250 | throws java.io.IOException { 1251 | return com.google.protobuf.GeneratedMessageV3 1252 | .parseWithIOException(PARSER, input); 1253 | } 1254 | public static Inventory.Item parseFrom( 1255 | java.io.InputStream input, 1256 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1257 | throws java.io.IOException { 1258 | return com.google.protobuf.GeneratedMessageV3 1259 | .parseWithIOException(PARSER, input, extensionRegistry); 1260 | } 1261 | public static Inventory.Item parseDelimitedFrom(java.io.InputStream input) 1262 | throws java.io.IOException { 1263 | return com.google.protobuf.GeneratedMessageV3 1264 | .parseDelimitedWithIOException(PARSER, input); 1265 | } 1266 | public static Inventory.Item parseDelimitedFrom( 1267 | java.io.InputStream input, 1268 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1269 | throws java.io.IOException { 1270 | return com.google.protobuf.GeneratedMessageV3 1271 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 1272 | } 1273 | public static Inventory.Item parseFrom( 1274 | com.google.protobuf.CodedInputStream input) 1275 | throws java.io.IOException { 1276 | return com.google.protobuf.GeneratedMessageV3 1277 | .parseWithIOException(PARSER, input); 1278 | } 1279 | public static Inventory.Item parseFrom( 1280 | com.google.protobuf.CodedInputStream input, 1281 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1282 | throws java.io.IOException { 1283 | return com.google.protobuf.GeneratedMessageV3 1284 | .parseWithIOException(PARSER, input, extensionRegistry); 1285 | } 1286 | 1287 | public Builder newBuilderForType() { return newBuilder(); } 1288 | public static Builder newBuilder() { 1289 | return DEFAULT_INSTANCE.toBuilder(); 1290 | } 1291 | public static Builder newBuilder(Inventory.Item prototype) { 1292 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 1293 | } 1294 | public Builder toBuilder() { 1295 | return this == DEFAULT_INSTANCE 1296 | ? new Builder() : new Builder().mergeFrom(this); 1297 | } 1298 | 1299 | @Override 1300 | protected Builder newBuilderForType( 1301 | BuilderParent parent) { 1302 | Builder builder = new Builder(parent); 1303 | return builder; 1304 | } 1305 | /** 1306 | * Protobuf type {@code mfe.ch03.grpc.Item} 1307 | */ 1308 | public static final class Builder extends 1309 | com.google.protobuf.GeneratedMessageV3.Builder implements 1310 | // @@protoc_insertion_point(builder_implements:mfe.ch03.grpc.Item) 1311 | Inventory.ItemOrBuilder { 1312 | public static final com.google.protobuf.Descriptors.Descriptor 1313 | getDescriptor() { 1314 | return Inventory.internal_static_mfe_ch03_grpc_Item_descriptor; 1315 | } 1316 | 1317 | protected FieldAccessorTable 1318 | internalGetFieldAccessorTable() { 1319 | return Inventory.internal_static_mfe_ch03_grpc_Item_fieldAccessorTable 1320 | .ensureFieldAccessorsInitialized( 1321 | Inventory.Item.class, Inventory.Item.Builder.class); 1322 | } 1323 | 1324 | // Construct using mfe.ch03.grpc.Inventory.Item.newBuilder() 1325 | private Builder() { 1326 | maybeForceBuilderInitialization(); 1327 | } 1328 | 1329 | private Builder( 1330 | BuilderParent parent) { 1331 | super(parent); 1332 | maybeForceBuilderInitialization(); 1333 | } 1334 | private void maybeForceBuilderInitialization() { 1335 | if (com.google.protobuf.GeneratedMessageV3 1336 | .alwaysUseFieldBuilders) { 1337 | } 1338 | } 1339 | public Builder clear() { 1340 | super.clear(); 1341 | id_ = ""; 1342 | 1343 | name_ = ""; 1344 | 1345 | description_ = ""; 1346 | 1347 | return this; 1348 | } 1349 | 1350 | public com.google.protobuf.Descriptors.Descriptor 1351 | getDescriptorForType() { 1352 | return Inventory.internal_static_mfe_ch03_grpc_Item_descriptor; 1353 | } 1354 | 1355 | public Inventory.Item getDefaultInstanceForType() { 1356 | return Inventory.Item.getDefaultInstance(); 1357 | } 1358 | 1359 | public Inventory.Item build() { 1360 | Inventory.Item result = buildPartial(); 1361 | if (!result.isInitialized()) { 1362 | throw newUninitializedMessageException(result); 1363 | } 1364 | return result; 1365 | } 1366 | 1367 | public Inventory.Item buildPartial() { 1368 | Inventory.Item result = new Inventory.Item(this); 1369 | result.id_ = id_; 1370 | result.name_ = name_; 1371 | result.description_ = description_; 1372 | onBuilt(); 1373 | return result; 1374 | } 1375 | 1376 | public Builder clone() { 1377 | return (Builder) super.clone(); 1378 | } 1379 | public Builder setField( 1380 | com.google.protobuf.Descriptors.FieldDescriptor field, 1381 | Object value) { 1382 | return (Builder) super.setField(field, value); 1383 | } 1384 | public Builder clearField( 1385 | com.google.protobuf.Descriptors.FieldDescriptor field) { 1386 | return (Builder) super.clearField(field); 1387 | } 1388 | public Builder clearOneof( 1389 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 1390 | return (Builder) super.clearOneof(oneof); 1391 | } 1392 | public Builder setRepeatedField( 1393 | com.google.protobuf.Descriptors.FieldDescriptor field, 1394 | int index, Object value) { 1395 | return (Builder) super.setRepeatedField(field, index, value); 1396 | } 1397 | public Builder addRepeatedField( 1398 | com.google.protobuf.Descriptors.FieldDescriptor field, 1399 | Object value) { 1400 | return (Builder) super.addRepeatedField(field, value); 1401 | } 1402 | public Builder mergeFrom(com.google.protobuf.Message other) { 1403 | if (other instanceof Inventory.Item) { 1404 | return mergeFrom((Inventory.Item)other); 1405 | } else { 1406 | super.mergeFrom(other); 1407 | return this; 1408 | } 1409 | } 1410 | 1411 | public Builder mergeFrom(Inventory.Item other) { 1412 | if (other == Inventory.Item.getDefaultInstance()) return this; 1413 | if (!other.getId().isEmpty()) { 1414 | id_ = other.id_; 1415 | onChanged(); 1416 | } 1417 | if (!other.getName().isEmpty()) { 1418 | name_ = other.name_; 1419 | onChanged(); 1420 | } 1421 | if (!other.getDescription().isEmpty()) { 1422 | description_ = other.description_; 1423 | onChanged(); 1424 | } 1425 | this.mergeUnknownFields(other.unknownFields); 1426 | onChanged(); 1427 | return this; 1428 | } 1429 | 1430 | public final boolean isInitialized() { 1431 | return true; 1432 | } 1433 | 1434 | public Builder mergeFrom( 1435 | com.google.protobuf.CodedInputStream input, 1436 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1437 | throws java.io.IOException { 1438 | Inventory.Item parsedMessage = null; 1439 | try { 1440 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 1441 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 1442 | parsedMessage = (Inventory.Item) e.getUnfinishedMessage(); 1443 | throw e.unwrapIOException(); 1444 | } finally { 1445 | if (parsedMessage != null) { 1446 | mergeFrom(parsedMessage); 1447 | } 1448 | } 1449 | return this; 1450 | } 1451 | 1452 | private Object id_ = ""; 1453 | /** 1454 | * string id = 1; 1455 | */ 1456 | public String getId() { 1457 | Object ref = id_; 1458 | if (!(ref instanceof String)) { 1459 | com.google.protobuf.ByteString bs = 1460 | (com.google.protobuf.ByteString) ref; 1461 | String s = bs.toStringUtf8(); 1462 | id_ = s; 1463 | return s; 1464 | } else { 1465 | return (String) ref; 1466 | } 1467 | } 1468 | /** 1469 | * string id = 1; 1470 | */ 1471 | public com.google.protobuf.ByteString 1472 | getIdBytes() { 1473 | Object ref = id_; 1474 | if (ref instanceof String) { 1475 | com.google.protobuf.ByteString b = 1476 | com.google.protobuf.ByteString.copyFromUtf8( 1477 | (String) ref); 1478 | id_ = b; 1479 | return b; 1480 | } else { 1481 | return (com.google.protobuf.ByteString) ref; 1482 | } 1483 | } 1484 | /** 1485 | * string id = 1; 1486 | */ 1487 | public Builder setId( 1488 | String value) { 1489 | if (value == null) { 1490 | throw new NullPointerException(); 1491 | } 1492 | 1493 | id_ = value; 1494 | onChanged(); 1495 | return this; 1496 | } 1497 | /** 1498 | * string id = 1; 1499 | */ 1500 | public Builder clearId() { 1501 | 1502 | id_ = getDefaultInstance().getId(); 1503 | onChanged(); 1504 | return this; 1505 | } 1506 | /** 1507 | * string id = 1; 1508 | */ 1509 | public Builder setIdBytes( 1510 | com.google.protobuf.ByteString value) { 1511 | if (value == null) { 1512 | throw new NullPointerException(); 1513 | } 1514 | checkByteStringIsUtf8(value); 1515 | 1516 | id_ = value; 1517 | onChanged(); 1518 | return this; 1519 | } 1520 | 1521 | private Object name_ = ""; 1522 | /** 1523 | * string name = 2; 1524 | */ 1525 | public String getName() { 1526 | Object ref = name_; 1527 | if (!(ref instanceof String)) { 1528 | com.google.protobuf.ByteString bs = 1529 | (com.google.protobuf.ByteString) ref; 1530 | String s = bs.toStringUtf8(); 1531 | name_ = s; 1532 | return s; 1533 | } else { 1534 | return (String) ref; 1535 | } 1536 | } 1537 | /** 1538 | * string name = 2; 1539 | */ 1540 | public com.google.protobuf.ByteString 1541 | getNameBytes() { 1542 | Object ref = name_; 1543 | if (ref instanceof String) { 1544 | com.google.protobuf.ByteString b = 1545 | com.google.protobuf.ByteString.copyFromUtf8( 1546 | (String) ref); 1547 | name_ = b; 1548 | return b; 1549 | } else { 1550 | return (com.google.protobuf.ByteString) ref; 1551 | } 1552 | } 1553 | /** 1554 | * string name = 2; 1555 | */ 1556 | public Builder setName( 1557 | String value) { 1558 | if (value == null) { 1559 | throw new NullPointerException(); 1560 | } 1561 | 1562 | name_ = value; 1563 | onChanged(); 1564 | return this; 1565 | } 1566 | /** 1567 | * string name = 2; 1568 | */ 1569 | public Builder clearName() { 1570 | 1571 | name_ = getDefaultInstance().getName(); 1572 | onChanged(); 1573 | return this; 1574 | } 1575 | /** 1576 | * string name = 2; 1577 | */ 1578 | public Builder setNameBytes( 1579 | com.google.protobuf.ByteString value) { 1580 | if (value == null) { 1581 | throw new NullPointerException(); 1582 | } 1583 | checkByteStringIsUtf8(value); 1584 | 1585 | name_ = value; 1586 | onChanged(); 1587 | return this; 1588 | } 1589 | 1590 | private Object description_ = ""; 1591 | /** 1592 | * string description = 3; 1593 | */ 1594 | public String getDescription() { 1595 | Object ref = description_; 1596 | if (!(ref instanceof String)) { 1597 | com.google.protobuf.ByteString bs = 1598 | (com.google.protobuf.ByteString) ref; 1599 | String s = bs.toStringUtf8(); 1600 | description_ = s; 1601 | return s; 1602 | } else { 1603 | return (String) ref; 1604 | } 1605 | } 1606 | /** 1607 | * string description = 3; 1608 | */ 1609 | public com.google.protobuf.ByteString 1610 | getDescriptionBytes() { 1611 | Object ref = description_; 1612 | if (ref instanceof String) { 1613 | com.google.protobuf.ByteString b = 1614 | com.google.protobuf.ByteString.copyFromUtf8( 1615 | (String) ref); 1616 | description_ = b; 1617 | return b; 1618 | } else { 1619 | return (com.google.protobuf.ByteString) ref; 1620 | } 1621 | } 1622 | /** 1623 | * string description = 3; 1624 | */ 1625 | public Builder setDescription( 1626 | String value) { 1627 | if (value == null) { 1628 | throw new NullPointerException(); 1629 | } 1630 | 1631 | description_ = value; 1632 | onChanged(); 1633 | return this; 1634 | } 1635 | /** 1636 | * string description = 3; 1637 | */ 1638 | public Builder clearDescription() { 1639 | 1640 | description_ = getDefaultInstance().getDescription(); 1641 | onChanged(); 1642 | return this; 1643 | } 1644 | /** 1645 | * string description = 3; 1646 | */ 1647 | public Builder setDescriptionBytes( 1648 | com.google.protobuf.ByteString value) { 1649 | if (value == null) { 1650 | throw new NullPointerException(); 1651 | } 1652 | checkByteStringIsUtf8(value); 1653 | 1654 | description_ = value; 1655 | onChanged(); 1656 | return this; 1657 | } 1658 | public final Builder setUnknownFields( 1659 | final com.google.protobuf.UnknownFieldSet unknownFields) { 1660 | return super.setUnknownFieldsProto3(unknownFields); 1661 | } 1662 | 1663 | public final Builder mergeUnknownFields( 1664 | final com.google.protobuf.UnknownFieldSet unknownFields) { 1665 | return super.mergeUnknownFields(unknownFields); 1666 | } 1667 | 1668 | 1669 | // @@protoc_insertion_point(builder_scope:mfe.ch03.grpc.Item) 1670 | } 1671 | 1672 | // @@protoc_insertion_point(class_scope:mfe.ch03.grpc.Item) 1673 | private static final Inventory.Item DEFAULT_INSTANCE; 1674 | static { 1675 | DEFAULT_INSTANCE = new Inventory.Item(); 1676 | } 1677 | 1678 | public static Inventory.Item getDefaultInstance() { 1679 | return DEFAULT_INSTANCE; 1680 | } 1681 | 1682 | private static final com.google.protobuf.Parser 1683 | PARSER = new com.google.protobuf.AbstractParser() { 1684 | public Item parsePartialFrom( 1685 | com.google.protobuf.CodedInputStream input, 1686 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1687 | throws com.google.protobuf.InvalidProtocolBufferException { 1688 | return new Item(input, extensionRegistry); 1689 | } 1690 | }; 1691 | 1692 | public static com.google.protobuf.Parser parser() { 1693 | return PARSER; 1694 | } 1695 | 1696 | @Override 1697 | public com.google.protobuf.Parser getParserForType() { 1698 | return PARSER; 1699 | } 1700 | 1701 | public Inventory.Item getDefaultInstanceForType() { 1702 | return DEFAULT_INSTANCE; 1703 | } 1704 | 1705 | } 1706 | 1707 | private static final com.google.protobuf.Descriptors.Descriptor 1708 | internal_static_mfe_ch03_grpc_Items_descriptor; 1709 | private static final 1710 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1711 | internal_static_mfe_ch03_grpc_Items_fieldAccessorTable; 1712 | private static final com.google.protobuf.Descriptors.Descriptor 1713 | internal_static_mfe_ch03_grpc_Item_descriptor; 1714 | private static final 1715 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1716 | internal_static_mfe_ch03_grpc_Item_fieldAccessorTable; 1717 | 1718 | public static com.google.protobuf.Descriptors.FileDescriptor 1719 | getDescriptor() { 1720 | return descriptor; 1721 | } 1722 | private static com.google.protobuf.Descriptors.FileDescriptor 1723 | descriptor; 1724 | static { 1725 | String[] descriptorData = { 1726 | "\n\017inventory.proto\022\rmfe.ch03.grpc\032\036google" + 1727 | "/protobuf/wrappers.proto\"=\n\005Items\022\020\n\010ite" + 1728 | "mDesc\030\001 \001(\t\022\"\n\005items\030\002 \003(\0132\023.mfe.ch03.gr" + 1729 | "pc.Item\"5\n\004Item\022\n\n\002id\030\001 \001(\t\022\014\n\004name\030\002 \001(" + 1730 | "\t\022\023\n\013description\030\003 \001(\t2\325\001\n\020InventoryServ" + 1731 | "ice\022C\n\rgetItemByName\022\034.google.protobuf.S" + 1732 | "tringValue\032\024.mfe.ch03.grpc.Items\022@\n\013getI" + 1733 | "temByID\022\034.google.protobuf.StringValue\032\023." + 1734 | "mfe.ch03.grpc.Item\022:\n\007addItem\022\023.mfe.ch03" + 1735 | ".grpc.Item\032\032.google.protobuf.BoolValueb\006", 1736 | "proto3" 1737 | }; 1738 | com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = 1739 | new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { 1740 | public com.google.protobuf.ExtensionRegistry assignDescriptors( 1741 | com.google.protobuf.Descriptors.FileDescriptor root) { 1742 | descriptor = root; 1743 | return null; 1744 | } 1745 | }; 1746 | com.google.protobuf.Descriptors.FileDescriptor 1747 | .internalBuildGeneratedFileFrom(descriptorData, 1748 | new com.google.protobuf.Descriptors.FileDescriptor[] { 1749 | com.google.protobuf.WrappersProto.getDescriptor(), 1750 | }, assigner); 1751 | internal_static_mfe_ch03_grpc_Items_descriptor = 1752 | getDescriptor().getMessageTypes().get(0); 1753 | internal_static_mfe_ch03_grpc_Items_fieldAccessorTable = new 1754 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 1755 | internal_static_mfe_ch03_grpc_Items_descriptor, 1756 | new String[] { "ItemDesc", "Items", }); 1757 | internal_static_mfe_ch03_grpc_Item_descriptor = 1758 | getDescriptor().getMessageTypes().get(1); 1759 | internal_static_mfe_ch03_grpc_Item_fieldAccessorTable = new 1760 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 1761 | internal_static_mfe_ch03_grpc_Item_descriptor, 1762 | new String[] { "Id", "Name", "Description", }); 1763 | com.google.protobuf.WrappersProto.getDescriptor(); 1764 | } 1765 | 1766 | // @@protoc_insertion_point(outer_class_scope) 1767 | } 1768 | --------------------------------------------------------------------------------