Skip to content

Commit 241960f

Browse files
author
Ajay Kannan
committed
rename geopoint to latlng
1 parent d75b0da commit 241960f

File tree

10 files changed

+84
-82
lines changed

10 files changed

+84
-82
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import static com.google.gcloud.datastore.DateTimeValue.of;
2222
import static com.google.gcloud.datastore.DoubleValue.of;
2323
import static com.google.gcloud.datastore.EntityValue.of;
24-
import static com.google.gcloud.datastore.GeoPointValue.of;
24+
import static com.google.gcloud.datastore.LatLngValue.of;
2525
import static com.google.gcloud.datastore.KeyValue.of;
2626
import static com.google.gcloud.datastore.ListValue.of;
2727
import static com.google.gcloud.datastore.LongValue.of;
@@ -160,7 +160,7 @@ public B set(String name, DateTime value) {
160160
return self();
161161
}
162162

163-
public B set(String name, GeoPoint value) {
163+
public B set(String name, LatLng value) {
164164
properties.put(name, of(value));
165165
return self();
166166
}
@@ -327,14 +327,14 @@ public DateTime getDateTime(String name) {
327327
}
328328

329329
/**
330-
* Returns the property value as a GeoPoint.
330+
* Returns the property value as a LatLng.
331331
*
332332
* @throws DatastoreException if not such property.
333-
* @throws ClassCastException if value is not a GeoPoint.
333+
* @throws ClassCastException if value is not a LatLng.
334334
*/
335335
@SuppressWarnings("unchecked")
336-
public GeoPoint getGeoPoint(String name) {
337-
return ((Value<GeoPoint>) getValue(name)).get();
336+
public LatLng getLatLng(String name) {
337+
return ((Value<LatLng>) getValue(name)).get();
338338
}
339339

340340
/**

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/GeoPoint.java renamed to gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/LatLng.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323
import java.util.Objects;
2424

2525
/**
26-
* A Google Cloud Datastore GeoPoint (represented by latitude and longitude in degrees).
26+
* A Google Cloud Datastore LatLng (represented by latitude and longitude in degrees).
2727
* This class is immutable.
2828
*
2929
* @see <a href="https://cloud.google.com/datastore/docs/concepts/entities">Google Cloud Datastore
3030
* Entities, Properties, and Keys</a>
3131
*/
32-
public final class GeoPoint extends Serializable<com.google.type.LatLng> {
32+
public final class LatLng extends Serializable<com.google.type.LatLng> {
3333

3434
private static final long serialVersionUID = 9077060962655752073L;
3535

3636
private final transient double latitude;
3737
private final transient double longitude;
3838

39-
GeoPoint(double latitude, double longitude) {
39+
LatLng(double latitude, double longitude) {
4040
checkArgument(
4141
latitude >= -90.0 && latitude <= 90.0, "latitude must be in the range [-90, 90] degrees");
4242
checkArgument(
@@ -66,12 +66,12 @@ public int hashCode() {
6666

6767
@Override
6868
public boolean equals(Object obj) {
69-
return obj == this || (obj instanceof GeoPoint && this.latitude == ((GeoPoint) obj).latitude
70-
&& this.longitude == ((GeoPoint) obj).longitude);
69+
return obj == this || (obj instanceof LatLng && this.latitude == ((LatLng) obj).latitude
70+
&& this.longitude == ((LatLng) obj).longitude);
7171
}
7272

73-
public static GeoPoint of(double latitude, double longitude) {
74-
return new GeoPoint(latitude, longitude);
73+
public static LatLng of(double latitude, double longitude) {
74+
return new LatLng(latitude, longitude);
7575
}
7676

7777
@Override
@@ -85,6 +85,6 @@ protected com.google.type.LatLng toPb() {
8585
@Override
8686
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
8787
com.google.type.LatLng parsedLatLng = com.google.type.LatLng.parseFrom(bytesPb);
88-
return new GeoPoint(parsedLatLng.getLatitude(), parsedLatLng.getLongitude());
88+
return new LatLng(parsedLatLng.getLatitude(), parsedLatLng.getLongitude());
8989
}
9090
}

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/GeoPointValue.java renamed to gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/LatLngValue.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import static com.google.datastore.v1beta3.Value.GEO_POINT_VALUE_FIELD_NUMBER;
2020

21-
public final class GeoPointValue extends Value<GeoPoint> {
21+
public final class LatLngValue extends Value<LatLng> {
2222

2323
private static final long serialVersionUID = -5810614280642405898L;
2424

25-
static final BaseMarshaller<GeoPoint, GeoPointValue, Builder> MARSHALLER =
26-
new BaseMarshaller<GeoPoint, GeoPointValue, Builder>() {
25+
static final BaseMarshaller<LatLng, LatLngValue, Builder> MARSHALLER =
26+
new BaseMarshaller<LatLng, LatLngValue, Builder>() {
2727

2828
private static final long serialVersionUID = -3550567536035178649L;
2929

@@ -33,39 +33,39 @@ public int getProtoFieldId() {
3333
}
3434

3535
@Override
36-
public Builder newBuilder(GeoPoint value) {
36+
public Builder newBuilder(LatLng value) {
3737
return builder(value);
3838
}
3939

4040
@Override
41-
protected GeoPoint getValue(com.google.datastore.v1beta3.Value from) {
42-
return new GeoPoint(
41+
protected LatLng getValue(com.google.datastore.v1beta3.Value from) {
42+
return new LatLng(
4343
from.getGeoPointValue().getLatitude(), from.getGeoPointValue().getLongitude());
4444
}
4545

4646
@Override
47-
protected void setValue(GeoPointValue from, com.google.datastore.v1beta3.Value.Builder to) {
47+
protected void setValue(LatLngValue from, com.google.datastore.v1beta3.Value.Builder to) {
4848
to.setGeoPointValue(from.get().toPb());
4949
}
5050
};
5151

52-
public static final class Builder extends Value.BaseBuilder<GeoPoint, GeoPointValue, Builder> {
52+
public static final class Builder extends Value.BaseBuilder<LatLng, LatLngValue, Builder> {
5353

5454
private Builder() {
55-
super(ValueType.GEO_POINT);
55+
super(ValueType.LAT_LNG);
5656
}
5757

5858
@Override
59-
public GeoPointValue build() {
60-
return new GeoPointValue(this);
59+
public LatLngValue build() {
60+
return new LatLngValue(this);
6161
}
6262
}
6363

64-
public GeoPointValue(GeoPoint value) {
64+
public LatLngValue(LatLng value) {
6565
this(builder(value));
6666
}
6767

68-
private GeoPointValue(Builder builder) {
68+
private LatLngValue(Builder builder) {
6969
super(builder);
7070
}
7171

@@ -74,11 +74,11 @@ public Builder toBuilder() {
7474
return new Builder().mergeFrom(this);
7575
}
7676

77-
public static GeoPointValue of(GeoPoint value) {
78-
return new GeoPointValue(value);
77+
public static LatLngValue of(LatLng value) {
78+
return new LatLngValue(value);
7979
}
8080

81-
public static Builder builder(GeoPoint value) {
81+
public static Builder builder(LatLng value) {
8282
return new Builder().set(value);
8383
}
8484
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public enum ValueType {
8181
RAW_VALUE(RawValue.MARSHALLER),
8282

8383
/**
84-
* Represents a {@link GeoPoint} value
84+
* Represents a {@link LatLng} value
8585
*/
86-
GEO_POINT(GeoPointValue.MARSHALLER);
86+
LAT_LNG(LatLngValue.MARSHALLER);
8787

8888
private static final ImmutableMap<Integer, ValueType> DESCRIPTOR_TO_TYPE_MAP;
8989

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

+7-7
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(37.422035, -122.084124);
38+
private static final LatLng LAT_LNG = new LatLng(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();
@@ -63,9 +63,9 @@ public void setUp() {
6363
builder = new Builder();
6464
builder.set("blob", BLOB).set("boolean", true).set("dateTime", DATE_TIME);
6565
builder.set("double", 1.25).set("key", KEY).set("string", "hello world");
66-
builder.set("long", 125).setNull("null").set("entity", ENTITY).set("geoPoint", GEO_POINT);
66+
builder.set("long", 125).setNull("null").set("entity", ENTITY).set("latLng", LAT_LNG);
6767
builder.set("partialEntity", PARTIAL_ENTITY).set("stringValue", StringValue.of("bla"));
68-
builder.set("list1", NullValue.of(), StringValue.of("foo"), GeoPointValue.of(GEO_POINT));
68+
builder.set("list1", NullValue.of(), StringValue.of("foo"), LatLngValue.of(LAT_LNG));
6969
builder.set("list2", ImmutableList.of(LongValue.of(10), DoubleValue.of(2)));
7070
builder.set("list3", Collections.singletonList(BooleanValue.of(true)));
7171
}
@@ -151,9 +151,9 @@ public void testGetDateTime() throws Exception {
151151
}
152152

153153
@Test
154-
public void testGetGeoPoint() throws Exception {
154+
public void testGetLatLng() throws Exception {
155155
BaseEntity<Key> entity = builder.build();
156-
assertEquals(GEO_POINT, entity.getGeoPoint("geoPoint"));
156+
assertEquals(LAT_LNG, entity.getLatLng("latLng"));
157157
}
158158

159159
@Test
@@ -181,7 +181,7 @@ public void testGetList() throws Exception {
181181
assertEquals(3, list.size());
182182
assertEquals(NullValue.of(), list.get(0));
183183
assertEquals("foo", list.get(1).get());
184-
assertEquals(GEO_POINT, list.get(2).get());
184+
assertEquals(LAT_LNG, list.get(2).get());
185185
list = entity.getList("list2");
186186
assertEquals(2, list.size());
187187
assertEquals(Long.valueOf(10), list.get(0).get());
@@ -207,7 +207,7 @@ public void testNames() throws Exception {
207207
Set<String> names =
208208
ImmutableSet.<String>builder()
209209
.add("string", "stringValue", "boolean", "double", "long", "list1", "list2", "list3")
210-
.add("entity", "partialEntity", "null", "dateTime", "geoPoint", "blob", "key")
210+
.add("entity", "partialEntity", "null", "dateTime", "latLng", "blob", "key")
211211
.build();
212212
BaseEntity<Key> entity = builder.build();
213213
assertEquals(names, entity.names());

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,8 +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 =
78-
new GeoPointValue(new GeoPoint(37.422035, -122.084124));
77+
private static final LatLngValue LAT_LNG_VALUE =
78+
new LatLngValue(new LatLng(37.422035, -122.084124));
7979
private static final FullEntity<IncompleteKey> PARTIAL_ENTITY1 =
8080
FullEntity.builder(INCOMPLETE_KEY2).set("str", STR_VALUE).set("bool", BOOL_VALUE)
8181
.set("list", LIST_VALUE1).build();
@@ -89,7 +89,7 @@ public class DatastoreTest {
8989
Entity.builder(KEY1)
9090
.set("str", STR_VALUE)
9191
.set("date", DATE_TIME_VALUE)
92-
.set("geoPoint", GEO_POINT_VALUE)
92+
.set("latLng", LAT_LNG_VALUE)
9393
.set("bool", BOOL_VALUE)
9494
.set("partial1", EntityValue.of(PARTIAL_ENTITY1))
9595
.set("list", LIST_VALUE2)
@@ -508,8 +508,8 @@ public void testGet() {
508508
assertEquals(LIST_VALUE2, value3);
509509
DateTimeValue value4 = entity.getValue("date");
510510
assertEquals(DATE_TIME_VALUE, value4);
511-
GeoPointValue value5 = entity.getValue("geoPoint");
512-
assertEquals(GEO_POINT_VALUE, value5);
511+
LatLngValue value5 = entity.getValue("latLng");
512+
assertEquals(LAT_LNG_VALUE, value5);
513513
FullEntity<IncompleteKey> value6 = entity.getEntity("partial1");
514514
assertEquals(PARTIAL_ENTITY1, value6);
515515
assertEquals(6, entity.names().size());
@@ -534,7 +534,7 @@ public void testGetArray() {
534534
assertEquals(PARTIAL_ENTITY2, partial1);
535535
assertEquals(ENTITY2, partial2);
536536
assertEquals(ValueType.BOOLEAN, entity3.getValue("bool").type());
537-
assertEquals(GEO_POINT_VALUE, entity3.getValue("geoPoint"));
537+
assertEquals(LAT_LNG_VALUE, entity3.getValue("latLng"));
538538
assertEquals(7, entity3.names().size());
539539
assertFalse(entity3.contains("bla"));
540540
try {

gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/GeoPointTest.java renamed to gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LatLngTest.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
import org.junit.Test;
2424
import org.junit.rules.ExpectedException;
2525

26-
public class GeoPointTest {
26+
public class LatLngTest {
2727

2828
@Rule
2929
public ExpectedException thrown = ExpectedException.none();
3030

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

3434
private static final String INVALID_LAT_MESSAGE =
3535
"latitude must be in the range [-90, 90] degrees";
@@ -44,34 +44,34 @@ public void testEquals() {
4444

4545
@Test
4646
public void testUpperLatRange() {
47-
new GeoPoint(90, 0);
47+
new LatLng(90, 0);
4848
thrown.expect(IllegalArgumentException.class);
4949
thrown.expectMessage(INVALID_LAT_MESSAGE);
50-
new GeoPoint(91, 0);
50+
new LatLng(91, 0);
5151
}
5252

5353
@Test
5454
public void testLowerLatRange() {
55-
new GeoPoint(-90, 0);
55+
new LatLng(-90, 0);
5656
thrown.expect(IllegalArgumentException.class);
5757
thrown.expectMessage(INVALID_LAT_MESSAGE);
58-
new GeoPoint(-91, 0);
58+
new LatLng(-91, 0);
5959
}
6060

6161
@Test
6262
public void testUpperLngRange() {
63-
new GeoPoint(0, 180);
63+
new LatLng(0, 180);
6464
thrown.expect(IllegalArgumentException.class);
6565
thrown.expectMessage(INVALID_LNG_MESSAGE);
66-
new GeoPoint(0, 181);
66+
new LatLng(0, 181);
6767
}
6868

6969
@Test
7070
public void testLowerLngRange() {
71-
new GeoPoint(0, 180);
71+
new LatLng(0, 180);
7272
thrown.expect(IllegalArgumentException.class);
7373
thrown.expectMessage(INVALID_LNG_MESSAGE);
74-
new GeoPoint(0, -181);
74+
new LatLng(0, -181);
7575
}
7676
}
7777

gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/GeoPointValueTest.java renamed to gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LatLngValueTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,29 @@
2222

2323
import org.junit.Test;
2424

25-
public class GeoPointValueTest {
25+
public class LatLngValueTest {
2626

27-
private static final GeoPoint CONTENT = new GeoPoint(37.4, -122.1);
27+
private static final LatLng CONTENT = new LatLng(37.4, -122.1);
2828

2929
@Test
3030
public void testToBuilder() throws Exception {
31-
GeoPointValue value = GeoPointValue.of(CONTENT);
31+
LatLngValue value = LatLngValue.of(CONTENT);
3232
assertEquals(value, value.toBuilder().build());
3333
}
3434

3535
@SuppressWarnings("deprecation")
3636
@Test
3737
public void testOf() throws Exception {
38-
GeoPointValue value = GeoPointValue.of(CONTENT);
38+
LatLngValue value = LatLngValue.of(CONTENT);
3939
assertEquals(CONTENT, value.get());
4040
assertFalse(value.excludeFromIndexes());
4141
}
4242

4343
@SuppressWarnings("deprecation")
4444
@Test
4545
public void testBuilder() throws Exception {
46-
GeoPointValue.Builder builder = GeoPointValue.builder(CONTENT);
47-
GeoPointValue value = builder.meaning(1).excludeFromIndexes(true).build();
46+
LatLngValue.Builder builder = LatLngValue.builder(CONTENT);
47+
LatLngValue value = builder.meaning(1).excludeFromIndexes(true).build();
4848
assertEquals(CONTENT, value.get());
4949
assertEquals(1, value.meaning());
5050
assertTrue(value.excludeFromIndexes());

0 commit comments

Comments
 (0)