Skip to content

Commit f287462

Browse files
author
Ajay Kannan
committed
Minor refactoring and javadoc fixes
1 parent 8ad3235 commit f287462

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public final class EntityQuery extends StructuredQuery<Entity> {
3030
private static final long serialVersionUID = 2990565454831019471L;
3131

3232
/**
33-
* A {@code EntityQuery} builder for queries that return Entity results.
33+
* A {@code EntityQuery} builder for queries that return {@link Entity} results.
3434
*/
3535
public static final class Builder extends StructuredQuery.BuilderImpl<Entity, Builder> {
3636

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public final class KeyQuery extends StructuredQuery<Key> {
3030
private static final long serialVersionUID = -746768461459070045L;
3131

3232
/**
33-
* A {@code KeyQuery} builder for queries that return Key results.
33+
* A {@code KeyQuery} builder for queries that return {@link Key} results.
3434
*/
3535
public static final class Builder extends StructuredQuery.BuilderImpl<Key, Builder> {
3636

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public final class ProjectionEntityQuery extends StructuredQuery<ProjectionEntit
2828
private static final long serialVersionUID = 5488451194542425391L;
2929

3030
/**
31-
* A {@code ProjectionEntityQuery} builder for queries that return Key results.
31+
* A {@code ProjectionEntityQuery} builder for queries that return {@link ProjectionEntity}
32+
* results.
3233
*/
3334
public static final class Builder extends StructuredQuery.BuilderImpl<ProjectionEntity, Builder> {
3435

@@ -43,6 +44,7 @@ public static final class Builder extends StructuredQuery.BuilderImpl<Projection
4344
/**
4445
* Clears the projection clause.
4546
*/
47+
@Override
4648
public Builder clearProjection() {
4749
super.clearProjection();
4850
return this;
@@ -51,6 +53,7 @@ public Builder clearProjection() {
5153
/**
5254
* Sets the query's projection clause (clearing any previously specified Projection settings).
5355
*/
56+
@Override
5457
public Builder projection(Projection projection, Projection... others) {
5558
super.projection(projection, others);
5659
return this;
@@ -59,6 +62,7 @@ public Builder projection(Projection projection, Projection... others) {
5962
/**
6063
* Adds one or more projections to the existing projection clause.
6164
*/
65+
@Override
6266
public Builder addProjection(Projection projection, Projection... others) {
6367
super.addProjection(projection, others);
6468
return this;
@@ -67,6 +71,7 @@ public Builder addProjection(Projection projection, Projection... others) {
6771
/**
6872
* Clears the group by clause.
6973
*/
74+
@Override
7075
public Builder clearGroupBy() {
7176
super.clearGroupBy();
7277
return this;
@@ -75,6 +80,7 @@ public Builder clearGroupBy() {
7580
/**
7681
* Sets the query's group by clause (clearing any previously specified GroupBy settings).
7782
*/
83+
@Override
7884
public Builder groupBy(String property, String... others) {
7985
super.groupBy(property, others);
8086
return this;
@@ -83,6 +89,7 @@ public Builder groupBy(String property, String... others) {
8389
/**
8490
* Adds one or more properties to the existing group by clause.
8591
*/
92+
@Override
8693
public Builder addGroupBy(String property, String... others) {
8794
super.addGroupBy(property, others);
8895
return this;

gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/StructuredQueryTest.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,22 +155,11 @@ public void testToAndFromPb() {
155155

156156
@Test
157157
public void testToBuilder() {
158-
StructuredQuery<Entity> entityQuery =
159-
Query.entityQueryBuilder().namespace("n1").kind("k1").build();
160-
Query<Entity> entityQueryResult = entityQuery.toBuilder().build();
161-
StructuredQuery<Key> keyQuery = Query.keyQueryBuilder().namespace("n2").kind("k2").build();
162-
Query<Key> keyQueryResult = keyQuery.toBuilder().build();
163-
StructuredQuery<ProjectionEntity> projectionEntityQuery = Query.projectionEntityQueryBuilder()
164-
.kind("k3")
165-
.projection(Projection.property("p1"), Projection.property("p2"))
166-
.build();
167-
Query<ProjectionEntity> projectionEntityQueryResult = projectionEntityQuery.toBuilder().build();
168-
assertEquals(entityQuery, entityQueryResult);
169-
assertTrue(entityQueryResult instanceof EntityQuery);
170-
assertEquals(keyQuery, keyQueryResult);
171-
assertTrue(keyQueryResult instanceof KeyQuery);
172-
assertEquals(projectionEntityQuery, projectionEntityQueryResult);
173-
assertTrue(projectionEntityQueryResult instanceof ProjectionEntityQuery);
158+
List<StructuredQuery<?>> queries =
159+
ImmutableList.<StructuredQuery<?>>of(ENTITY_QUERY, KEY_QUERY, PROJECTION_QUERY);
160+
for (StructuredQuery<?> query : queries) {
161+
assertEquals(query, query.toBuilder().build());
162+
}
174163
}
175164

176165
@Test

0 commit comments

Comments
 (0)