Skip to content

Commit

Permalink
Merge pull request #67 from salesforce/bugfix/underscore_rpc
Browse files Browse the repository at this point in the history
Correctly handle underscores in RPC names
  • Loading branch information
rmichela authored Mar 9, 2018
2 parents 70d52bb + a418f1d commit 7fd8078
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,13 @@ public String methodNameUpperUnderscore() {
}

public String methodNamePascalCase() {
return String.valueOf(Character.toUpperCase(methodName.charAt(0))) + methodName.substring(1);
String mn = methodName.replace("_", "");
return String.valueOf(Character.toUpperCase(mn.charAt(0))) + mn.substring(1);
}

public String methodNameCamelCase() {
String mn = methodName.replace("_", "");
return String.valueOf(Character.toLowerCase(mn.charAt(0))) + mn.substring(1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

package com.example.v1;

import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";

service Settings {
rpc SettingsGet_Classic_1 (google.protobuf.Empty) returns (Settings_Classic_1);
rpc SettingsGetClassic2 (google.protobuf.Empty) returns (Settings_Classic_1);
}

message Settings_Classic_1 {
google.protobuf.Timestamp timestamp = 1;
}
8 changes: 4 additions & 4 deletions rx-java/rxgrpc/src/main/resources/RxStub.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class {{className}} {
@java.lang.Deprecated
{{/deprecated}}
public {{#isManyOutput}}io.reactivex.Flowable{{/isManyOutput}}{{^isManyOutput}}io.reactivex.Single{{/isManyOutput}}<{{outputType}}> {{methodName}}({{#isManyInput}}io.reactivex.Flowable{{/isManyInput}}{{^isManyInput}}io.reactivex.Single{{/isManyInput}}<{{inputType}}> rxRequest) {
return com.salesforce.rxgrpc.stub.ClientCalls.{{reactiveCallsMethodName}}(rxRequest, delegateStub::{{methodName}});
return com.salesforce.rxgrpc.stub.ClientCalls.{{reactiveCallsMethodName}}(rxRequest, delegateStub::{{methodNameCamelCase}});
}

{{/methods}}
Expand All @@ -69,7 +69,7 @@ public final class {{className}} {
{{#deprecated}}
@java.lang.Deprecated
{{/deprecated}}
public {{#isManyOutput}}io.reactivex.Flowable{{/isManyOutput}}{{^isManyOutput}}io.reactivex.Single{{/isManyOutput}}<{{outputType}}> {{methodName}}({{#isManyInput}}io.reactivex.Flowable{{/isManyInput}}{{^isManyInput}}io.reactivex.Single{{/isManyInput}}<{{inputType}}> request) {
public {{#isManyOutput}}io.reactivex.Flowable{{/isManyOutput}}{{^isManyOutput}}io.reactivex.Single{{/isManyOutput}}<{{outputType}}> {{methodNameCamelCase}}({{#isManyInput}}io.reactivex.Flowable{{/isManyInput}}{{^isManyInput}}io.reactivex.Single{{/isManyInput}}<{{inputType}}> request) {
throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED);
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public final class {{className}} {
case METHODID_{{methodNameUpperUnderscore}}:
com.salesforce.rxgrpc.stub.ServerCalls.{{reactiveCallsMethodName}}(({{inputType}}) request,
(io.grpc.stub.StreamObserver<{{outputType}}>) responseObserver,
serviceImpl::{{methodName}});
serviceImpl::{{methodNameCamelCase}});
break;
{{/isManyInput}}
{{/methods}}
Expand All @@ -133,7 +133,7 @@ public final class {{className}} {
case METHODID_{{methodNameUpperUnderscore}}:
return (io.grpc.stub.StreamObserver<Req>) com.salesforce.rxgrpc.stub.ServerCalls.{{reactiveCallsMethodName}}(
(io.grpc.stub.StreamObserver<{{outputType}}>) responseObserver,
serviceImpl::{{methodName}});
serviceImpl::{{methodNameCamelCase}});
{{/isManyInput}}
{{/methods}}
default:
Expand Down

0 comments on commit 7fd8078

Please sign in to comment.