@Test public void testCreate() { URI datasetUri = new URIBuilder(repoUri, "ns", "test").build(); DatasetDescriptor descriptor = new DatasetDescriptor.Builder() .schemaLiteral("\"string\"") .build(); Dataset<Object> expected = mock(Dataset.class); when(repo.create("ns", "test", descriptor, Object.class)).thenReturn(expected); Dataset<Object> ds = Datasets.<Object, Dataset<Object>> create(datasetUri, descriptor, Object.class); verify(repo).create("ns", "test", descriptor, Object.class); verifyNoMoreInteractions(repo); verifyNoMoreInteractions(expected); Assert.assertEquals(expected, ds); }
@SuppressWarnings("unchecked") public static <E, V extends View<E>> V create(URI uri, DatasetDescriptor descriptor, Class<E> type) { boolean isView = URIBuilder.VIEW_SCHEME.equals(uri.getScheme()); Preconditions.checkArgument(isView || URIBuilder.DATASET_SCHEME.equals(uri.getScheme()), "Not a dataset or view URI: " + uri); Preconditions.checkNotNull(type, "The entity type can't be null, use Object.class to have the type" + " determined by the schema."); Pair<DatasetRepository, Map<String, String>> pair = Registration.lookupDatasetUri(URI.create(uri.getRawSchemeSpecificPart())); DatasetRepository repo = pair.first(); Map<String, String> uriOptions = pair.second(); if (descriptor.getLocation() == null && uriOptions.containsKey("location")) { descriptor = new DatasetDescriptor.Builder(descriptor) .location(uriOptions.get("location")) .build(); } Dataset<E> dataset = repo.create( uriOptions.get(URIBuilder.NAMESPACE_OPTION), uriOptions.get(URIBuilder.DATASET_NAME_OPTION), descriptor, type); if (isView) { return Datasets.<E, V> view(dataset, uriOptions); } else { return (V) dataset; } }
Datasets { @SuppressWarnings("unchecked") public static <E, V extends View<E>> V create(URI uri, DatasetDescriptor descriptor, Class<E> type) { boolean isView = URIBuilder.VIEW_SCHEME.equals(uri.getScheme()); Preconditions.checkArgument(isView || URIBuilder.DATASET_SCHEME.equals(uri.getScheme()), "Not a dataset or view URI: " + uri); Preconditions.checkNotNull(type, "The entity type can't be null, use Object.class to have the type" + " determined by the schema."); Pair<DatasetRepository, Map<String, String>> pair = Registration.lookupDatasetUri(URI.create(uri.getRawSchemeSpecificPart())); DatasetRepository repo = pair.first(); Map<String, String> uriOptions = pair.second(); if (descriptor.getLocation() == null && uriOptions.containsKey("location")) { descriptor = new DatasetDescriptor.Builder(descriptor) .location(uriOptions.get("location")) .build(); } Dataset<E> dataset = repo.create( uriOptions.get(URIBuilder.NAMESPACE_OPTION), uriOptions.get(URIBuilder.DATASET_NAME_OPTION), descriptor, type); if (isView) { return Datasets.<E, V> view(dataset, uriOptions); } else { return (V) dataset; } } }
Datasets { @SuppressWarnings("unchecked") public static <E, V extends View<E>> V create(URI uri, DatasetDescriptor descriptor, Class<E> type) { boolean isView = URIBuilder.VIEW_SCHEME.equals(uri.getScheme()); Preconditions.checkArgument(isView || URIBuilder.DATASET_SCHEME.equals(uri.getScheme()), "Not a dataset or view URI: " + uri); Preconditions.checkNotNull(type, "The entity type can't be null, use Object.class to have the type" + " determined by the schema."); Pair<DatasetRepository, Map<String, String>> pair = Registration.lookupDatasetUri(URI.create(uri.getRawSchemeSpecificPart())); DatasetRepository repo = pair.first(); Map<String, String> uriOptions = pair.second(); if (descriptor.getLocation() == null && uriOptions.containsKey("location")) { descriptor = new DatasetDescriptor.Builder(descriptor) .location(uriOptions.get("location")) .build(); } Dataset<E> dataset = repo.create( uriOptions.get(URIBuilder.NAMESPACE_OPTION), uriOptions.get(URIBuilder.DATASET_NAME_OPTION), descriptor, type); if (isView) { return Datasets.<E, V> view(dataset, uriOptions); } else { return (V) dataset; } }  }
Datasets { @SuppressWarnings("unchecked") public static <E, V extends View<E>> V create(URI uri, DatasetDescriptor descriptor, Class<E> type) { boolean isView = URIBuilder.VIEW_SCHEME.equals(uri.getScheme()); Preconditions.checkArgument(isView || URIBuilder.DATASET_SCHEME.equals(uri.getScheme()), "Not a dataset or view URI: " + uri); Preconditions.checkNotNull(type, "The entity type can't be null, use Object.class to have the type" + " determined by the schema."); Pair<DatasetRepository, Map<String, String>> pair = Registration.lookupDatasetUri(URI.create(uri.getRawSchemeSpecificPart())); DatasetRepository repo = pair.first(); Map<String, String> uriOptions = pair.second(); if (descriptor.getLocation() == null && uriOptions.containsKey("location")) { descriptor = new DatasetDescriptor.Builder(descriptor) .location(uriOptions.get("location")) .build(); } Dataset<E> dataset = repo.create( uriOptions.get(URIBuilder.NAMESPACE_OPTION), uriOptions.get(URIBuilder.DATASET_NAME_OPTION), descriptor, type); if (isView) { return Datasets.<E, V> view(dataset, uriOptions); } else { return (V) dataset; } }  @SuppressWarnings("unchecked") static V load(URI uri, Class<E> type); @SuppressWarnings("unchecked") static V load(URI uri); static V load(String uriString, Class<E> type); static V load(String uriString); @SuppressWarnings("unchecked") static V create(URI uri, DatasetDescriptor descriptor, Class<E> type); @SuppressWarnings("unchecked") static V create(URI uri, DatasetDescriptor descriptor); static V create(String uri, DatasetDescriptor descriptor, Class<E> type); @SuppressWarnings("unchecked") static V create(String uri, DatasetDescriptor descriptor); @SuppressWarnings("unchecked") static D update(
      URI uri, DatasetDescriptor descriptor, Class<E> type); @SuppressWarnings("unchecked") static D update(
      URI uri, DatasetDescriptor descriptor); static D update(String uri, DatasetDescriptor descriptor, Class<E> type); static D update(String uri, DatasetDescriptor descriptor); static boolean delete(URI uri); static boolean delete(String uri); static boolean moveToTrash(URI uri); static boolean moveToTrash(String uri); static boolean exists(URI uri); static boolean exists(String uri); static Collection<URI> list(URI uri); static Collection<URI> list(String uri); }
