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()); }
.extensions(extensions.build()) .options(options.build()) .reserveds(reserveds.build()) .groups(groups.build()) .build();
@Test public void reservedToSchema() { TypeElement element = MessageElement.builder(location) .name("Message") .reserveds(ImmutableList.of( ReservedElement.create(location, "", ImmutableList.<Object>of(10, Range.closed(12, 14), "foo")), ReservedElement.create(location, "", ImmutableList.<Object>of(10)), ReservedElement.create(location, "", ImmutableList.<Object>of(Range.closed(12, 14))), ReservedElement.create(location, "", ImmutableList.<Object>of("foo")))) .build(); String expected = "" + "message Message {\n" + " reserved 10, 12 to 14, \"foo\";\n" + " reserved 10;\n" + " reserved 12 to 14;\n" + " reserved \"foo\";\n" + "}\n"; assertThat(element.toSchema()).isEqualTo(expected); }
.extensions(extensions.build()) .options(options.build()) .reserveds(reserveds.build()) .groups(groups.build()) .build();
.extensions(extensions.build()) .options(options.build()) .reserveds(reserveds.build()) .groups(groups.build()) .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(); } }
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(); } }
@Test public void reserved() { String proto = "" + "message Foo {\n" + " reserved 10, 12 to 14, 'foo';" + "}"; TypeElement message = MessageElement.builder(location.at(1, 1)) .name("Foo") .reserveds(ImmutableList.of(ReservedElement.create(location.at(2, 3), "", ImmutableList.<Object>of(10, Range.closed(12, 14), "foo")))) .build(); ProtoFileElement expected = ProtoFileElement.builder(location) .types(ImmutableList.of(message)) .build(); assertThat(ProtoParser.parse(location, proto)).isEqualTo(expected); }