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

com.linkedin.restli.client.config.RequestConfigProvider Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
package com.linkedin.restli.client.config;

import java.util.function.Function;

import com.linkedin.restli.client.InboundRequestContextFinder;
import com.linkedin.restli.client.ParSeqRestliClientConfig;
import com.linkedin.restli.client.Request;

@FunctionalInterface
public interface RequestConfigProvider extends Function, RequestConfig> {

  /**
   * @param config configuration
   * @param inboundRequestContextFinder request config finder
   * @throws RuntimeException throws exception if config provider could not be built
   * @return instance of RequestConfigProvider
   */
  public static RequestConfigProvider build(ParSeqRestliClientConfig config, InboundRequestContextFinder inboundRequestContextFinder) {
    try {
      RequestConfigProviderBuilder builder = new RequestConfigProviderBuilder();
      builder.setInboundRequestFinder(inboundRequestContextFinder)
        .addConfig(getDefaultConfig());
      if (config != null) {
        builder.addConfig(config);
      }
      return builder.build();
    } catch (RequestConfigKeyParsingException e) {
      throw new RuntimeException(e);
    }
  }

  public static ParSeqRestliClientConfig getDefaultConfig() {
    return RequestConfigProviderImpl.DEFAULT_CONFIG;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy