Skip to content

Commit

Permalink
Add getters, remove filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay Kannan committed Oct 20, 2015
1 parent f6eeddd commit 3ccc7ed
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public final class GeoPoint extends Serializable<com.google.type.LatLng> {
this.longitude = longitude;
}

public double getLatitude() {
return latitude;
}

public double getLongitude() {
return longitude;
}

@Override
public String toString() {
return Double.toString(latitude) + ", " + Double.toString(longitude);
Expand All @@ -58,9 +66,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj == this
|| (obj instanceof GeoPoint && new Double(this.latitude).equals(((GeoPoint) obj).latitude))
&& new Double(this.longitude).equals(((GeoPoint) obj).longitude);
return obj == this || (obj instanceof GeoPoint && this.latitude == ((GeoPoint) obj).latitude
&& this.longitude == ((GeoPoint) obj).longitude);
}

public static GeoPoint of(double latitude, double longitude) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,6 @@ public Builder<V> setBinding(String name, DateTime... value) {
namedBindings.put(name, toBinding(DateTimeValue.MARSHALLER, Arrays.asList(value)));
return this;
}

public Builder<V> setBinding(String name, GeoPoint... value) {
namedBindings.put(name, toBinding(GeoPointValue.MARSHALLER, Arrays.asList(value)));
return this;
}

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

public Builder<V> addBinding(GeoPoint... value) {
positionalBindings.add(toBinding(GeoPointValue.MARSHALLER, Arrays.asList(value)));
return this;
}

public Builder<V> addBinding(Key... value) {
positionalBindings.add(toBinding(KeyValue.MARSHALLER, Arrays.asList(value)));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static com.google.gcloud.datastore.BooleanValue.of;
import static com.google.gcloud.datastore.DateTimeValue.of;
import static com.google.gcloud.datastore.DoubleValue.of;
import static com.google.gcloud.datastore.GeoPointValue.of;
import static com.google.gcloud.datastore.KeyValue.of;
import static com.google.gcloud.datastore.LongValue.of;
import static com.google.gcloud.datastore.StringValue.of;
Expand Down Expand Up @@ -421,10 +420,6 @@ public static PropertyFilter eq(String property, DateTime value) {
return new PropertyFilter(property, Operator.EQUAL, of(value));
}

public static PropertyFilter eq(String property, GeoPoint value) {
return new PropertyFilter(property, Operator.EQUAL, of(value));
}

public static PropertyFilter eq(String property, Key value) {
return new PropertyFilter(property, Operator.EQUAL, of(value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class BaseEntityTest {

private static final Blob BLOB = Blob.copyFrom(new byte[]{1, 2});
private static final DateTime DATE_TIME = DateTime.now();
private static final GeoPoint GEO_POINT = new GeoPoint(30.5, -40.5);
private static final GeoPoint GEO_POINT = new GeoPoint(37.422035, -122.084124);
private static final Key KEY = Key.builder("ds1", "k1", "n1").build();
private static final Entity ENTITY = Entity.builder(KEY).set("name", "foo").build();
private static final IncompleteKey INCOMPLETE_KEY = IncompleteKey.builder("ds1", "k1").build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public class DatastoreTest {
.build();
private static final ListValue LIST_VALUE2 = ListValue.of(Collections.singletonList(KEY_VALUE));
private static final DateTimeValue DATE_TIME_VALUE = new DateTimeValue(DateTime.now());
private static final GeoPointValue GEO_POINT_VALUE = new GeoPointValue(new GeoPoint(30.5, 40.5));
private static final GeoPointValue GEO_POINT_VALUE =
new GeoPointValue(new GeoPoint(37.422035, -122.084124));
private static final FullEntity<IncompleteKey> PARTIAL_ENTITY1 =
FullEntity.builder(INCOMPLETE_KEY2).set("str", STR_VALUE).set("bool", BOOL_VALUE)
.set("list", LIST_VALUE1).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public class GeoPointTest {
@Rule
public ExpectedException thrown = ExpectedException.none();

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

private static final String INVALID_LAT_MESSAGE =
"latitude must be in the range [-90, 90] degrees";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class SerializationTest {
IncompleteKey.builder(KEY1, "v").ancestors(PathElement.of("p", 1)).build();
private static final Key KEY2 = Key.builder(KEY1, "v", 2).build();
private static final DateTime DATE_TIME1 = DateTime.now();
private static final GeoPoint GEO_POINT = new GeoPoint(30.5, 40.5);
private static final GeoPoint GEO_POINT = new GeoPoint(37.422035, -122.084124);
private static final Blob BLOB1 = Blob.copyFrom(UTF_8.encode("hello world"));
private static final Cursor CURSOR1 = Cursor.copyFrom(new byte[] {1,2});
private static final Cursor CURSOR2 = Cursor.copyFrom(new byte[]{10});
Expand Down

0 comments on commit 3ccc7ed

Please sign in to comment.