/*
 * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
 * (the "License"). You may not use this work except in compliance with the License, which is
 * available at www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied, as more fully set forth in the License.
 *
 * See the NOTICE file distributed with this work for information regarding copyright ownership.
 */

package alluxio.underfs;

import alluxio.Configuration;
import alluxio.PropertyKey;

import java.util.Collections;
import java.util.Map;

/**
 * A class that gets the value of the given key in the given UFS configuration or the global
 * configuration (in case the key is not found in the UFS configuration), throw
 * {@link RuntimeException} if the key is not found in both configurations..
 */
public final class UnderFileSystemConfiguration {
  private final Map<String, String> mUfsConf;

  /**
   * Constructs a new instance of the configuration for a UFS.
   *
   * @param ufsConf the user-specified UFS configuration as a map
   */
  public UnderFileSystemConfiguration(Map<String, String> ufsConf) {
    mUfsConf = ufsConf;
  }

  /**
   * @param key property key
   * @return true if the key is contained in the given UFS configuration or global configuration
   */
  public boolean containsKey(PropertyKey key) {
    return (mUfsConf != null && mUfsConf.containsKey(key.toString())) || Configuration
        .containsKey(key);
  }

  /**
   * @return the map of user-customized configuration
   */
  public Map<String, String> userSpecifiedConf() {
    return Collections.unmodifiableMap(mUfsConf);
  }

  /**
   * Gets the value of the given key in the given UFS configuration or the global configuration
   * (in case the key is not found in the UFS configuration), throw {@link RuntimeException} if the
   * key is not found in both configurations.
   *
   * @param key property key
   * @return the value associated with the given key
   */
  public String getValue(PropertyKey key) {
    if (mUfsConf != null && mUfsConf.containsKey(key.toString())) {
      return mUfsConf.get(key.toString());
    }
    if (Configuration.containsKey(key)) {
      return Configuration.get(key);
    }
    throw new RuntimeException("key " + key + " not found");
  }

  /**
   * Gets the value of the given key in the given UFS configuration or the global configuration
   * (in case the key is not found in the UFS configuration), throw {@link RuntimeException} if the
   * key is not found in both configurations.
   *
   * @param key property key
   * @param ufsConf configuration for the UFS
   * @return the value associated with the given key
   */
  public static String getValue1(PropertyKey key, Map<String, String> ufsConf) {
    if (ufsConf != null && ufsConf.containsKey(key.toString())) {
      return ufsConf.get(key.toString());
    }
    if (Configuration.containsKey(key)) {
      return Configuration.get(key);
    }
    throw new RuntimeException("key " + key + " not found");
  }

  /**
   * @param key property key
   * @param ufsConf configuration for the UFS
   * @return true if the key is contained in the given UFS configuration or global configuration
   */
  public static boolean containsKey1(PropertyKey key, Map<String, String> ufsConf) {
    return (ufsConf != null && ufsConf.containsKey(key.toString())) || Configuration
        .containsKey(key);
  }
}

@@ -1553,180 +1553,8 @@
  %7D%0A%0A
-  /**%0A   * @return the map of user-customized configuration%0A   */%0A  public Map%3CString, String%3E userSpecifiedConf() %7B%0A    return Collections.unmodifiableMap(mUfsConf);%0A  %7D%0A%0A
   /*
@@ -2217,623 +2217,114 @@
   * 
-Gets the value of the given key in the given UFS configuration or the global configuration%0A   * (in case the key is not found in the UFS configuration), throw %7B@link RuntimeException%7D if the%0A   * key is not found in both configurations.%0A   *%0A   * @param key property key%0A   * @param ufsConf configuration for the UFS%0A   * @return the value associated with the given key%0A   */%0A  public static String getValue1(PropertyKey key, Map%3CString, String%3E ufsConf) %7B%0A    if (ufsConf != null && ufsConf.containsKey(key.toString())) %7B%0A      return ufsConf.get(key.toString());%0A    %7D%0A    if (Configuration.containsKey(key)
+@return the map of user-customized configuration%0A   */%0A  public Map%3CString, String%3E userSpecifiedConf(
 ) %7B%0A
-  
     
@@ -2336,480 +2336,42 @@
 n Co
-nfiguration.get(key);%0A    %7D%0A    throw new RuntimeException(%22key %22 + key + %22 not found%22);%0A  %7D%0A%0A  /**%0A   * @param key property key%0A   * @param ufsConf configuration for the UFS%0A   * @return true if the key is contained in the given UFS configuration or global configuration%0A   */%0A  public static boolean containsKey1(PropertyKey key, Map%3CString, String%3E ufsConf) %7B%0A    return (ufsConf != null && ufsConf.containsKey(key.toString())) %7C%7C Configuration%0A        .containsKey(key
+llections.unmodifiableMap(mUfsConf
 );%0A 

Remove unused methods