use of com.google.api.codegen.viewmodel.BatchingDescriptorClassView in project toolkit by googleapis.
the class BatchingTransformer method generateDescriptorClass.
private BatchingDescriptorClassView generateDescriptorClass(MethodContext context) {
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getMethodModel();
BatchingConfig batching = context.getMethodConfig().getBatching();
FieldModel batchedField = batching.getBatchedField();
FieldModel subresponseField = batching.getSubresponseField();
BatchingDescriptorClassView.Builder desc = BatchingDescriptorClassView.newBuilder();
desc.name(context.getNamer().getBatchingDescriptorConstName(context.getMethodModel()));
desc.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
desc.responseTypeName(method.getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
desc.batchedFieldTypeName(context.getTypeTable().getAndSaveNicknameFor(batchedField));
desc.partitionKeys(generatePartitionKeys(context));
desc.discriminatorFieldCopies(generateDiscriminatorFieldCopies(context));
desc.batchedFieldGetFunction(namer.getFieldGetFunctionName(batchedField));
desc.batchedFieldSetFunction(namer.getFieldSetFunctionName(batchedField));
desc.batchedFieldCountGetFunction(namer.getFieldCountGetFunctionName(batchedField));
if (subresponseField != null) {
desc.subresponseTypeName(context.getTypeTable().getAndSaveNicknameFor(subresponseField));
desc.subresponseByIndexGetFunction(namer.getByIndexGetFunctionName(subresponseField));
desc.subresponseSetFunction(namer.getFieldSetFunctionName(subresponseField));
}
return desc.build();
}
use of com.google.api.codegen.viewmodel.BatchingDescriptorClassView in project toolkit by googleapis.
the class BatchingTransformer method generateDescriptorClasses.
public List<BatchingDescriptorClassView> generateDescriptorClasses(InterfaceContext context) {
List<BatchingDescriptorClassView> descriptors = new ArrayList<>();
for (MethodModel method : context.getInterfaceConfigMethods()) {
MethodConfig methodConfig = context.getMethodConfig(method);
if (methodConfig == null) {
continue;
}
if (!methodConfig.isBatching()) {
continue;
}
descriptors.add(generateDescriptorClass(context.asRequestMethodContext(method)));
}
return descriptors;
}
Aggregations