private GroupElement readGroup(Location location, String documentation, Field.Label label) { String name = reader.readWord(); reader.require('='); int tag = reader.readInt(); GroupElement.Builder builder = GroupElement.builder(location) .label(label) .name(name) .tag(tag) .documentation(documentation); ImmutableList.Builder<FieldElement> fields = ImmutableList.builder(); reader.require('{'); while (true) { String nestedDocumentation = reader.readDocumentation(); if (reader.peekChar('}')) break; Location fieldLocation = reader.location(); String fieldLabel = reader.readWord(); Object field = readField(nestedDocumentation, fieldLocation, fieldLabel); if (!(field instanceof FieldElement)) { throw reader.unexpected("expected field declaration, was " + field); } fields.add((FieldElement) field); } return builder.fields(fields.build()) .build(); }
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); if (label() != null) { builder.append(label().name().toLowerCase(Locale.US)).append(' '); } builder.append("group ") .append(name()) .append(" = ") .append(tag()) .append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } return builder.append("}\n").toString(); }
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("oneof ").append(name()).append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } if (!groups().isEmpty()) { builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema()); } } return builder.append("}\n").toString(); }
Builder(GroupElement source) { this.label = source.label(); this.name = source.name(); this.tag = source.tag(); this.documentation = source.documentation(); this.fields = source.fields(); } @Override
.tag(1) .build())) .groups(ImmutableList.of(GroupElement.builder(location.at(5, 5)) .name("Stuff") .tag(3)
builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema());
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof GroupElement) { GroupElement that = (GroupElement) o; return ((this.label == null) ? (that.label() == null) : this.label.equals(that.label())) && (this.name.equals(that.name())) && (this.tag == that.tag()) && (this.documentation.equals(that.documentation())) && (this.fields.equals(that.fields())); } return false; }
.tag(2) .build())) .groups(ImmutableList.of(GroupElement.builder(location.at(5, 5)) .name("Stuff") .tag(3)
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("oneof ").append(name()).append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } if (!groups().isEmpty()) { builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema()); } } return builder.append("}\n").toString(); }
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); if (label() != null) { builder.append(label().name().toLowerCase(Locale.US)).append(' '); } builder.append("group ") .append(name()) .append(" = ") .append(tag()) .append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } return builder.append("}\n").toString(); }
.name("SearchResponse") .groups(ImmutableList.of( GroupElement.builder(location.at(2, 3)) .label(REPEATED) .name("Result")
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("oneof ").append(name()).append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } if (!groups().isEmpty()) { builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema()); } } return builder.append("}\n").toString(); }
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); if (label() != null) { builder.append(label().name().toLowerCase(Locale.US)).append(' '); } builder.append("group ") .append(name()) .append(" = ") .append(tag()) .append(" {"); if (!fields().isEmpty()) { builder.append('\n'); for (FieldElement field : fields()) { appendIndented(builder, field.toSchema()); } } return builder.append("}\n").toString(); }
.name("SearchResponse") .groups(ImmutableList.of( GroupElement.builder(location.at(2, 3)) .label(REPEATED) .name("Result")
builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema());
private GroupElement readGroup(String documentation, Field.Label label) { String name = reader.readWord(); reader.require('='); int tag = reader.readInt(); GroupElement.Builder builder = GroupElement.builder() .label(label) .name(name) .tag(tag) .documentation(documentation); ImmutableList.Builder<FieldElement> fields = ImmutableList.builder(); reader.require('{'); while (true) { String nestedDocumentation = reader.readDocumentation(); if (reader.peekChar('}')) break; Location location = reader.location(); String fieldLabel = reader.readWord(); Object field = readField(nestedDocumentation, location, fieldLabel); if (!(field instanceof FieldElement)) { throw reader.unexpected("expected field declaration, was " + field); } fields.add((FieldElement) field); } return builder.fields(fields.build()) .build(); }
builder.append('\n'); for (GroupElement group : groups()) { appendIndented(builder, group.toSchema());
private GroupElement readGroup(String documentation, Field.Label label) { String name = readWord(); if (readChar() != '=') { throw unexpected("expected '='"); } int tag = readInt(); GroupElement.Builder builder = GroupElement.builder() .label(label) .name(name) .tag(tag) .documentation(documentation); ImmutableList.Builder<FieldElement> fields = ImmutableList.builder(); if (readChar() != '{') throw unexpected("expected '{'"); while (true) { String nestedDocumentation = readDocumentation(); if (peekChar() == '}') { pos++; break; } Location location = location(); String fieldLabel = readWord(); Object field = readField(nestedDocumentation, location, fieldLabel); if (!(field instanceof FieldElement)) { throw unexpected("expected field declaration, was " + field); } fields.add((FieldElement) field); } return builder.fields(fields.build()) .build(); }