java高可用grpc_gRPC编码初探(java)
//Generated by the protocol buffer compiler. DO NOT EDIT!//source: AccountQry.proto
packagecom.mzsg.demo.grpc.qryaccount;public final classQryAccountProto {privateQryAccountProto() {}public static voidregisterAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
}public interface AccountQryRequestOrBuilder extends
//@@protoc_insertion_point(interface_extends:accountService.AccountQryRequest)
com.google.protobuf.MessageOrBuilder {/*** optional string requestId = 1;
*
*
*请求流水
*
*/java.lang.String getRequestId();/***optional string requestId = 1;*
*
*请求流水
*
*/com.google.protobuf.ByteStringgetRequestIdBytes();/*** optional string userId = 2;
*
*
*用户ID
*
*/java.lang.String getUserId();/***optional string userId = 2;*
*
*用户ID
*
*/com.google.protobuf.ByteStringgetUserIdBytes();
}/*** Protobuf type {@codeaccountService.AccountQryRequest}
*
*
*账户查询请求
*
*/public static final class AccountQryRequest extendscom.google.protobuf.GeneratedMessageimplements
//@@protoc_insertion_point(message_implements:accountService.AccountQryRequest)
AccountQryRequestOrBuilder {//Use AccountQryRequest.newBuilder() to construct.
private AccountQryRequest(com.google.protobuf.GeneratedMessage.Builder>builder) {super(builder);
}privateAccountQryRequest() {
requestId_= "";
userId_= "";
}
@java.lang.Overridepublic finalcom.google.protobuf.UnknownFieldSet
getUnknownFields() {returncom.google.protobuf.UnknownFieldSet.getDefaultInstance();
}privateAccountQryRequest(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) {this();int mutable_bitField0_ = 0;try{boolean done = false;while (!done) {int tag =input.readTag();switch(tag) {case 0:
done= true;break;default: {if (!input.skipField(tag)) {
done= true;
}break;
}case 10: {
java.lang.String s=input.readStringRequireUtf8();
requestId_=s;break;
}case 18: {
java.lang.String s=input.readStringRequireUtf8();
userId_=s;break;
}
}
}
}catch(com.google.protobuf.InvalidProtocolBufferException e) {throw new RuntimeException(e.setUnfinishedMessage(this));
}catch(java.io.IOException e) {throw newRuntimeException(newcom.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this));
}finally{
makeExtensionsImmutable();
}
}public static finalcom.google.protobuf.Descriptors.Descriptor
getDescriptor() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryRequest_descriptor;
}protectedcom.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest.class, com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest.Builder.class);
}public static final int REQUESTID_FIELD_NUMBER = 1;private volatilejava.lang.Object requestId_;/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicjava.lang.String getRequestId() {
java.lang.Object ref=requestId_;if (ref instanceofjava.lang.String) {return(java.lang.String) ref;
}else{
com.google.protobuf.ByteString bs=(com.google.protobuf.ByteString) ref;
java.lang.String s=bs.toStringUtf8();
requestId_=s;returns;
}
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publiccom.google.protobuf.ByteString
getRequestIdBytes() {
java.lang.Object ref=requestId_;if (ref instanceofjava.lang.String) {
com.google.protobuf.ByteString b=com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
requestId_=b;returnb;
}else{return(com.google.protobuf.ByteString) ref;
}
}public static final int USERID_FIELD_NUMBER = 2;private volatilejava.lang.Object userId_;/*** optional string userId = 2;
*
*
*用户ID
*
*/publicjava.lang.String getUserId() {
java.lang.Object ref=userId_;if (ref instanceofjava.lang.String) {return(java.lang.String) ref;
}else{
com.google.protobuf.ByteString bs=(com.google.protobuf.ByteString) ref;
java.lang.String s=bs.toStringUtf8();
userId_=s;returns;
}
}/*** optional string userId = 2;
*
*
*用户ID
*
*/publiccom.google.protobuf.ByteString
getUserIdBytes() {
java.lang.Object ref=userId_;if (ref instanceofjava.lang.String) {
com.google.protobuf.ByteString b=com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
userId_=b;returnb;
}else{return(com.google.protobuf.ByteString) ref;
}
}private byte memoizedIsInitialized = -1;public final booleanisInitialized() {byte isInitialized =memoizedIsInitialized;if (isInitialized == 1) return true;if (isInitialized == 0) return false;
memoizedIsInitialized= 1;return true;
}public voidwriteTo(com.google.protobuf.CodedOutputStream output)throwsjava.io.IOException {if (!getRequestIdBytes().isEmpty()) {
com.google.protobuf.GeneratedMessage.writeString(output,1, requestId_);
}if (!getUserIdBytes().isEmpty()) {
com.google.protobuf.GeneratedMessage.writeString(output,2, userId_);
}
}public intgetSerializedSize() {int size =memoizedSize;if (size != -1) returnsize;
size= 0;if (!getRequestIdBytes().isEmpty()) {
size+= com.google.protobuf.GeneratedMessage.computeStringSize(1, requestId_);
}if (!getUserIdBytes().isEmpty()) {
size+= com.google.protobuf.GeneratedMessage.computeStringSize(2, userId_);
}
memoizedSize=size;returnsize;
}private static final long serialVersionUID = 0L;public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseFrom(
com.google.protobuf.ByteString data)throwscom.google.protobuf.InvalidProtocolBufferException {returnPARSER.parseFrom(data);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwscom.google.protobuf.InvalidProtocolBufferException {returnPARSER.parseFrom(data, extensionRegistry);
}public static com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseFrom(byte[] data)throwscom.google.protobuf.InvalidProtocolBufferException {returnPARSER.parseFrom(data);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseFrom(byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwscom.google.protobuf.InvalidProtocolBufferException {returnPARSER.parseFrom(data, extensionRegistry);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseFrom(java.io.InputStream input)throwsjava.io.IOException {returnPARSER.parseFrom(input);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwsjava.io.IOException {returnPARSER.parseFrom(input, extensionRegistry);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseDelimitedFrom(java.io.InputStream input)throwsjava.io.IOException {returnPARSER.parseDelimitedFrom(input);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwsjava.io.IOException {returnPARSER.parseDelimitedFrom(input, extensionRegistry);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseFrom(
com.google.protobuf.CodedInputStream input)throwsjava.io.IOException {returnPARSER.parseFrom(input);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwsjava.io.IOException {returnPARSER.parseFrom(input, extensionRegistry);
}public Builder newBuilderForType() { returnnewBuilder(); }public staticBuilder newBuilder() {returnDEFAULT_INSTANCE.toBuilder();
}public staticBuilder newBuilder(com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest prototype) {returnDEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}publicBuilder toBuilder() {return this ==DEFAULT_INSTANCE? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.OverrideprotectedBuilder newBuilderForType(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
Builder builder= newBuilder(parent);returnbuilder;
}/*** Protobuf type {@codeaccountService.AccountQryRequest}
*
*
*账户查询请求
*
*/public static final class Builder extendscom.google.protobuf.GeneratedMessage.Builder implements
//@@protoc_insertion_point(builder_implements:accountService.AccountQryRequest)
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequestOrBuilder {public static finalcom.google.protobuf.Descriptors.Descriptor
getDescriptor() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryRequest_descriptor;
}protectedcom.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest.class, com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest.Builder.class);
}//Construct using com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest.newBuilder()
privateBuilder() {
maybeForceBuilderInitialization();
}privateBuilder(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {super(parent);
maybeForceBuilderInitialization();
}private voidmaybeForceBuilderInitialization() {if(com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
}
}publicBuilder clear() {super.clear();
requestId_= "";
userId_= "";return this;
}publiccom.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryRequest_descriptor;
}publiccom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest getDefaultInstanceForType() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest.getDefaultInstance();
}publiccom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest build() {
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest result=buildPartial();if (!result.isInitialized()) {thrownewUninitializedMessageException(result);
}returnresult;
}publiccom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest buildPartial() {
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest result= new com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest(this);
result.requestId_=requestId_;
result.userId_=userId_;
onBuilt();returnresult;
}publicBuilder mergeFrom(com.google.protobuf.Message other) {if (other instanceofcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest) {returnmergeFrom((com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest)other);
}else{super.mergeFrom(other);return this;
}
}publicBuilder mergeFrom(com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest other) {if (other == com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest.getDefaultInstance()) return this;if (!other.getRequestId().isEmpty()) {
requestId_=other.requestId_;
onChanged();
}if (!other.getUserId().isEmpty()) {
userId_=other.userId_;
onChanged();
}
onChanged();return this;
}public final booleanisInitialized() {return true;
}publicBuilder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwsjava.io.IOException {
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest parsedMessage= null;try{
parsedMessage=PARSER.parsePartialFrom(input, extensionRegistry);
}catch(com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage=(com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest) e.getUnfinishedMessage();throwe;
}finally{if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}return this;
}private java.lang.Object requestId_ = "";/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicjava.lang.String getRequestId() {
java.lang.Object ref=requestId_;if (!(ref instanceofjava.lang.String)) {
com.google.protobuf.ByteString bs=(com.google.protobuf.ByteString) ref;
java.lang.String s=bs.toStringUtf8();
requestId_=s;returns;
}else{return(java.lang.String) ref;
}
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publiccom.google.protobuf.ByteString
getRequestIdBytes() {
java.lang.Object ref=requestId_;if (ref instanceofString) {
com.google.protobuf.ByteString b=com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
requestId_=b;returnb;
}else{return(com.google.protobuf.ByteString) ref;
}
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicBuilder setRequestId(
java.lang.String value) {if (value == null) {throw newNullPointerException();
}
requestId_=value;
onChanged();return this;
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicBuilder clearRequestId() {
requestId_=getDefaultInstance().getRequestId();
onChanged();return this;
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicBuilder setRequestIdBytes(
com.google.protobuf.ByteString value) {if (value == null) {throw newNullPointerException();
}
checkByteStringIsUtf8(value);
requestId_=value;
onChanged();return this;
}private java.lang.Object userId_ = "";/*** optional string userId = 2;
*
*
*用户ID
*
*/publicjava.lang.String getUserId() {
java.lang.Object ref=userId_;if (!(ref instanceofjava.lang.String)) {
com.google.protobuf.ByteString bs=(com.google.protobuf.ByteString) ref;
java.lang.String s=bs.toStringUtf8();
userId_=s;returns;
}else{return(java.lang.String) ref;
}
}/*** optional string userId = 2;
*
*
*用户ID
*
*/publiccom.google.protobuf.ByteString
getUserIdBytes() {
java.lang.Object ref=userId_;if (ref instanceofString) {
com.google.protobuf.ByteString b=com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
userId_=b;returnb;
}else{return(com.google.protobuf.ByteString) ref;
}
}/*** optional string userId = 2;
*
*
*用户ID
*
*/publicBuilder setUserId(
java.lang.String value) {if (value == null) {throw newNullPointerException();
}
userId_=value;
onChanged();return this;
}/*** optional string userId = 2;
*
*
*用户ID
*
*/publicBuilder clearUserId() {
userId_=getDefaultInstance().getUserId();
onChanged();return this;
}/*** optional string userId = 2;
*
*
*用户ID
*
*/publicBuilder setUserIdBytes(
com.google.protobuf.ByteString value) {if (value == null) {throw newNullPointerException();
}
checkByteStringIsUtf8(value);
userId_=value;
onChanged();return this;
}public finalBuilder setUnknownFields(finalcom.google.protobuf.UnknownFieldSet unknownFields) {return this;
}public finalBuilder mergeUnknownFields(finalcom.google.protobuf.UnknownFieldSet unknownFields) {return this;
}//@@protoc_insertion_point(builder_scope:accountService.AccountQryRequest)
}//@@protoc_insertion_point(class_scope:accountService.AccountQryRequest)
private static finalcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest DEFAULT_INSTANCE;static{
DEFAULT_INSTANCE= newcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest();
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest getDefaultInstance() {returnDEFAULT_INSTANCE;
}private static final com.google.protobuf.ParserPARSER= new com.google.protobuf.AbstractParser() {publicAccountQryRequest parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwscom.google.protobuf.InvalidProtocolBufferException {try{return newAccountQryRequest(input, extensionRegistry);
}catch(RuntimeException e) {if (e.getCause() instanceofcom.google.protobuf.InvalidProtocolBufferException) {throw(com.google.protobuf.InvalidProtocolBufferException)
e.getCause();
}throwe;
}
}
};public static com.google.protobuf.Parserparser() {returnPARSER;
}
@java.lang.Overridepublic com.google.protobuf.ParsergetParserForType() {returnPARSER;
}publiccom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest getDefaultInstanceForType() {returnDEFAULT_INSTANCE;
}
}public interface AccountQryResponseOrBuilder extends
//@@protoc_insertion_point(interface_extends:accountService.AccountQryResponse)
com.google.protobuf.MessageOrBuilder {/*** optional string requestId = 1;
*
*
*请求流水
*
*/java.lang.String getRequestId();/***optional string requestId = 1;*
*
*请求流水
*
*/com.google.protobuf.ByteStringgetRequestIdBytes();/*** optional int32 rc = 2;
*
*
*返回码,1:成功; -1:失败
*
*/intgetRc();/*** optional string msg = 3;
*
*
*错误消息
*
*/java.lang.String getMsg();/***optional string msg = 3;*
*
*错误消息
*
*/com.google.protobuf.ByteStringgetMsgBytes();/*** optional int32 amount = 4;
*
*
*账户余额
*
*/intgetAmount();
}/*** Protobuf type {@codeaccountService.AccountQryResponse}
*
*
*账户查询响应
*
*/public static final class AccountQryResponse extendscom.google.protobuf.GeneratedMessageimplements
//@@protoc_insertion_point(message_implements:accountService.AccountQryResponse)
AccountQryResponseOrBuilder {//Use AccountQryResponse.newBuilder() to construct.
private AccountQryResponse(com.google.protobuf.GeneratedMessage.Builder>builder) {super(builder);
}privateAccountQryResponse() {
requestId_= "";
rc_= 0;
msg_= "";
amount_= 0;
}
@java.lang.Overridepublic finalcom.google.protobuf.UnknownFieldSet
getUnknownFields() {returncom.google.protobuf.UnknownFieldSet.getDefaultInstance();
}privateAccountQryResponse(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) {this();int mutable_bitField0_ = 0;try{boolean done = false;while (!done) {int tag =input.readTag();switch(tag) {case 0:
done= true;break;default: {if (!input.skipField(tag)) {
done= true;
}break;
}case 10: {
java.lang.String s=input.readStringRequireUtf8();
requestId_=s;break;
}case 16: {
rc_=input.readInt32();break;
}case 26: {
java.lang.String s=input.readStringRequireUtf8();
msg_=s;break;
}case 32: {
amount_=input.readInt32();break;
}
}
}
}catch(com.google.protobuf.InvalidProtocolBufferException e) {throw new RuntimeException(e.setUnfinishedMessage(this));
}catch(java.io.IOException e) {throw newRuntimeException(newcom.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this));
}finally{
makeExtensionsImmutable();
}
}public static finalcom.google.protobuf.Descriptors.Descriptor
getDescriptor() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryResponse_descriptor;
}protectedcom.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse.class, com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse.Builder.class);
}public static final int REQUESTID_FIELD_NUMBER = 1;private volatilejava.lang.Object requestId_;/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicjava.lang.String getRequestId() {
java.lang.Object ref=requestId_;if (ref instanceofjava.lang.String) {return(java.lang.String) ref;
}else{
com.google.protobuf.ByteString bs=(com.google.protobuf.ByteString) ref;
java.lang.String s=bs.toStringUtf8();
requestId_=s;returns;
}
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publiccom.google.protobuf.ByteString
getRequestIdBytes() {
java.lang.Object ref=requestId_;if (ref instanceofjava.lang.String) {
com.google.protobuf.ByteString b=com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
requestId_=b;returnb;
}else{return(com.google.protobuf.ByteString) ref;
}
}public static final int RC_FIELD_NUMBER = 2;private intrc_;/*** optional int32 rc = 2;
*
*
*返回码,1:成功; -1:失败
*
*/public intgetRc() {returnrc_;
}public static final int MSG_FIELD_NUMBER = 3;private volatilejava.lang.Object msg_;/*** optional string msg = 3;
*
*
*错误消息
*
*/publicjava.lang.String getMsg() {
java.lang.Object ref=msg_;if (ref instanceofjava.lang.String) {return(java.lang.String) ref;
}else{
com.google.protobuf.ByteString bs=(com.google.protobuf.ByteString) ref;
java.lang.String s=bs.toStringUtf8();
msg_=s;returns;
}
}/*** optional string msg = 3;
*
*
*错误消息
*
*/publiccom.google.protobuf.ByteString
getMsgBytes() {
java.lang.Object ref=msg_;if (ref instanceofjava.lang.String) {
com.google.protobuf.ByteString b=com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
msg_=b;returnb;
}else{return(com.google.protobuf.ByteString) ref;
}
}public static final int AMOUNT_FIELD_NUMBER = 4;private intamount_;/*** optional int32 amount = 4;
*
*
*账户余额
*
*/public intgetAmount() {returnamount_;
}private byte memoizedIsInitialized = -1;public final booleanisInitialized() {byte isInitialized =memoizedIsInitialized;if (isInitialized == 1) return true;if (isInitialized == 0) return false;
memoizedIsInitialized= 1;return true;
}public voidwriteTo(com.google.protobuf.CodedOutputStream output)throwsjava.io.IOException {if (!getRequestIdBytes().isEmpty()) {
com.google.protobuf.GeneratedMessage.writeString(output,1, requestId_);
}if (rc_ != 0) {
output.writeInt32(2, rc_);
}if (!getMsgBytes().isEmpty()) {
com.google.protobuf.GeneratedMessage.writeString(output,3, msg_);
}if (amount_ != 0) {
output.writeInt32(4, amount_);
}
}public intgetSerializedSize() {int size =memoizedSize;if (size != -1) returnsize;
size= 0;if (!getRequestIdBytes().isEmpty()) {
size+= com.google.protobuf.GeneratedMessage.computeStringSize(1, requestId_);
}if (rc_ != 0) {
size+=com.google.protobuf.CodedOutputStream
.computeInt32Size(2, rc_);
}if (!getMsgBytes().isEmpty()) {
size+= com.google.protobuf.GeneratedMessage.computeStringSize(3, msg_);
}if (amount_ != 0) {
size+=com.google.protobuf.CodedOutputStream
.computeInt32Size(4, amount_);
}
memoizedSize=size;returnsize;
}private static final long serialVersionUID = 0L;public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseFrom(
com.google.protobuf.ByteString data)throwscom.google.protobuf.InvalidProtocolBufferException {returnPARSER.parseFrom(data);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwscom.google.protobuf.InvalidProtocolBufferException {returnPARSER.parseFrom(data, extensionRegistry);
}public static com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseFrom(byte[] data)throwscom.google.protobuf.InvalidProtocolBufferException {returnPARSER.parseFrom(data);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseFrom(byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwscom.google.protobuf.InvalidProtocolBufferException {returnPARSER.parseFrom(data, extensionRegistry);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseFrom(java.io.InputStream input)throwsjava.io.IOException {returnPARSER.parseFrom(input);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwsjava.io.IOException {returnPARSER.parseFrom(input, extensionRegistry);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseDelimitedFrom(java.io.InputStream input)throwsjava.io.IOException {returnPARSER.parseDelimitedFrom(input);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwsjava.io.IOException {returnPARSER.parseDelimitedFrom(input, extensionRegistry);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseFrom(
com.google.protobuf.CodedInputStream input)throwsjava.io.IOException {returnPARSER.parseFrom(input);
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwsjava.io.IOException {returnPARSER.parseFrom(input, extensionRegistry);
}public Builder newBuilderForType() { returnnewBuilder(); }public staticBuilder newBuilder() {returnDEFAULT_INSTANCE.toBuilder();
}public staticBuilder newBuilder(com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse prototype) {returnDEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}publicBuilder toBuilder() {return this ==DEFAULT_INSTANCE? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.OverrideprotectedBuilder newBuilderForType(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
Builder builder= newBuilder(parent);returnbuilder;
}/*** Protobuf type {@codeaccountService.AccountQryResponse}
*
*
*账户查询响应
*
*/public static final class Builder extendscom.google.protobuf.GeneratedMessage.Builder implements
//@@protoc_insertion_point(builder_implements:accountService.AccountQryResponse)
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponseOrBuilder {public static finalcom.google.protobuf.Descriptors.Descriptor
getDescriptor() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryResponse_descriptor;
}protectedcom.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse.class, com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse.Builder.class);
}//Construct using com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse.newBuilder()
privateBuilder() {
maybeForceBuilderInitialization();
}privateBuilder(
com.google.protobuf.GeneratedMessage.BuilderParent parent) {super(parent);
maybeForceBuilderInitialization();
}private voidmaybeForceBuilderInitialization() {if(com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
}
}publicBuilder clear() {super.clear();
requestId_= "";
rc_= 0;
msg_= "";
amount_= 0;return this;
}publiccom.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.internal_static_accountService_AccountQryResponse_descriptor;
}publiccom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse getDefaultInstanceForType() {returncom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse.getDefaultInstance();
}publiccom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse build() {
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse result=buildPartial();if (!result.isInitialized()) {thrownewUninitializedMessageException(result);
}returnresult;
}publiccom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse buildPartial() {
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse result= new com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse(this);
result.requestId_=requestId_;
result.rc_=rc_;
result.msg_=msg_;
result.amount_=amount_;
onBuilt();returnresult;
}publicBuilder mergeFrom(com.google.protobuf.Message other) {if (other instanceofcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse) {returnmergeFrom((com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse)other);
}else{super.mergeFrom(other);return this;
}
}publicBuilder mergeFrom(com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse other) {if (other == com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse.getDefaultInstance()) return this;if (!other.getRequestId().isEmpty()) {
requestId_=other.requestId_;
onChanged();
}if (other.getRc() != 0) {
setRc(other.getRc());
}if (!other.getMsg().isEmpty()) {
msg_=other.msg_;
onChanged();
}if (other.getAmount() != 0) {
setAmount(other.getAmount());
}
onChanged();return this;
}public final booleanisInitialized() {return true;
}publicBuilder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwsjava.io.IOException {
com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse parsedMessage= null;try{
parsedMessage=PARSER.parsePartialFrom(input, extensionRegistry);
}catch(com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage=(com.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse) e.getUnfinishedMessage();throwe;
}finally{if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}return this;
}private java.lang.Object requestId_ = "";/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicjava.lang.String getRequestId() {
java.lang.Object ref=requestId_;if (!(ref instanceofjava.lang.String)) {
com.google.protobuf.ByteString bs=(com.google.protobuf.ByteString) ref;
java.lang.String s=bs.toStringUtf8();
requestId_=s;returns;
}else{return(java.lang.String) ref;
}
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publiccom.google.protobuf.ByteString
getRequestIdBytes() {
java.lang.Object ref=requestId_;if (ref instanceofString) {
com.google.protobuf.ByteString b=com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
requestId_=b;returnb;
}else{return(com.google.protobuf.ByteString) ref;
}
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicBuilder setRequestId(
java.lang.String value) {if (value == null) {throw newNullPointerException();
}
requestId_=value;
onChanged();return this;
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicBuilder clearRequestId() {
requestId_=getDefaultInstance().getRequestId();
onChanged();return this;
}/*** optional string requestId = 1;
*
*
*请求流水
*
*/publicBuilder setRequestIdBytes(
com.google.protobuf.ByteString value) {if (value == null) {throw newNullPointerException();
}
checkByteStringIsUtf8(value);
requestId_=value;
onChanged();return this;
}private intrc_ ;/*** optional int32 rc = 2;
*
*
*返回码,1:成功; -1:失败
*
*/public intgetRc() {returnrc_;
}/*** optional int32 rc = 2;
*
*
*返回码,1:成功; -1:失败
*
*/public Builder setRc(intvalue) {
rc_=value;
onChanged();return this;
}/*** optional int32 rc = 2;
*
*
*返回码,1:成功; -1:失败
*
*/publicBuilder clearRc() {
rc_= 0;
onChanged();return this;
}private java.lang.Object msg_ = "";/*** optional string msg = 3;
*
*
*错误消息
*
*/publicjava.lang.String getMsg() {
java.lang.Object ref=msg_;if (!(ref instanceofjava.lang.String)) {
com.google.protobuf.ByteString bs=(com.google.protobuf.ByteString) ref;
java.lang.String s=bs.toStringUtf8();
msg_=s;returns;
}else{return(java.lang.String) ref;
}
}/*** optional string msg = 3;
*
*
*错误消息
*
*/publiccom.google.protobuf.ByteString
getMsgBytes() {
java.lang.Object ref=msg_;if (ref instanceofString) {
com.google.protobuf.ByteString b=com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
msg_=b;returnb;
}else{return(com.google.protobuf.ByteString) ref;
}
}/*** optional string msg = 3;
*
*
*错误消息
*
*/publicBuilder setMsg(
java.lang.String value) {if (value == null) {throw newNullPointerException();
}
msg_=value;
onChanged();return this;
}/*** optional string msg = 3;
*
*
*错误消息
*
*/publicBuilder clearMsg() {
msg_=getDefaultInstance().getMsg();
onChanged();return this;
}/*** optional string msg = 3;
*
*
*错误消息
*
*/publicBuilder setMsgBytes(
com.google.protobuf.ByteString value) {if (value == null) {throw newNullPointerException();
}
checkByteStringIsUtf8(value);
msg_=value;
onChanged();return this;
}private intamount_ ;/*** optional int32 amount = 4;
*
*
*账户余额
*
*/public intgetAmount() {returnamount_;
}/*** optional int32 amount = 4;
*
*
*账户余额
*
*/public Builder setAmount(intvalue) {
amount_=value;
onChanged();return this;
}/*** optional int32 amount = 4;
*
*
*账户余额
*
*/publicBuilder clearAmount() {
amount_= 0;
onChanged();return this;
}public finalBuilder setUnknownFields(finalcom.google.protobuf.UnknownFieldSet unknownFields) {return this;
}public finalBuilder mergeUnknownFields(finalcom.google.protobuf.UnknownFieldSet unknownFields) {return this;
}//@@protoc_insertion_point(builder_scope:accountService.AccountQryResponse)
}//@@protoc_insertion_point(class_scope:accountService.AccountQryResponse)
private static finalcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse DEFAULT_INSTANCE;static{
DEFAULT_INSTANCE= newcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse();
}public staticcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse getDefaultInstance() {returnDEFAULT_INSTANCE;
}private static final com.google.protobuf.ParserPARSER= new com.google.protobuf.AbstractParser() {publicAccountQryResponse parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)throwscom.google.protobuf.InvalidProtocolBufferException {try{return newAccountQryResponse(input, extensionRegistry);
}catch(RuntimeException e) {if (e.getCause() instanceofcom.google.protobuf.InvalidProtocolBufferException) {throw(com.google.protobuf.InvalidProtocolBufferException)
e.getCause();
}throwe;
}
}
};public static com.google.protobuf.Parserparser() {returnPARSER;
}
@java.lang.Overridepublic com.google.protobuf.ParsergetParserForType() {returnPARSER;
}publiccom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse getDefaultInstanceForType() {returnDEFAULT_INSTANCE;
}
}private staticcom.google.protobuf.Descriptors.Descriptor
internal_static_accountService_AccountQryRequest_descriptor;private staticcom.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_accountService_AccountQryRequest_fieldAccessorTable;private staticcom.google.protobuf.Descriptors.Descriptor
internal_static_accountService_AccountQryResponse_descriptor;private staticcom.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_accountService_AccountQryResponse_fieldAccessorTable;public staticcom.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {returndescriptor;
}private staticcom.google.protobuf.Descriptors.FileDescriptor
descriptor;static{
java.lang.String[] descriptorData={"\n\020AccountQry.proto\022\016accountService\"6\n\021Ac" +
"countQryRequest\022\021\n\trequestId\030\001 \001(\t\022\016\n\006us" +
"erId\030\002 \001(\t\"P\n\022AccountQryResponse\022\021\n\trequ" +
"estId\030\001 \001(\t\022\n\n\002rc\030\002 \001(\005\022\013\n\003msg\030\003 \001(\t\022\016\n\006" +
"amount\030\004 \001(\0052a\n\021QryAccountService\022L\n\003Qry" +
"\022!.accountService.AccountQryRequest\032\".ac" +
"countService.AccountQryResponseB0\n\035com.m" +
"zsg.demo.grpc.qryaccountB\017QryAccountProt" +
"ob\006proto3"};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner=
newcom.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {publiccom.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor=root;return null;
}
};
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,newcom.google.protobuf.Descriptors.FileDescriptor[] {
}, assigner);
internal_static_accountService_AccountQryRequest_descriptor=getDescriptor().getMessageTypes().get(0);
internal_static_accountService_AccountQryRequest_fieldAccessorTable= newcom.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_accountService_AccountQryRequest_descriptor,new java.lang.String[] { "RequestId", "UserId", });
internal_static_accountService_AccountQryResponse_descriptor=getDescriptor().getMessageTypes().get(1);
internal_static_accountService_AccountQryResponse_fieldAccessorTable= newcom.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_accountService_AccountQryResponse_descriptor,new java.lang.String[] { "RequestId", "Rc", "Msg", "Amount", });
}//@@protoc_insertion_point(outer_class_scope)
}7、编写接口实现类QryAccountServiceImpl.javapackagecom.mzsg.demo.grpc.qryaccount.impl;importcom.mzsg.demo.grpc.qryaccount.QryAccountProto;importcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryRequest;importcom.mzsg.demo.grpc.qryaccount.QryAccountProto.AccountQryResponse;importcom.mzsg.demo.grpc.qryaccount.QryAccountServiceGrpc.QryAccountService;importio.grpc.stub.StreamObserver;public class QryAccountServiceImpl implementsQryAccountService {public void qry(AccountQryRequest request, StreamObserverresponseObserver) {
System.out.println("qry " +request.getUserId());
AccountQryResponse response= QryAccountProto.AccountQryResponse.newBuilder().setRc(1).setAmount(666).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}
更多推荐
所有评论(0)