com.fullcontact.rpc.jersey.yaml.YamlHttpRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protoc-gen-jersey Show documentation
Show all versions of protoc-gen-jersey Show documentation
protoc-gen-jersey developed by FullContact
package com.fullcontact.rpc.jersey.yaml;
import com.google.api.HttpRule;
import lombok.Value;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* HTTPRules defined in the .yml will be parsed into a YamlHTTPRule, from which a com.google.api.HttpRule can be generated.
*
* @author Kyle Hansen (sypticus)
*/
@Value
public class YamlHttpRule {
String selector;
String get;
String post;
String put;
String delete;
String body;
List additionalBindings;
public HttpRule buildHttpRule() {
HttpRule.Builder builder = HttpRule.newBuilder();
if(get != null){
builder.setGet(get);
}
if(put != null){
builder.setPut(put);
}
if(delete != null){
builder.setDelete(delete);
}
if(post != null){
builder.setPost(post);
}
if(body != null){
builder.setBody(body);
}
if(additionalBindings != null){
builder.addAllAdditionalBindings(additionalBindings.stream().map(YamlHttpRule::buildHttpRule).collect(Collectors.toList()));
}
return builder.build();
}
}