class MoreMapUtils {

  public static URI getUri(Map<?, ?> map, Object key, URI defaultValue) {
    Object uri = map.get(key);
    if (uri == null) {
      return defaultValue;
    }
    if (uri instanceof URI) {
      return (URI) uri;
    }
    if (uri instanceof String) {
      try {
        return URI.create(((String) uri).trim());
      } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException("Object '" + key + "' is not a valid URI: " + uri, e);
      }
    }
    throw new IllegalArgumentException(
        "Object '" + key + "' must be a String or a URI. Got " + uri.getClass().getName());
  }

  private  MoreMapUtils();

}