Skip to content

Commit 3e51672

Browse files
author
Ajay Kannan
committed
Add getters and standardize test location
1 parent f6eeddd commit 3e51672

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public final class GeoPoint extends Serializable<com.google.type.LatLng> {
4646
this.longitude = longitude;
4747
}
4848

49+
public double getLatitude() {
50+
return latitude;
51+
}
52+
53+
public double getLongitude() {
54+
return longitude;
55+
}
56+
4957
@Override
5058
public String toString() {
5159
return Double.toString(latitude) + ", " + Double.toString(longitude);
@@ -58,9 +66,8 @@ public int hashCode() {
5866

5967
@Override
6068
public boolean equals(Object obj) {
61-
return obj == this
62-
|| (obj instanceof GeoPoint && new Double(this.latitude).equals(((GeoPoint) obj).latitude))
63-
&& new Double(this.longitude).equals(((GeoPoint) obj).longitude);
69+
return obj == this || (obj instanceof GeoPoint && this.latitude == ((GeoPoint) obj).latitude
70+
&& this.longitude == ((GeoPoint) obj).longitude);
6471
}
6572

6673
public static GeoPoint of(double latitude, double longitude) {

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

-10
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,6 @@ public Builder<V> setBinding(String name, DateTime... value) {
212212
namedBindings.put(name, toBinding(DateTimeValue.MARSHALLER, Arrays.asList(value)));
213213
return this;
214214
}
215-
216-
public Builder<V> setBinding(String name, GeoPoint... value) {
217-
namedBindings.put(name, toBinding(GeoPointValue.MARSHALLER, Arrays.asList(value)));
218-
return this;
219-
}
220215

221216
public Builder<V> setBinding(String name, Key... value) {
222217
namedBindings.put(name, toBinding(KeyValue.MARSHALLER, Arrays.asList(value)));
@@ -263,11 +258,6 @@ public Builder<V> addBinding(DateTime... value) {
263258
return this;
264259
}
265260

266-
public Builder<V> addBinding(GeoPoint... value) {
267-
positionalBindings.add(toBinding(GeoPointValue.MARSHALLER, Arrays.asList(value)));
268-
return this;
269-
}
270-
271261
public Builder<V> addBinding(Key... value) {
272262
positionalBindings.add(toBinding(KeyValue.MARSHALLER, Arrays.asList(value)));
273263
return this;

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

-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static com.google.gcloud.datastore.BooleanValue.of;
2222
import static com.google.gcloud.datastore.DateTimeValue.of;
2323
import static com.google.gcloud.datastore.DoubleValue.of;
24-
import static com.google.gcloud.datastore.GeoPointValue.of;
2524
import static com.google.gcloud.datastore.KeyValue.of;
2625
import static com.google.gcloud.datastore.LongValue.of;
2726
import static com.google.gcloud.datastore.StringValue.of;
@@ -421,10 +420,6 @@ public static PropertyFilter eq(String property, DateTime value) {
421420
return new PropertyFilter(property, Operator.EQUAL, of(value));
422421
}
423422

424-
public static PropertyFilter eq(String property, GeoPoint value) {
425-
return new PropertyFilter(property, Operator.EQUAL, of(value));
426-
}
427-
428423
public static PropertyFilter eq(String property, Key value) {
429424
return new PropertyFilter(property, Operator.EQUAL, of(value));
430425
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class BaseEntityTest {
3535

3636
private static final Blob BLOB = Blob.copyFrom(new byte[]{1, 2});
3737
private static final DateTime DATE_TIME = DateTime.now();
38-
private static final GeoPoint GEO_POINT = new GeoPoint(30.5, -40.5);
38+
private static final GeoPoint GEO_POINT = new GeoPoint(37.422035, -122.084124);
3939
private static final Key KEY = Key.builder("ds1", "k1", "n1").build();
4040
private static final Entity ENTITY = Entity.builder(KEY).set("name", "foo").build();
4141
private static final IncompleteKey INCOMPLETE_KEY = IncompleteKey.builder("ds1", "k1").build();

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public class DatastoreTest {
7474
.build();
7575
private static final ListValue LIST_VALUE2 = ListValue.of(Collections.singletonList(KEY_VALUE));
7676
private static final DateTimeValue DATE_TIME_VALUE = new DateTimeValue(DateTime.now());
77-
private static final GeoPointValue GEO_POINT_VALUE = new GeoPointValue(new GeoPoint(30.5, 40.5));
77+
private static final GeoPoint GEO_POINT = new GeoPoint(37.422035, -122.084124);
78+
private static final GeoPointValue GEO_POINT_VALUE = new GeoPointValue(GEO_POINT);
7879
private static final FullEntity<IncompleteKey> PARTIAL_ENTITY1 =
7980
FullEntity.builder(INCOMPLETE_KEY2).set("str", STR_VALUE).set("bool", BOOL_VALUE)
8081
.set("list", LIST_VALUE1).build();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public class GeoPointTest {
2828
@Rule
2929
public ExpectedException thrown = ExpectedException.none();
3030

31-
private static GeoPoint gp1 = new GeoPoint(10.5, 20.5);
32-
private static GeoPoint gp2 = new GeoPoint(10.5, 30.5);
31+
private static GeoPoint gp1 = new GeoPoint(37.422035, -122.084124);
32+
private static GeoPoint gp2 = new GeoPoint(0.0, 0.0);
3333

3434
private static final String INVALID_LAT_MESSAGE =
3535
"latitude must be in the range [-90, 90] degrees";

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class SerializationTest {
4545
IncompleteKey.builder(KEY1, "v").ancestors(PathElement.of("p", 1)).build();
4646
private static final Key KEY2 = Key.builder(KEY1, "v", 2).build();
4747
private static final DateTime DATE_TIME1 = DateTime.now();
48-
private static final GeoPoint GEO_POINT = new GeoPoint(30.5, 40.5);
48+
private static final GeoPoint GEO_POINT = new GeoPoint(37.422035, -122.084124);
4949
private static final Blob BLOB1 = Blob.copyFrom(UTF_8.encode("hello world"));
5050
private static final Cursor CURSOR1 = Cursor.copyFrom(new byte[] {1,2});
5151
private static final Cursor CURSOR2 = Cursor.copyFrom(new byte[]{10});

0 commit comments

Comments
 (0)