code: @SuppressWarnings("unchecked")
    public static <R extends DatasetRepository> R repositoryFor(URI uri) {
      boolean isRepoUri = URIBuilder.REPO_SCHEME.equals(uri.getScheme());
      Preconditions.checkArgument(isRepoUri ||
          URIBuilder.DATASET_SCHEME.equals(uri.getScheme()) ||
          URIBuilder.VIEW_SCHEME.equals(uri.getScheme()),
          "Not a repository, dataset, or view URI: " + uri);
  
      Pair<DatasetRepository, Map<String, String>> pair; 
      if (URIBuilder.REPO_SCHEME.equals(uri.getScheme())) {
        pair = Registration.lookupRepoUri(
            URI.create(uri.getRawSchemeSpecificPart()));
      } else {
        pair = Registration.lookupDatasetUri(
            URI.create(uri.getRawSchemeSpecificPart()));
      }
  
      return (R) pair.first();
    }
docs: Load a {@link DatasetRepository} for the given dataset, view or repository URI.
  <p>
  URI formats are defined by {@code Dataset} implementations, but must begin
  with "dataset:" or "view:".
  
  @param uri a {@code Dataset} or {@code View} URI.
  @param <R> The type of {@code DatasetRepository} expected.
  @return a {@code DatasetRepository} responsible for the given URI.