public static Builder builder(Location location) { return new AutoValue_MessageElement.Builder() .location(location) .documentation("") .fields(ImmutableList.<FieldElement>of()) .oneOfs(ImmutableList.<OneOfElement>of()) .nestedTypes(ImmutableList.<TypeElement>of()) .extensions(ImmutableList.<ExtensionsElement>of()) .options(ImmutableList.<OptionElement>of()) .reserveds(ImmutableList.<ReservedElement>of()) .groups(ImmutableList.<GroupElement>of()); }
.nestedTypes(nestedTypes.build()) .extensions(extensions.build()) .options(options.build()) .reserveds(reserveds.build()) .groups(groups.build())
MessageElement.builder(location.at(1, 1)) .name("ExoticOptions") .options(ImmutableList.of( OptionElement.create("squareup.one", Kind.MAP, option_one_map, true), OptionElement.create("squareup.two.a", Kind.MAP, option_two_a_map, true),
.nestedTypes(nestedTypes.build()) .extensions(extensions.build()) .options(options.build()) .reserveds(reserveds.build()) .groups(groups.build())
.nestedTypes(nestedTypes.build()) .extensions(extensions.build()) .options(options.build()) .reserveds(reserveds.build()) .groups(groups.build())
MessageElement toElement() { return MessageElement.builder(location) .documentation(documentation) .name(name) .options(options.toElements()) .fields(Field.toElements(declaredFields)) .nestedTypes(Type.toElements(nestedTypes)) .oneOfs(OneOf.toElements(oneOfs)) .extensions(Extensions.toElements(extensionsList)) .reserveds(Reserved.toElements(reserveds)) .build(); } }
public static Builder builder(Location location) { return new AutoValue_MessageElement.Builder() .location(location) .documentation("") .fields(ImmutableList.<FieldElement>of()) .oneOfs(ImmutableList.<OneOfElement>of()) .nestedTypes(ImmutableList.<TypeElement>of()) .extensions(ImmutableList.<ExtensionsElement>of()) .options(ImmutableList.<OptionElement>of()) .reserveds(ImmutableList.<ReservedElement>of()) .groups(ImmutableList.<GroupElement>of()); }
public static Builder builder(Location location) { return new AutoValue_MessageElement.Builder() .location(location) .documentation("") .fields(ImmutableList.<FieldElement>of()) .oneOfs(ImmutableList.<OneOfElement>of()) .nestedTypes(ImmutableList.<TypeElement>of()) .extensions(ImmutableList.<ExtensionsElement>of()) .options(ImmutableList.<OptionElement>of()) .reserveds(ImmutableList.<ReservedElement>of()) .groups(ImmutableList.<GroupElement>of()); }
MessageElement toElement() { return MessageElement.builder(location) .documentation(documentation) .name(name) .options(options.toElements()) .fields(Field.toElements(declaredFields)) .nestedTypes(Type.toElements(nestedTypes)) .oneOfs(OneOf.toElements(oneOfs)) .extensions(Extensions.toElements(extensionsList)) .reserveds(Reserved.toElements(reserveds)) .build(); } }
.nestedTypes(ImmutableList.of(nested)) .extensions(ImmutableList.of(extensions1, extensions2)) .options(ImmutableList.of(option)) .build(); String expected = ""
@Test public void simpleWithOptionsToSchema() { FieldElement field = FieldElement.builder(location) .label(REQUIRED) .type("string") .name("name") .tag(1) .build(); TypeElement element = MessageElement.builder(location) .name("Message") .fields(ImmutableList.of(field)) .options(ImmutableList.of( OptionElement.create("kit", Kind.STRING, "kat"))) .build(); String expected = "" + "message Message {\n" + " option kit = \"kat\";\n" + "\n" + " required string name = 1;\n" + "}\n"; assertThat(element.toSchema()).isEqualTo(expected); }
@Test public void addMultipleOptions() { FieldElement field = FieldElement.builder(location) .label(REQUIRED) .type("string") .name("name") .tag(1) .build(); OptionElement kitKat = OptionElement.create("kit", Kind.STRING, "kat"); OptionElement fooBar = OptionElement.create("foo", Kind.STRING, "bar"); MessageElement element = MessageElement.builder(location) .name("Message") .fields(ImmutableList.of(field)) .options(ImmutableList.of(kitKat, fooBar)) .build(); assertThat(element.options()).hasSize(2); }
MessageElement toElement() { return MessageElement.builder(location) .documentation(documentation) .name(name) .options(options.toElements()) .fields(Field.toElements(declaredFields)) .nestedTypes(Type.toElements(nestedTypes)) .oneOfs(OneOf.toElements(oneOfs)) .extensions(Extensions.toElements(extensionsList)) .reserveds(Reserved.toElements(reserveds)) .build(); } }