com.google.protobuf.DescriptorProtos.MethodOptions Java Examples

The following examples show how to use com.google.protobuf.DescriptorProtos.MethodOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtoApiFromOpenApi.java    From api-compiler with Apache License 2.0 5 votes vote down vote up
/** Adds a {@link Method} from {@link Operation}. */
private void addMethodFromOperation(
    Service.Builder serviceBuilder,
    Operation operation,
    Path parentPath,
    String operationType,
    String path) {
  TypeInfo responseTypeInfo = getResponseTypeInfo(serviceBuilder, operation);
  TypeInfo requestType =
      getRequestTypeInfo(
          serviceBuilder,
          operation,
          parentPath,
          OpenApiLocations.createOperationLocation(operationType, path));

  com.google.protobuf.Method.Builder coreMethodBuilder =
      com.google.protobuf.Method.newBuilder()
          .setName(NameConverter.operationIdToMethodName(operation.getOperationId()))
          .setRequestTypeUrl(requestType.typeUrl())
          .setResponseTypeUrl(responseTypeInfo.typeUrl());
  if (operation.isDeprecated() != null && operation.isDeprecated()) {
    coreMethodBuilder.addOptions(
        createBoolOption(
            MethodOptions.getDescriptor()
                .findFieldByNumber(MethodOptions.DEPRECATED_FIELD_NUMBER)
                .getFullName(),
            true));
  }
  coreApiBuilder.addMethods(coreMethodBuilder);
}
 
Example #2
Source File: DescriptorGenerator.java    From api-compiler with Apache License 2.0 4 votes vote down vote up
private MethodOptions generateMethodOptions(Method method) {
  MethodOptions.Builder builder = MethodOptions.newBuilder();
  setOptions(builder, method.getOptionsList(), METHOD_OPTION_NAME_PREFIX);
  return builder.build();
}
 
Example #3
Source File: Method.java    From api-compiler with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a method-level annotation, or null if it is a stream.
 */
public <T extends Message> T getMethodAnnotation(Extension<MethodOptions, T> extension) {
  return methodProto.getOptions().getExtension(extension);
}
 
Example #4
Source File: Descriptors.java    From play-store-api with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the {@code MethodOptions}, defined in {@code descriptor.proto}.
 */
public MethodOptions getOptions() { return proto.getOptions(); }