Skip to content

Commit d54fe4c

Browse files
authored
Added StepManeuver.Type for ease of use (#898)
1 parent 402d63e commit d54fe4c

2 files changed

Lines changed: 169 additions & 49 deletions

File tree

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,14 @@ public static Builder builder() {
5252
public abstract List<BannerComponents> components();
5353

5454
/**
55-
* This indicates the type of maneuver. It can be any of these listed:
56-
* <br>
57-
* <ul>
58-
* <li>turn - a basic turn into direction of the modifier</li>
59-
* <li>new name - the road name changes (after a mandatory turn)</li>
60-
* <li>depart - indicates departure from a leg</li>
61-
* <li>arrive - indicates arrival to a destination of a leg</li>
62-
* <li>merge - merge onto a street</li>
63-
* <li>on ramp - take a ramp to enter a highway</li>
64-
* <li>off ramp - take a ramp to exit a highway</li>
65-
* <li>fork - take the left/right side of a fork</li>
66-
* <li>end of road - road ends in a T intersection</li>
67-
* <li>continue - continue on a street after a turn</li>
68-
* <li>roundabout - traverse roundabout, has additional property exit in RouteStep
69-
* containing the exit number. The modifier specifies the direction of entering the roundabout.
70-
* </li>
71-
* <li>rotary - a traffic circle. While very similar to a larger version of a roundabout, it does
72-
* not necessarily follow roundabout rules for right of way. It can offer
73-
* {@link LegStep#rotaryName()} and/or {@link LegStep#rotaryPronunciation()} parameters in
74-
* addition to the exit property.</li>
75-
* <li>roundabout turn - small roundabout that is treated as an intersection</li>
76-
* <li>notification - change of driving conditions, e.g. change of mode from driving to ferry</li>
77-
* </ul>
55+
* This indicates the type of maneuver.
7856
*
7957
* @return String with type of maneuver
58+
* @see com.mapbox.api.directions.v5.models.StepManeuver.StepManeuverType
8059
* @since 3.0.0
8160
*/
8261
@Nullable
62+
@StepManeuver.StepManeuverType
8363
public abstract String type();
8464

8565
/**
@@ -185,9 +165,10 @@ public abstract static class Builder {
185165
*
186166
* @param type String with type of maneuver
187167
* @return this builder for chaining options together
168+
* @see com.mapbox.api.directions.v5.models.StepManeuver.StepManeuverType
188169
* @since 3.0.0
189170
*/
190-
public abstract Builder type(@Nullable String type);
171+
public abstract Builder type(@Nullable @StepManeuver.StepManeuverType String type);
191172

192173
/**
193174
* This indicates the mode of the maneuver. If type is of turn, the modifier indicates the

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

Lines changed: 164 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
import android.support.annotation.FloatRange;
44
import android.support.annotation.NonNull;
55
import android.support.annotation.Nullable;
6+
import android.support.annotation.StringDef;
7+
68
import com.google.auto.value.AutoValue;
79
import com.google.gson.Gson;
810
import com.google.gson.GsonBuilder;
911
import com.google.gson.TypeAdapter;
1012
import com.google.gson.annotations.SerializedName;
1113
import com.mapbox.api.directions.v5.DirectionsAdapterFactory;
14+
import com.mapbox.api.directions.v5.MapboxDirections;
1215
import com.mapbox.geojson.Point;
1316

17+
import java.lang.annotation.Retention;
18+
import java.lang.annotation.RetentionPolicy;
19+
1420
/**
1521
* Gives maneuver information about one {@link LegStep}.
1622
*
@@ -19,6 +25,159 @@
1925
@AutoValue
2026
public abstract class StepManeuver extends DirectionsJsonObject {
2127

28+
/**
29+
* A basic turn in the direction of the modifier.
30+
*
31+
* @since 4.1.0
32+
*/
33+
public static final String TURN = "turn";
34+
35+
/**
36+
* The road name changes (after a mandatory turn).
37+
*
38+
* @since 4.1.0
39+
*/
40+
public static final String NEW_NAME = "new name";
41+
42+
/**
43+
* Indicates departure from a leg.
44+
* The modifier value indicates the position of the departure point
45+
* in relation to the current direction of travel.
46+
*
47+
* @since 4.1.0
48+
*/
49+
public static final String DEPART = "depart";
50+
51+
/**
52+
* Indicates arrival to a destination of a leg.
53+
* The modifier value indicates the position of the arrival point
54+
* in relation to the current direction of travel.
55+
*
56+
* @since 4.1.0
57+
*/
58+
public static final String ARRIVE = "arrive";
59+
60+
/**
61+
* Merge onto a street.
62+
*
63+
* @since 4.1.0
64+
*/
65+
public static final String MERGE = "merge";
66+
67+
/**
68+
* Take a ramp to enter a highway.
69+
* @since 4.1.0
70+
*/
71+
public static final String ON_RAMP = "on ramp";
72+
73+
/**
74+
* Take a ramp to exit a highway.
75+
*
76+
* @since 4.1.0
77+
*/
78+
public static final String OFF_RAMP = "off ramp";
79+
80+
/**
81+
* Take the left or right side of a fork.
82+
*
83+
* @since 4.1.0
84+
*/
85+
public static final String FORK = "fork";
86+
87+
/**
88+
* Road ends in a T intersection.
89+
*
90+
* @since 4.1.0
91+
*/
92+
public static final String END_OF_ROAD = "end of road";
93+
94+
/**
95+
* Continue on a street after a turn.
96+
*
97+
* @since 4.1.0
98+
*/
99+
public static final String CONTINUE = "continue";
100+
101+
/**
102+
* Traverse roundabout.
103+
* Has an additional property exit in the route step that contains
104+
* the exit number. The modifier specifies the direction of entering the roundabout.
105+
*
106+
* @since 4.1.0
107+
*/
108+
public static final String ROUNDABOUT = "roundabout";
109+
110+
/**
111+
* A traffic circle. While very similar to a larger version of a roundabout,
112+
* it does not necessarily follow roundabout rules for right of way.
113+
* It can offer {@link LegStep#rotaryName()} parameters,
114+
* {@link LegStep#rotaryPronunciation()} ()} parameters, or both,
115+
* in addition to the {@link #exit()} property.
116+
*
117+
* @since 4.1.0
118+
*/
119+
public static final String ROTARY = "rotary";
120+
121+
/**
122+
* A small roundabout that is treated as an intersection.
123+
*
124+
* @since 4.1.0
125+
*/
126+
public static final String ROUNDABOUT_TURN = "roundabout turn";
127+
128+
/**
129+
* Indicates a change of driving conditions, for example changing the mode
130+
* from driving to ferry.
131+
*
132+
* @since 4.1.0
133+
*/
134+
public static final String NOTIFICATION = "notification";
135+
136+
/**
137+
* Indicates the exit maneuver from a roundabout.
138+
* Will not appear in results unless you supply true to the {@link #exit()} query
139+
* parameter in the request.
140+
*
141+
* @since 4.1.0
142+
*/
143+
public static final String EXIT_ROUNDABOUT = "exit roundabout";
144+
145+
/**
146+
* Indicates the exit maneuver from a rotary.
147+
* Will not appear in results unless you supply true
148+
* to the {@link MapboxDirections#roundaboutExits()} query parameter in the request.
149+
*
150+
* @since 4.1.0
151+
*/
152+
public static final String EXIT_ROTARY = "exit rotary";
153+
154+
/**
155+
* Maneuver types.
156+
*
157+
* @since 4.1.0
158+
*/
159+
@Retention(RetentionPolicy.SOURCE)
160+
@StringDef( {
161+
TURN,
162+
NEW_NAME,
163+
DEPART,
164+
ARRIVE,
165+
MERGE,
166+
ON_RAMP,
167+
OFF_RAMP,
168+
FORK,
169+
END_OF_ROAD,
170+
CONTINUE,
171+
ROUNDABOUT,
172+
ROTARY,
173+
ROUNDABOUT_TURN,
174+
NOTIFICATION,
175+
EXIT_ROUNDABOUT,
176+
EXIT_ROTARY
177+
})
178+
public @interface StepManeuverType {
179+
}
180+
22181
/**
23182
* Create a new instance of this class by using the {@link Builder} class.
24183
*
@@ -89,34 +248,13 @@ public Point location() {
89248
public abstract String instruction();
90249

91250
/**
92-
* This indicates the type of maneuver. It can be any of these listed:
93-
* <br>
94-
* <ul>
95-
* <li>turn - a basic turn into direction of the modifier</li>
96-
* <li>new name - the road name changes (after a mandatory turn)</li>
97-
* <li>depart - indicates departure from a leg</li>
98-
* <li>arrive - indicates arrival to a destination of a leg</li>
99-
* <li>merge - merge onto a street</li>
100-
* <li>on ramp - take a ramp to enter a highway</li>
101-
* <li>off ramp - take a ramp to exit a highway</li>
102-
* <li>fork - take the left/right side of a fork</li>
103-
* <li>end of road - road ends in a T intersection</li>
104-
* <li>continue - continue on a street after a turn</li>
105-
* <li>roundabout - traverse roundabout, has additional property {@link #exit()} in RouteStep
106-
* containing the exit number. The modifier specifies the direction of entering the roundabout.
107-
* </li>
108-
* <li>rotary - a traffic circle. While very similar to a larger version of a roundabout, it does
109-
* not necessarily follow roundabout rules for right of way. It can offer
110-
* {@link LegStep#rotaryName()} and/or {@link LegStep#rotaryPronunciation()} parameters in
111-
* addition to the {@link #exit()} property.</li>
112-
* <li>roundabout turn - small roundabout that is treated as an intersection</li>
113-
* <li>notification - change of driving conditions, e.g. change of mode from driving to ferry</li>
114-
* </ul>
115-
*
251+
* This indicates the type of maneuver.
252+
* @see StepManeuverType
116253
* @return String with type of maneuver
117254
* @since 1.0.0
118255
*/
119256
@Nullable
257+
@StepManeuverType
120258
public abstract String type();
121259

122260
/**
@@ -241,10 +379,11 @@ public abstract Builder bearingAfter(
241379
* options.
242380
*
243381
* @param type String with type of maneuver
382+
* @see StepManeuverType
244383
* @return this builder for chaining options together
245384
* @since 3.0.0
246385
*/
247-
public abstract Builder type(@Nullable String type);
386+
public abstract Builder type(@Nullable @StepManeuverType String type);
248387

249388
/**
250389
* This indicates the mode of the maneuver. If type is of turn, the modifier indicates the

0 commit comments

Comments
 (0)