Datasets { @SuppressWarnings("unchecked") public static <E, V extends View<E>> V create(URI uri, DatasetDescriptor descriptor, Class<E> type) { boolean isView = URIBuilder.VIEW_SCHEME.equals(uri.getScheme()); Preconditions.checkArgument(isView || URIBuilder.DATASET_SCHEME.equals(uri.getScheme()), "Not a dataset or view URI: " + uri); Preconditions.checkNotNull(type, "The entity type can't be null, use Object.class to have the type" + " determined by the schema."); Pair<DatasetRepository, Map<String, String>> pair = Registration.lookupDatasetUri(URI.create(uri.getRawSchemeSpecificPart())); DatasetRepository repo = pair.first(); Map<String, String> uriOptions = pair.second(); if (descriptor.getLocation() == null && uriOptions.containsKey("location")) { descriptor = new DatasetDescriptor.Builder(descriptor) .location(uriOptions.get("location")) .build(); } Dataset<E> dataset = repo.create( uriOptions.get(URIBuilder.NAMESPACE_OPTION), uriOptions.get(URIBuilder.DATASET_NAME_OPTION), descriptor, type); if (isView) { return Datasets.<E, V> view(dataset, uriOptions); } else { return (V) dataset; } }  @SuppressWarnings("unchecked") static V load(URI uri, Class<E> type); @SuppressWarnings("unchecked") static V load(URI uri); static V load(String uriString, Class<E> type); static V load(String uriString); @SuppressWarnings("unchecked") static V create(URI uri, DatasetDescriptor descriptor, Class<E> type); @SuppressWarnings("unchecked") static V create(URI uri, DatasetDescriptor descriptor); static V create(String uri, DatasetDescriptor descriptor, Class<E> type); @SuppressWarnings("unchecked") static V create(String uri, DatasetDescriptor descriptor); @SuppressWarnings("unchecked") static D update(
      URI uri, DatasetDescriptor descriptor, Class<E> type); @SuppressWarnings("unchecked") static D update(
      URI uri, DatasetDescriptor descriptor); static D update(String uri, DatasetDescriptor descriptor, Class<E> type); static D update(String uri, DatasetDescriptor descriptor); static boolean delete(URI uri); static boolean delete(String uri); static boolean moveToTrash(URI uri); static boolean moveToTrash(String uri); static boolean exists(URI uri); static boolean exists(String uri); static Collection<URI> list(URI uri); static Collection<URI> list(String uri);  }