Search in sources :

Example 1 with GenericFieldSelector

use of com.google.api.codegen.config.GenericFieldSelector in project toolkit by googleapis.

the class BatchingTransformer method generateDiscriminatorFieldCopies.

private List<FieldCopyView> generateDiscriminatorFieldCopies(MethodContext context) {
    List<FieldCopyView> fieldCopies = new ArrayList<>();
    BatchingConfig batching = context.getMethodConfig().getBatching();
    for (GenericFieldSelector fieldSelector : batching.getDiscriminatorFields()) {
        FieldModel selectedType = fieldSelector.getLastField();
        FieldCopyView fieldCopy = FieldCopyView.newBuilder().fieldGetFunction(context.getNamer().getFieldGetFunctionName(selectedType)).fieldSetFunction(context.getNamer().getFieldSetFunctionName(selectedType)).build();
        fieldCopies.add(fieldCopy);
    }
    return fieldCopies;
}
Also used : FieldCopyView(com.google.api.codegen.viewmodel.FieldCopyView) ArrayList(java.util.ArrayList) BatchingConfig(com.google.api.codegen.config.BatchingConfig) GenericFieldSelector(com.google.api.codegen.config.GenericFieldSelector) FieldModel(com.google.api.codegen.config.FieldModel)

Example 2 with GenericFieldSelector

use of com.google.api.codegen.config.GenericFieldSelector in project toolkit by googleapis.

the class BatchingTransformer method generatePartitionKeys.

private List<BatchingPartitionKeyView> generatePartitionKeys(MethodContext context) {
    List<BatchingPartitionKeyView> keys = new ArrayList<>();
    BatchingConfig batching = context.getMethodConfig().getBatching();
    for (GenericFieldSelector fieldSelector : batching.getDiscriminatorFields()) {
        FieldModel selectedType = fieldSelector.getLastField();
        BatchingPartitionKeyView key = BatchingPartitionKeyView.newBuilder().fieldGetFunction(context.getNamer().getFieldGetFunctionName(selectedType)).build();
        keys.add(key);
    }
    return keys;
}
Also used : ArrayList(java.util.ArrayList) BatchingConfig(com.google.api.codegen.config.BatchingConfig) GenericFieldSelector(com.google.api.codegen.config.GenericFieldSelector) BatchingPartitionKeyView(com.google.api.codegen.viewmodel.BatchingPartitionKeyView) FieldModel(com.google.api.codegen.config.FieldModel)

Aggregations

BatchingConfig (com.google.api.codegen.config.BatchingConfig)2 FieldModel (com.google.api.codegen.config.FieldModel)2 GenericFieldSelector (com.google.api.codegen.config.GenericFieldSelector)2 ArrayList (java.util.ArrayList)2 BatchingPartitionKeyView (com.google.api.codegen.viewmodel.BatchingPartitionKeyView)1 FieldCopyView (com.google.api.codegen.viewmodel.FieldCopyView)1