Skip to content

Commit

Permalink
Deprecate namespace setter, undo deprecating getGeneratedKeys (#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard authored Nov 1, 2016
1 parent e7063d4 commit a963ef4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ public DatastoreOptions build() {
/**
* Sets the default namespace to be used by the datastore service.
*/
@Deprecated
public Builder namespace(String namespace) {
return setNamespace(namespace);
}

/**
* Sets the default namespace to be used by the datastore service.
*/
public Builder setNamespace(String namespace) {
this.namespace = validateNamespace(namespace);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ interface Response {
/**
* Returns a list of keys generated by a transaction.
*/
@Deprecated
List<Key> getGeneratedKeys();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,15 +667,15 @@ public DatastoreOptions getOptions() {
*/
@Deprecated
public DatastoreOptions options(String namespace) {
return optionsBuilder().namespace(namespace).build();
return optionsBuilder().setNamespace(namespace).build();
}

/**
* Returns a {@link DatastoreOptions} instance that sets the host to use the Datastore emulator on
* localhost. The default namespace is set to {@code namespace}.
*/
public DatastoreOptions getOptions(String namespace) {
return optionsBuilder().namespace(namespace).build();
return optionsBuilder().setNamespace(namespace).build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void deleteNamespace() {
*/
public static RemoteDatastoreHelper create() {
DatastoreOptions datastoreOption = DatastoreOptions.newBuilder()
.namespace(UUID.randomUUID().toString())
.setNamespace(UUID.randomUUID().toString())
.setRetryParams(retryParams())
.setConnectTimeout(60000)
.setReadTimeout(60000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void testHost() throws Exception {
@Test
public void testNamespace() throws Exception {
assertTrue(options.build().getNamespace().isEmpty());
assertEquals("ns1", options.namespace("ns1").build().getNamespace());
assertEquals("ns1", options.setNamespace("ns1").build().getNamespace());
}

@Test
Expand All @@ -72,7 +72,7 @@ public void testDatastore() throws Exception {

@Test
public void testToBuilder() throws Exception {
DatastoreOptions original = options.namespace("ns1").build();
DatastoreOptions original = options.setNamespace("ns1").build();
DatastoreOptions copy = original.toBuilder().build();
assertEquals(original.getProjectId(), copy.getProjectId());
assertEquals(original.getNamespace(), copy.getNamespace());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected java.io.Serializable[] serializableObjects() {
.setProjectId("ds1")
.build();
DatastoreOptions otherOptions = options.toBuilder()
.namespace("ns1")
.setNamespace("ns1")
.setAuthCredentials(null)
.build();
return new java.io.Serializable[]{KEY1, KEY2, INCOMPLETE_KEY1, INCOMPLETE_KEY2, ENTITY1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public static void main(String... args) throws Exception {
// .setHost("http://localhost:8080")
// .build();
DatastoreOptions options =
DatastoreOptions.newBuilder().setProjectId(projectId).namespace(NAMESPACE).build();
DatastoreOptions.newBuilder().setProjectId(projectId).setNamespace(NAMESPACE).build();
String name = args.length > 1 ? args[1] : System.getProperty("user.getName");
Datastore datastore = options.getService();
KeyFactory keyFactory = datastore.newKeyFactory().setKind(USER_KIND);
Expand Down

0 comments on commit a963ef4

Please sign in to comment.