All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fullcontact.rpc.jersey.yaml.YamlHttpRule Maven / Gradle / Ivy

There is a newer version: 0.1.3
Show newest version
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();

  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy