use of com.google.protobuf.DescriptorProtos.MethodOptions.IdempotencyLevel in project schema-registry by confluentinc.
the class ProtobufSchema method toDynamicService.
private static ServiceDefinition toDynamicService(ServiceElement serviceElement) {
ServiceDefinition.Builder service = ServiceDefinition.newBuilder(serviceElement.getName());
Map<String, OptionElement> serviceOptions = mergeOptions(serviceElement.getOptions());
Boolean isDeprecated = findOption(DEPRECATED, serviceOptions).map(o -> Boolean.valueOf(o.getValue().toString())).orElse(null);
if (isDeprecated != null) {
service.setDeprecated(isDeprecated);
}
for (RpcElement method : serviceElement.getRpcs()) {
Map<String, OptionElement> methodOptions = mergeOptions(method.getOptions());
Boolean isMethodDeprecated = findOption(DEPRECATED, methodOptions).map(o -> Boolean.valueOf(o.getValue().toString())).orElse(null);
IdempotencyLevel idempotencyLevel = findOption(IDEMPOTENCY_LEVEL, methodOptions).map(o -> IdempotencyLevel.valueOf(o.getValue().toString())).orElse(null);
service.addMethod(method.getName(), method.getRequestType(), method.getResponseType(), method.getRequestStreaming(), method.getResponseStreaming(), isMethodDeprecated, idempotencyLevel);
}
return service.build();
}
Aggregations