Skip to content

Commit 70ddaa1

Browse files
author
Łukasz Paczos
committed
exposed RestStop#name
1 parent ce0e7d8 commit 70ddaa1

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Mapbox welcomes participation and contributions from everyone.
44

55
### main
6+
- Added `RestStop#name` field which contains a name of the service/rest area, when available. [#1428](https://github.com/mapbox/mapbox-java/pull/1428)
67

78
### v6.5.0-beta.3 - April 27, 2022
89
- Added `ignore` parameter to Map Matching API. [#1424](https://github.com/mapbox/mapbox-java/pull/1424)

services-directions-models/src/main/java/com/mapbox/api/directions/v5/models/RestStop.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public abstract class RestStop extends DirectionsJsonObject {
2424
@Nullable
2525
public abstract String type();
2626

27+
/**
28+
* The name of the rest stop. Optionally included if data is available.
29+
*/
30+
@Nullable
31+
public abstract String name();
32+
2733
/**
2834
* Create a new instance of this class by using the {@link Builder} class.
2935
*
@@ -80,6 +86,13 @@ public abstract static class Builder extends DirectionsJsonObject.Builder<Builde
8086
*/
8187
public abstract Builder type(@Nullable String type);
8288

89+
/**
90+
* The name of the rest stop. Optionally included if data is available.
91+
*
92+
* @param name rest stop name
93+
*/
94+
public abstract Builder name(@Nullable String name);
95+
8396
/**
8497
* Build a new {@link RestStop} object.
8598
*

services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/StepIntersectionTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void testToFromJson1() {
4646
.rawLocation(new double[]{13.426579, 52.508068})
4747
.geometryIndex(123)
4848
.isUrban(true)
49-
.restStop(RestStop.builder().type("rest_area").build())
49+
.restStop(RestStop.builder().type("rest_area").name("stop_name").build())
5050
.tollCollection(TollCollection.builder().type("toll_gantry").build())
5151
.adminIndex(2)
5252
.mapboxStreetsV8(MapboxStreetsV8.builder().roadClass("street").build())
@@ -125,12 +125,13 @@ public void testAdminIndex() {
125125
public void testRestStop() {
126126
String stepIntersectionJsonString = "{"
127127
+ "\"location\": [ 13.426579, 52.508068 ],"
128-
+ "\"rest_stop\": { \"type\": \"rest_area\" }"
128+
+ "\"rest_stop\": { \"type\": \"rest_area\", \"name\": \"stop_name\" }"
129129
+ "}";
130130

131131
StepIntersection stepIntersection = StepIntersection.fromJson(stepIntersectionJsonString);
132132

133133
Assert.assertEquals("rest_area", stepIntersection.restStop().type());
134+
Assert.assertEquals("stop_name", stepIntersection.restStop().name());
134135
String jsonStr = stepIntersection.toJson();
135136
compareJson(stepIntersectionJsonString, jsonStr);
136137
}

0 commit comments

Comments
 (0)