Skip to content

Commit 8683520

Browse files
authored
add tunnelName to StepIntersection (#1179)
1 parent 99fd907 commit 8683520

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ public Point location() {
126126
@Nullable
127127
public abstract List<IntersectionLanes> lanes();
128128

129+
/**
130+
* Name of the tunnel. Value may be present if {@link #classes} contains "tunnel".
131+
*
132+
* @return name of the tunnel
133+
*/
134+
@Nullable
135+
@SerializedName("tunnel_name")
136+
public abstract String tunnelName();
137+
129138
/**
130139
* Convert the current {@link StepIntersection} to its builder holding the currently assigned
131140
* values. This allows you to modify a single property and then rebuild the object resulting in
@@ -245,6 +254,14 @@ public abstract static class Builder {
245254
*/
246255
public abstract Builder lanes(@Nullable List<IntersectionLanes> lanes);
247256

257+
/**
258+
* Name of the tunnel. Value is present only if class is tunnel.
259+
*
260+
* @param tunnelName name of the tunnel
261+
* @return this builder for chaining options together
262+
*/
263+
public abstract Builder tunnelName(@Nullable String tunnelName);
264+
248265
/**
249266
* The rawLocation as a double array. Once the {@link StepIntersection} object's created,
250267
* this raw location gets converted into a {@link Point} object and is public exposed as such.

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public void testSerializable() throws Exception {
3838

3939
@Test
4040
public void testToFromJson1() {
41-
StepIntersection intersection
42-
= StepIntersection.builder()
41+
StepIntersection intersection = StepIntersection.builder()
4342
.out(0)
4443
.entry(Arrays.asList(true))
4544
.bearings(Arrays.asList(125))
4645
.rawLocation(new double[]{13.426579, 52.508068})
46+
.tunnelName("test tunnel")
4747
.build();
4848

4949
String jsonString = intersection.toJson();
@@ -54,13 +54,13 @@ public void testToFromJson1() {
5454

5555
@Test
5656
public void testToFromJson2() {
57-
StepIntersection intersection
58-
= StepIntersection.builder()
57+
StepIntersection intersection = StepIntersection.builder()
5958
.in(0)
6059
.out(1)
6160
.entry(Arrays.asList(false, true, true))
6261
.bearings(Arrays.asList(120, 210, 300))
6362
.rawLocation(new double[]{13.424671, 52.508812})
63+
.tunnelName("test tunnel")
6464
.build();
6565

6666
String jsonString = intersection.toJson();
@@ -73,8 +73,11 @@ public void testToFromJson2() {
7373
@Test
7474
public void testFromJson() {
7575
String stepIntersectionJsonString = "{\"out\": 0, \"entry\": [true], \"bearings\": [ 125 ], "
76+
+ "\"tunnel_name\": \"test tunnel name\","
7677
+ "\"location\": [ 13.426579, 52.508068 ] }";
78+
7779
StepIntersection stepIntersection = StepIntersection.fromJson(stepIntersectionJsonString);
80+
Assert.assertEquals("test tunnel name", stepIntersection.tunnelName());
7881

7982
Point location = stepIntersection.location();
8083
Assert.assertEquals(13.426579, location.longitude(), 0.0001);

0 commit comments

Comments
 (0)