Skip to content

Commit 15865cc

Browse files
author
Ajay Kannan
committed
Clean up test code and javadoc formatting
1 parent f6cc097 commit 15865cc

File tree

4 files changed

+173
-311
lines changed

4 files changed

+173
-311
lines changed

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreHelper.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,19 @@ static KeyFactory newKeyFactory(DatastoreOptions options) {
5656
}
5757

5858
/**
59-
* Returns a list with a value for each given key (ordered by input).
60-
* {@code null} values are returned for nonexistent keys.
59+
* Returns a list with a value for each given key (ordered by input). {@code null} values are
60+
* returned for nonexistent keys.
6161
*/
6262
static List<Entity> fetch(Transaction reader, Key... keys) {
63-
Iterator<Entity> entities = reader.get(keys);
64-
return compileEntities(keys, entities);
63+
return compileEntities(keys, reader.get(keys));
6564
}
6665

6766
/**
68-
* Returns a list with a value for each given key (ordered by input).
69-
* {@code null} values are returned for nonexistent keys.
67+
* Returns a list with a value for each given key (ordered by input). {@code null} values are
68+
* returned for nonexistent keys.
7069
*/
7170
static List<Entity> fetch(Datastore reader, Key[] keys, ReadOption... options) {
72-
Iterator<Entity> entities;
73-
entities = reader.get(Arrays.asList(keys), options);
74-
return compileEntities(keys, entities);
71+
return compileEntities(keys, reader.get(Arrays.asList(keys), options));
7572
}
7673

7774
private static List<Entity> compileEntities(Key[] keys, Iterator<Entity> entities) {

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreImpl.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,11 @@ public Iterator<Entity> get(Iterable<Key> keys, ReadOption... options) {
210210

211211
private static com.google.datastore.v1beta3.ReadOptions toReadOptionsPb(ReadOption... options) {
212212
com.google.datastore.v1beta3.ReadOptions readOptionsPb = null;
213-
if (options != null) {
214-
Map<Class<? extends ReadOption>, ReadOption> optionsMap = ReadOption.asImmutableMap(options);
215-
EventualConsistency eventualConsistency =
216-
(EventualConsistency) optionsMap.get(EventualConsistency.class);
217-
if (eventualConsistency != null) {
218-
readOptionsPb =
219-
com.google.datastore.v1beta3.ReadOptions.newBuilder()
220-
.setReadConsistency(ReadConsistency.EVENTUAL)
221-
.build();
222-
}
213+
if (options != null
214+
&& ReadOption.asImmutableMap(options).containsKey(EventualConsistency.class)) {
215+
readOptionsPb = com.google.datastore.v1beta3.ReadOptions.newBuilder()
216+
.setReadConsistency(ReadConsistency.EVENTUAL)
217+
.build();
223218
}
224219
return readOptionsPb;
225220
}

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ReadOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public boolean isEventual() {
4747
}
4848
}
4949

50-
ReadOption() {}
50+
private ReadOption() {}
5151

5252
/**
5353
* Returns a {@code ReadOption} that specifies eventual consistency.

0 commit comments

Comments
 (0)