@Test public void toBuilderTest() { MethodDescriptor<String, String> md1 = MethodDescriptor.<String, String>newBuilder() .setType(MethodType.UNARY) .setFullMethodName("package.service/method") .setRequestMarshaller(StringMarshaller.INSTANCE) .setResponseMarshaller(StringMarshaller.INSTANCE) .setSampledToLocalTracing(true) .setIdempotent(true) .setSafe(true) .setSchemaDescriptor(new Object()) .build(); MethodDescriptor<String, String> defaults = MethodDescriptor.<String, String>newBuilder() .setType(MethodType.UNARY) .setFullMethodName("package.service/method") .setRequestMarshaller(StringMarshaller.INSTANCE) .setResponseMarshaller(StringMarshaller.INSTANCE) .build(); assertNotEquals(md1.isSampledToLocalTracing(), defaults.isSampledToLocalTracing()); assertNotEquals(md1.isIdempotent(), defaults.isIdempotent()); assertNotEquals(md1.isSafe(), defaults.isSafe()); assertNotEquals(md1.getSchemaDescriptor(), defaults.getSchemaDescriptor()); MethodDescriptor<Integer, Integer> md2 = md1.toBuilder( IntegerMarshaller.INSTANCE, IntegerMarshaller.INSTANCE).build(); assertSame(md1.getType(), md2.getType()); assertSame(md1.getFullMethodName(), md2.getFullMethodName()); assertSame(IntegerMarshaller.INSTANCE, md2.getRequestMarshaller()); assertSame(IntegerMarshaller.INSTANCE, md2.getResponseMarshaller()); assertEquals(md1.isSampledToLocalTracing(), md2.isSampledToLocalTracing()); assertEquals(md1.isIdempotent(), md2.isIdempotent()); assertEquals(md1.isSafe(), md2.isSafe()); assertSame(md1.getSchemaDescriptor(), md2.getSchemaDescriptor()); }
@CheckReturnValue public Builder<ReqT, RespT> toBuilder() { return toBuilder(requestMarshaller, responseMarshaller); }
MethodDescriptor { @CheckReturnValue public Builder<ReqT, RespT> toBuilder() { return toBuilder(requestMarshaller, responseMarshaller); } }
MethodDescriptor { @CheckReturnValue public Builder<ReqT, RespT> toBuilder() { return toBuilder(requestMarshaller, responseMarshaller); } private  MethodDescriptor(
      MethodType type,
      String fullMethodName,
      Marshaller<ReqT> requestMarshaller,
      Marshaller<RespT> responseMarshaller,
      Object schemaDescriptor,
      boolean idempotent,
      boolean safe,
      boolean sampledToLocalTracing); }
MethodDescriptor { @CheckReturnValue public Builder<ReqT, RespT> toBuilder() { return toBuilder(requestMarshaller, responseMarshaller); } private  MethodDescriptor(
      MethodType type,
      String fullMethodName,
      Marshaller<ReqT> requestMarshaller,
      Marshaller<RespT> responseMarshaller,
      Object schemaDescriptor,
      boolean idempotent,
      boolean safe,
      boolean sampledToLocalTracing); @Deprecated static MethodDescriptor<RequestT, ResponseT> create(
      MethodType type, String fullMethodName,
      Marshaller<RequestT> requestMarshaller,
      Marshaller<ResponseT> responseMarshaller); MethodType getType(); String getFullMethodName(); RespT parseResponse(InputStream input); InputStream streamRequest(ReqT requestMessage); ReqT parseRequest(InputStream input); InputStream streamResponse(RespT response); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2592") Marshaller<ReqT> getRequestMarshaller(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2592") Marshaller<RespT> getResponseMarshaller(); @Nullable Object getSchemaDescriptor(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1775") boolean isIdempotent(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1775") boolean isSafe(); boolean isSampledToLocalTracing(); static String generateFullMethodName(String fullServiceName, String methodName); @Nullable static String extractFullServiceName(String fullMethodName); @CheckReturnValue static Builder<ReqT, RespT> newBuilder(); @CheckReturnValue static Builder<ReqT, RespT> newBuilder(
      Marshaller<ReqT> requestMarshaller, Marshaller<RespT> responseMarshaller); @CheckReturnValue Builder<ReqT, RespT> toBuilder(); @CheckReturnValue Builder<NewReqT, NewRespT> toBuilder(
      Marshaller<NewReqT> requestMarshaller, Marshaller<NewRespT> responseMarshaller); @Override String toString(); }
MethodDescriptor { @CheckReturnValue public Builder<ReqT, RespT> toBuilder() { return toBuilder(requestMarshaller, responseMarshaller); } private  MethodDescriptor(
      MethodType type,
      String fullMethodName,
      Marshaller<ReqT> requestMarshaller,
      Marshaller<RespT> responseMarshaller,
      Object schemaDescriptor,
      boolean idempotent,
      boolean safe,
      boolean sampledToLocalTracing); @Deprecated static MethodDescriptor<RequestT, ResponseT> create(
      MethodType type, String fullMethodName,
      Marshaller<RequestT> requestMarshaller,
      Marshaller<ResponseT> responseMarshaller); MethodType getType(); String getFullMethodName(); RespT parseResponse(InputStream input); InputStream streamRequest(ReqT requestMessage); ReqT parseRequest(InputStream input); InputStream streamResponse(RespT response); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2592") Marshaller<ReqT> getRequestMarshaller(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2592") Marshaller<RespT> getResponseMarshaller(); @Nullable Object getSchemaDescriptor(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1775") boolean isIdempotent(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1775") boolean isSafe(); boolean isSampledToLocalTracing(); static String generateFullMethodName(String fullServiceName, String methodName); @Nullable static String extractFullServiceName(String fullMethodName); @CheckReturnValue static Builder<ReqT, RespT> newBuilder(); @CheckReturnValue static Builder<ReqT, RespT> newBuilder(
      Marshaller<ReqT> requestMarshaller, Marshaller<RespT> responseMarshaller); @CheckReturnValue Builder<ReqT, RespT> toBuilder(); @CheckReturnValue Builder<NewReqT, NewRespT> toBuilder(
      Marshaller<NewReqT> requestMarshaller, Marshaller<NewRespT> responseMarshaller); @Override String toString();  }