/** Reads a scalar, map, or type name. */ private String readDataType() { String name = readWord(); return readDataType(name); }
/** Reads a scalar, map, or type name with {@code name} as a prefix word. */ private String readDataType(String name) { if (name.equals("map")) { if (readChar() != '<') throw unexpected("expected '<'"); String keyType = readDataType(); if (readChar() != ',') throw unexpected("expected ','"); String valueType = readDataType(); if (readChar() != '>') throw unexpected("expected '>'"); return String.format("map<%s, %s>", keyType, valueType); } else { return name; } }
type = readDataType(); break; type = readDataType(); break; type = readDataType(); break; type = readDataType(word); break;
private OneOfElement readOneOf(String documentation) { OneOfElement.Builder builder = OneOfElement.builder() .name(readName()) .documentation(documentation); ImmutableList.Builder<FieldElement> fields = ImmutableList.builder(); ImmutableList.Builder<GroupElement> groups = ImmutableList.builder(); if (readChar() != '{') throw unexpected("expected '{'"); while (true) { String nestedDocumentation = readDocumentation(); if (peekChar() == '}') { pos++; break; } Location location = location(); String type = readDataType(); if (type.equals("group")) { groups.add(readGroup(nestedDocumentation, null)); } else { fields.add(readField(location, nestedDocumentation, null, type)); } } return builder.fields(fields.build()) .groups(groups.build()) .build(); }
if (word.equals("stream")) { builder.requestStreaming(true); type = readDataType(); } else { type = readDataType(word); if (word.equals("stream")) { builder.responseStreaming(true); type = readDataType(); } else { type = readDataType(word);