Search in sources :

Example 6 with NullConfigNode

use of com.google.api.codegen.configgen.nodes.NullConfigNode in project toolkit by googleapis.

the class PageStreamingMerger method generatePageStreamingRequestValueNode.

private ConfigNode generatePageStreamingRequestValueNode(ConfigNode parentNode, int startLine, MethodModel method) {
    String pageTokenName = pageStreamingTransformer.getNameForPageToken();
    String pageSizeName = pageStreamingTransformer.getNameForPageSize();
    boolean hasTokenField = method.getInputField(pageTokenName) != null;
    boolean hasPageSizeField = method.getInputField(pageSizeName) != null;
    ConfigNode requestValueNode = null;
    if (hasPageSizeField) {
        requestValueNode = FieldConfigNode.createStringPair(startLine, "page_size_field", pageSizeName);
        if (hasTokenField) {
            ConfigNode tokenFieldNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(requestValueNode), "token_field", pageTokenName);
            requestValueNode.insertNext(tokenFieldNode);
        }
    } else if (hasTokenField) {
        requestValueNode = FieldConfigNode.createStringPair(startLine, "token_field", pageTokenName);
    } else {
        return new NullConfigNode();
    }
    parentNode.setChild(requestValueNode);
    return requestValueNode;
}
Also used : NullConfigNode(com.google.api.codegen.configgen.nodes.NullConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) NullConfigNode(com.google.api.codegen.configgen.nodes.NullConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode)

Aggregations

ConfigNode (com.google.api.codegen.configgen.nodes.ConfigNode)6 NullConfigNode (com.google.api.codegen.configgen.nodes.NullConfigNode)6 FieldConfigNode (com.google.api.codegen.configgen.nodes.FieldConfigNode)5 ListItemConfigNode (com.google.api.codegen.configgen.nodes.ListItemConfigNode)4 ScalarConfigNode (com.google.api.codegen.configgen.nodes.ScalarConfigNode)4 MappingNode (org.yaml.snakeyaml.nodes.MappingNode)2 NodeTuple (org.yaml.snakeyaml.nodes.NodeTuple)2 Descriptor (com.google.protobuf.Descriptors.Descriptor)1 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)1 Node (org.yaml.snakeyaml.nodes.Node)1 ScalarNode (org.yaml.snakeyaml.nodes.ScalarNode)1 SequenceNode (org.yaml.snakeyaml.nodes.SequenceNode)1