public static String mapIfMapAvailable(String s, Function<String, String> mapping){
    try {
      if (mapping != null){
        return mapping.apply(s);
      }
    } catch (IllegalArgumentException iae){
      // The key wasn't present in the mapping, and the function didn't
      // return a default value - ignore, and use our default.
    }
    // We return the key itself, since no mapping was available/returned
    return s;
  }
Return a mapping from a given map function if available, and the key itself if not.
hcatalog/webhcat/java-client/src/main/java/org/apache/hive/hcatalog/api/repl/ReplicationUtils.java