public static Builder builder(Location location) { return new AutoValue_EnumConstantElement.Builder() .location(location) .documentation("") .options(ImmutableList.<OptionElement>of()); }
@Test public void fieldWithOptionsToSchema() { EnumConstantElement value = EnumConstantElement.builder(location) .name("NAME") .tag(1) .options(ImmutableList.of( OptionElement.create("kit", STRING, "kat", true), OptionElement.create("tit", STRING, "tat"))) .build(); String expected = "NAME = 1 [\n" + " (kit) = \"kat\",\n" + " tit = \"tat\"\n" + "];\n"; assertThat(value.toSchema()).isEqualTo(expected); } }
.name("STRING") .tag(0) .options(ImmutableList.of( OptionElement.create("opt_a", Kind.NUMBER, "1", true), OptionElement.create("opt_b", Kind.NUMBER, "2", true)))
documentation = tryAppendTrailingDocumentation(documentation); return builder.documentation(documentation) .options(options.build()) .build(); } else {
/** Reads an enum constant like "ROCK = 0;". The label is the constant name. */ private EnumConstantElement readEnumConstant( String documentation, Location location, String label) { reader.require('='); int tag = reader.readInt(); ImmutableList.Builder<OptionElement> options = ImmutableList.builder(); if (reader.peekChar() == '[') { reader.readChar(); while (true) { options.add(readOption('=')); char c = reader.readChar(); if (c == ']') { break; } if (c != ',') { throw reader.unexpected("Expected ',' or ']"); } } } reader.require(';'); documentation = reader.tryAppendTrailingDocumentation(documentation); return EnumConstantElement.builder(location) .name(label) .tag(tag) .documentation(documentation) .options(options.build()) .build(); }
public static Builder builder(Location location) { return new AutoValue_EnumConstantElement.Builder() .location(location) .documentation("") .options(ImmutableList.<OptionElement>of()); }
EnumConstantElement toElement() { return EnumConstantElement.builder(location) .documentation(documentation) .name(name) .tag(tag) .options(options.toElements()) .build(); }
public static Builder builder(Location location) { return new AutoValue_EnumConstantElement.Builder() .location(location) .documentation("") .options(ImmutableList.<OptionElement>of()); }
EnumConstantElement toElement() { return EnumConstantElement.builder(location) .documentation(documentation) .name(name) .tag(tag) .options(options.toElements()) .build(); }
.name("FRUIT") .tag(1) .options(ImmutableList.of( OptionElement.create("healthy", Kind.BOOLEAN, "true", true))) .build(),
/** Reads an enum constant like "ROCK = 0;". The label is the constant name. */ private EnumConstantElement readEnumConstant( String documentation, Location location, String label) { reader.require('='); int tag = reader.readInt(); ImmutableList<OptionElement> options = new OptionReader(reader).readOptions(); reader.require(';'); documentation = reader.tryAppendTrailingDocumentation(documentation); return EnumConstantElement.builder(location) .name(label) .tag(tag) .documentation(documentation) .options(options) .build(); }
EnumConstantElement toElement() { return EnumConstantElement.builder(location) .documentation(documentation) .name(name) .tag(tag) .options(options.toElements()) .build(); }