Skip to content

Commit 76e3b3e

Browse files
author
Ajay Kannan
committed
Clean up test code and javadoc formatting
1 parent c95e5e7 commit 76e3b3e

File tree

6 files changed

+190
-330
lines changed

6 files changed

+190
-330
lines changed

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

+10-11
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,27 @@ interface TransactionCallable<T> {
114114
Entity get(Key key, ReadOption... options);
115115

116116
/**
117-
* Returns an {@link Entity} for each given {@link Key} that exists in the Datastore.
118-
* The order of the result is unspecified.
119-
* Results are loaded lazily, so it is possible to get a {@code DatastoreException}
120-
* from the returned {@code Iterator}'s {@link Iterator#hasNext hasNext} or
121-
* {@link Iterator#next next} methods. {@link ReadOption}s can be specified if desired.
117+
* Returns an {@link Entity} for each given {@link Key} that exists in the Datastore. The order of
118+
* the result is unspecified. Results are loaded lazily, so it is possible to get a
119+
* {@code DatastoreException} from the returned {@code Iterator}'s
120+
* {@link Iterator#hasNext hasNext} or {@link Iterator#next next} methods. {@link ReadOption}s can
121+
* be specified if desired.
122122
*
123123
* @throws DatastoreException upon failure
124124
* @see #get(Key)
125125
*/
126126
Iterator<Entity> get(Iterable<Key> keys, ReadOption... options);
127127

128128
/**
129-
* Returns a list with a value for each given key (ordered by input).
130-
* {@code null} values are returned for nonexistent keys.
131-
* When possible prefer using {@link #get(Key...)} to avoid eagerly loading the results.
132-
* {@link ReadOption}s can be specified if desired.
129+
* Returns a list with a value for each given key (ordered by input). {@code null} values are
130+
* returned for nonexistent keys. When possible prefer using {@link #get(Key...)} to avoid eagerly
131+
* loading the results. {@link ReadOption}s can be specified if desired.
133132
*/
134133
List<Entity> fetch(Iterable<Key> keys, ReadOption... options);
135134

136135
/**
137-
* Submits a {@link Query} and returns its result.
138-
* {@link ReadOption}s can be specified if desired.
136+
* Submits a {@link Query} and returns its result. {@link ReadOption}s can be specified if
137+
* desired.
139138
*
140139
* @throws DatastoreException upon failure
141140
*/

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

+6-9
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

+5-10
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/DatastoreReader.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,20 @@ public interface DatastoreReader {
3232
Entity get(Key key);
3333

3434
/**
35-
* Returns an {@link Entity} for each given {@link Key} that exists in the Datastore.
36-
* The order of the result is unspecified.
37-
* Results are loaded lazily, so it is possible to get a {@code DatastoreException}
38-
* from the returned {@code Iterator}'s {@link Iterator#hasNext hasNext} or
39-
* {@link Iterator#next next} methods.
35+
* Returns an {@link Entity} for each given {@link Key} that exists in the Datastore. The order of
36+
* the result is unspecified. Results are loaded lazily, so it is possible to get a
37+
* {@code DatastoreException} from the returned {@code Iterator}'s
38+
* {@link Iterator#hasNext hasNext} or {@link Iterator#next next} methods.
4039
*
4140
* @throws DatastoreException upon failure
4241
* @see #get(Key)
4342
*/
4443
Iterator<Entity> get(Key... key);
4544

4645
/**
47-
* Returns a list with a value for each given key (ordered by input).
48-
* {@code null} values are returned for nonexistent keys.
49-
* When possible prefer using {@link #get(Key...)} to avoid eagerly loading the results.
46+
* Returns a list with a value for each given key (ordered by input). {@code null} values are
47+
* returned for nonexistent keys. When possible prefer using {@link #get(Key...)} to avoid eagerly
48+
* loading the results.
5049
*/
5150
List<Entity> fetch(Key... keys);
5251

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

+1-1
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)