public static Builder builder(Location location) { return new AutoValue_ServiceElement.Builder() .location(location) .documentation("") .rpcs(ImmutableList.<RpcElement>of()) .options(ImmutableList.<OptionElement>of()); }
static ImmutableList<ServiceElement> toElements(ImmutableList<Service> services) { ImmutableList.Builder<ServiceElement> elements = new ImmutableList.Builder<>(); for (Service service : services) { elements.add(ServiceElement.builder(service.location) .documentation(service.documentation) .name(service.name) .rpcs(Rpc.toElements(service.rpcs)) .options(service.options.toElements()) .build()); } return elements.build(); } }
/** Reads a service declaration and returns it. */ private ServiceElement readService(Location location, String documentation) { String name = reader.readName(); ServiceElement.Builder builder = ServiceElement.builder(location) .name(name) .documentation(documentation); reader.require('{'); ImmutableList.Builder<RpcElement> rpcs = ImmutableList.builder(); ImmutableList.Builder<OptionElement> options = ImmutableList.builder(); while (true) { String rpcDocumentation = reader.readDocumentation(); if (reader.peekChar('}')) break; Object declared = readDeclaration(rpcDocumentation, Context.SERVICE); if (declared instanceof RpcElement) { rpcs.add((RpcElement) declared); } else if (declared instanceof OptionElement) { options.add((OptionElement) declared); } } return builder.options(options.build()) .rpcs(rpcs.build()) .build(); }
/** Reads a service declaration and returns it. */ private ServiceElement readService(Location location, String documentation) { String name = readName(); ServiceElement.Builder builder = ServiceElement.builder(location) .name(name) .documentation(documentation); if (readChar() != '{') throw unexpected("expected '{'"); ImmutableList.Builder<RpcElement> rpcs = ImmutableList.builder(); ImmutableList.Builder<OptionElement> options = ImmutableList.builder(); while (true) { String rpcDocumentation = readDocumentation(); if (peekChar() == '}') { pos++; break; } Object declared = readDeclaration(rpcDocumentation, Context.SERVICE); if (declared instanceof RpcElement) { rpcs.add((RpcElement) declared); } else if (declared instanceof OptionElement) { options.add((OptionElement) declared); } } return builder.options(options.build()) .rpcs(rpcs.build()) .build(); }
/** Reads a service declaration and returns it. */ private ServiceElement readService(Location location, String documentation) { String name = reader.readName(); ServiceElement.Builder builder = ServiceElement.builder(location) .name(name) .documentation(documentation); reader.require('{'); ImmutableList.Builder<RpcElement> rpcs = ImmutableList.builder(); ImmutableList.Builder<OptionElement> options = ImmutableList.builder(); while (true) { String rpcDocumentation = reader.readDocumentation(); if (reader.peekChar('}')) break; Object declared = readDeclaration(rpcDocumentation, Context.SERVICE); if (declared instanceof RpcElement) { rpcs.add((RpcElement) declared); } else if (declared instanceof OptionElement) { options.add((OptionElement) declared); } } return builder.options(options.build()) .rpcs(rpcs.build()) .build(); }
static ImmutableList<ServiceElement> toElements(ImmutableList<Service> services) { ImmutableList.Builder<ServiceElement> elements = new ImmutableList.Builder<>(); for (Service service : services) { elements.add(ServiceElement.builder(service.location) .documentation(service.documentation) .name(service.name) .rpcs(Rpc.toElements(service.rpcs)) .options(service.options.toElements()) .build()); } return elements.build(); } }
static ImmutableList<ServiceElement> toElements(ImmutableList<Service> services) { ImmutableList.Builder<ServiceElement> elements = new ImmutableList.Builder<>(); for (Service service : services) { elements.add(ServiceElement.builder(service.location) .documentation(service.documentation) .name(service.name) .rpcs(Rpc.toElements(service.rpcs)) .options(service.options.toElements()) .build()); } return elements.build(); } }
public static Builder builder(Location location) { return new AutoValue_ServiceElement.Builder() .location(location) .documentation("") .rpcs(ImmutableList.<RpcElement>of()) .options(ImmutableList.<OptionElement>of()); }
public static Builder builder(Location location) { return new AutoValue_ServiceElement.Builder() .location(location) .documentation("") .rpcs(ImmutableList.<RpcElement>of()) .options(ImmutableList.<OptionElement>of()); }
@Test public void singleWithDocumentationToSchema() { ServiceElement service = ServiceElement.builder(location) .name("Service") .documentation("Hello") .rpcs(ImmutableList.of( RpcElement.builder(location) .name("Name") .requestType("RequestType") .responseType("ResponseType") .build())) .build(); String expected = "" + "// Hello\n" + "service Service {\n" + " rpc Name (RequestType) returns (ResponseType);\n" + "}\n"; assertThat(service.toSchema()).isEqualTo(expected); }