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())
@Test public void addMultipleTypes() { TypeElement nested1 = MessageElement.builder(location).name("Nested1").build(); TypeElement nested2 = MessageElement.builder(location).name("Nested2").build(); TypeElement element = MessageElement.builder(location) .name("Message") .fields(ImmutableList.of(FieldElement.builder(location) .label(REQUIRED) .type("string") .name("name") .tag(1) .build())) .nestedTypes(ImmutableList.of(nested1, nested2)) .build(); assertThat(element.nestedTypes()).hasSize(2); }
.nestedTypes(nestedTypes.build()) .extensions(extensions.build()) .options(options.build())
.nestedTypes(nestedTypes.build()) .extensions(extensions.build()) .options(options.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(); } }
.fields(ImmutableList.of(field1, field2)) .oneOfs(ImmutableList.of(oneOf1, oneOf2)) .nestedTypes(ImmutableList.of(nested)) .extensions(ImmutableList.of(extensions1, extensions2)) .options(ImmutableList.of(option))
.name("FieldOptions") .fields(ImmutableList.of(field)) .nestedTypes(ImmutableList.of(enumElement)) .extensions(ImmutableList.of( ExtensionsElement.create(location.at(7, 3), 500, 500,
.tag(1) .build())) .nestedTypes(ImmutableList.<TypeElement>of( MessageElement.builder(location) .name("Nested")
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(); } }
MessageElement toElement() { return MessageElement.builder(location) .name(type.simpleName()) .nestedTypes(Type.toElements(nestedTypes)) .build(); } }