// Path: src/main/java/com/cloudera/director/spi/v2/util/Preconditions.java
// public static void checkArgument(
//     boolean expression, Object message) {
//   if (!expression) {
//     throw new IllegalArgumentException(String.valueOf(message));
//   }
// }
// 
// Path: src/main/java/com/cloudera/director/spi/v2/util/Preconditions.java
// public static <T> T checkNotNull(T instance, String message) {
//   if (instance == null) {
//     throw new NullPointerException(message);
//   }
//   return instance;
// }


import static com.cloudera.director.spi.v2.util.Preconditions.checkArgument;
import static com.cloudera.director.spi.v2.util.Preconditions.checkNotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
// (c) Copyright 2015 Cloudera, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.cloudera.director.spi.v2.common.http;



/**
 * Houses and validates HTTP proxy parameters.
 */
public class HttpProxyParameters {

  private final String host;
  private final int port;
  private final String username;
  private final String password;
  private final String domain;
  private final String workstation;
  private final boolean preemptiveBasicProxyAuth;
  private final List<String> proxyBypassHosts;

  /**
   * Constructs HTTP proxy parameters with default configuration.
   */
  public HttpProxyParameters() {
    this(null, -1, null, null, null, null, false, Collections.<String>emptyList());
  }

  /**
   * <p>Creates HTTP proxy parameters with the specified parameters.</p>
   * <p>The host and port must be specified together.</p>
   * <p>The username and password must also be specified together and must accompany the
   * host and port.</p>
   * <p>The domain and workstation must be specified together and must accompany the
   * username, password, host, and port.</p>
   *
   * @param host                     the proxy host
   * @param port                     the proxy port
   * @param username                 the proxy username
   * @param password                 the proxy password
   * @param domain                   the proxy domain (NTLM authentication only)
   * @param workstation              the proxy workstation (NTLM authentication only)
   * @param preemptiveBasicProxyAuth whether the proxy should preemptively authenticate
   * @param proxyBypassHosts         hosts or domain extensions that should be used to determine if the proxy
   *                                 should be used for a domain
   */
  @SuppressWarnings("PMD.UselessParentheses")
  public HttpProxyParameters(String host, int port, String username,
      String password, String domain, String workstation,
      boolean preemptiveBasicProxyAuth, List<String> proxyBypassHosts) {
    this.host = host;
    this.port = port;

// Path: src/main/java/com/cloudera/director/spi/v2/util/Preconditions.java
// public static void checkArgument(
//     boolean expression, Object message) {
//   if (!expression) {
//     throw new IllegalArgumentException(String.valueOf(message));
//   }
// }
// 
// Path: src/main/java/com/cloudera/director/spi/v2/util/Preconditions.java
// public static <T> T checkNotNull(T instance, String message) {
//   if (instance == null) {
//     throw new NullPointerException(message);
//   }
//   return instance;
// }


// Path: src/main/java/com/cloudera/director/spi/v2/common/http/HttpProxyParameters.java
import static com.cloudera.director.spi.v2.util.Preconditions.checkArgument;
import static com.cloudera.director.spi.v2.util.Preconditions.checkNotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

// (c) Copyright 2015 Cloudera, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.cloudera.director.spi.v2.common.http;



/**
 * Houses and validates HTTP proxy parameters.
 */
public class HttpProxyParameters {

  private final String host;
  private final int port;
  private final String username;
  private final String password;
  private final String domain;
  private final String workstation;
  private final boolean preemptiveBasicProxyAuth;
  private final List<String> proxyBypassHosts;

  /**
   * Constructs HTTP proxy parameters with default configuration.
   */
  public HttpProxyParameters() {
    this(null, -1, null, null, null, null, false, Collections.<String>emptyList());
  }

  /**
   * <p>Creates HTTP proxy parameters with the specified parameters.</p>
   * <p>The host and port must be specified together.</p>
   * <p>The username and password must also be specified together and must accompany the
   * host and port.</p>
   * <p>The domain and workstation must be specified together and must accompany the
   * username, password, host, and port.</p>
   *
   * @param host                     the proxy host
   * @param port                     the proxy port
   * @param username                 the proxy username
   * @param password                 the proxy password
   * @param domain                   the proxy domain (NTLM authentication only)
   * @param workstation              the proxy workstation (NTLM authentication only)
   * @param preemptiveBasicProxyAuth whether the proxy should preemptively authenticate
   * @param proxyBypassHosts         hosts or domain extensions that should be used to determine if the proxy
   *                                 should be used for a domain
   */
  @SuppressWarnings("PMD.UselessParentheses")
  public HttpProxyParameters(String host, int port, String username,
      String password, String domain, String workstation,
      boolean preemptiveBasicProxyAuth, List<String> proxyBypassHosts) {
    this.host = host;
    this.port = port;

    checkArgument((host == null) || (this.port > 0 && this.port < 65536),