public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("service ") .append(name()) .append(" {"); if (!options().isEmpty()) { builder.append('\n'); for (OptionElement option : options()) { appendIndented(builder, option.toSchemaDeclaration()); } } if (!rpcs().isEmpty()) { builder.append('\n'); for (RpcElement rpc : rpcs()) { appendIndented(builder, rpc.toSchema()); } } return builder.append("}\n").toString(); }
static Service fromElement(ProtoType protoType, ServiceElement element) { ImmutableList<Rpc> rpcs = Rpc.fromElements(element.rpcs()); Options options = new Options(Options.SERVICE_OPTIONS, element.options()); return new Service(protoType, element.location(), element.documentation(), element.name(), rpcs, options); }
@Test public void addMultipleRpcs() { RpcElement firstName = RpcElement.builder(location) .name("FirstName") .requestType("RequestType") .responseType("ResponseType") .build(); RpcElement lastName = RpcElement.builder(location) .name("LastName") .requestType("RequestType") .responseType("ResponseType") .build(); ServiceElement service = ServiceElement.builder(location) .name("Service") .rpcs(ImmutableList.of(firstName, lastName)) .build(); assertThat(service.rpcs()).hasSize(2); }
public List<RpcMethodDefinition> getRpcMethods() throws IOException { List<RpcMethodDefinition> retval = new ArrayList<>(); ProtoParser parser = new ProtoParser(Location.get(input.getCanonicalPath()), gulpFile(input)); ProtoFileElement element = parser.readProtoFile(); if (protoFileMatchesPackage(element)) { List<ServiceElement> services = element.services(); if (services != null) { for (ServiceElement service : services) { String name = service.name(); List<RpcElement> rpcs = service.rpcs(); if (rpcs != null) { for (RpcElement rpc : rpcs) { RpcMethodDefinition def = new RpcMethodDefinition(name + "." + rpc.name(), rpc.requestType(), rpc.responseType(), element.packageName(), fileName ); retval.add(def); } } } } } return retval; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof ServiceElement) { ServiceElement that = (ServiceElement) o; return (this.location.equals(that.location())) && (this.name.equals(that.name())) && (this.documentation.equals(that.documentation())) && (this.rpcs.equals(that.rpcs())) && (this.options.equals(that.options())); } return false; }
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("service ") .append(name()) .append(" {"); if (!options().isEmpty()) { builder.append('\n'); for (OptionElement option : options()) { appendIndented(builder, option.toSchemaDeclaration()); } } if (!rpcs().isEmpty()) { builder.append('\n'); for (RpcElement rpc : rpcs()) { appendIndented(builder, rpc.toSchema()); } } return builder.append("}\n").toString(); }
public final String toSchema() { StringBuilder builder = new StringBuilder(); appendDocumentation(builder, documentation()); builder.append("service ") .append(name()) .append(" {"); if (!options().isEmpty()) { builder.append('\n'); for (OptionElement option : options()) { appendIndented(builder, option.toSchemaDeclaration()); } } if (!rpcs().isEmpty()) { builder.append('\n'); for (RpcElement rpc : rpcs()) { appendIndented(builder, rpc.toSchema()); } } return builder.append("}\n").toString(); }
Builder(ServiceElement source) { this.location = source.location(); this.name = source.name(); this.documentation = source.documentation(); this.rpcs = source.rpcs(); this.options = source.options(); } @Override
static Service fromElement(ProtoType protoType, ServiceElement element) { ImmutableList<Rpc> rpcs = Rpc.fromElements(element.rpcs()); Options options = new Options(Options.SERVICE_OPTIONS, element.options()); return new Service(protoType, element.location(), element.documentation(), element.name(), rpcs, options); }
static Service fromElement(ProtoType protoType, ServiceElement element) { ImmutableList<Rpc> rpcs = Rpc.fromElements(element.rpcs()); Options options = new Options(Options.SERVICE_OPTIONS, element.options()); return new Service(protoType, element.location(), element.documentation(), element.name(), rpcs, options); }