Search in sources :

Example 1 with BatchingDescriptorClassView

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();
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) BatchingDescriptorClassView(com.google.api.codegen.viewmodel.BatchingDescriptorClassView) BatchingConfig(com.google.api.codegen.config.BatchingConfig) FieldModel(com.google.api.codegen.config.FieldModel)

Example 2 with BatchingDescriptorClassView

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;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) BatchingDescriptorClassView(com.google.api.codegen.viewmodel.BatchingDescriptorClassView) ArrayList(java.util.ArrayList)

Aggregations

MethodModel (com.google.api.codegen.config.MethodModel)2 BatchingDescriptorClassView (com.google.api.codegen.viewmodel.BatchingDescriptorClassView)2 BatchingConfig (com.google.api.codegen.config.BatchingConfig)1 FieldModel (com.google.api.codegen.config.FieldModel)1 MethodConfig (com.google.api.codegen.config.MethodConfig)1 ArrayList (java.util.ArrayList)1