|
3 | 3 | import android.support.annotation.FloatRange; |
4 | 4 | import android.support.annotation.NonNull; |
5 | 5 | import android.support.annotation.Nullable; |
| 6 | +import android.support.annotation.StringDef; |
| 7 | + |
6 | 8 | import com.google.auto.value.AutoValue; |
7 | 9 | import com.google.gson.Gson; |
8 | 10 | import com.google.gson.GsonBuilder; |
9 | 11 | import com.google.gson.TypeAdapter; |
10 | 12 | import com.google.gson.annotations.SerializedName; |
11 | 13 | import com.mapbox.api.directions.v5.DirectionsAdapterFactory; |
| 14 | +import com.mapbox.api.directions.v5.MapboxDirections; |
12 | 15 | import com.mapbox.geojson.Point; |
13 | 16 |
|
| 17 | +import java.lang.annotation.Retention; |
| 18 | +import java.lang.annotation.RetentionPolicy; |
| 19 | + |
14 | 20 | /** |
15 | 21 | * Gives maneuver information about one {@link LegStep}. |
16 | 22 | * |
|
19 | 25 | @AutoValue |
20 | 26 | public abstract class StepManeuver extends DirectionsJsonObject { |
21 | 27 |
|
| 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 | + |
22 | 181 | /** |
23 | 182 | * Create a new instance of this class by using the {@link Builder} class. |
24 | 183 | * |
@@ -89,34 +248,13 @@ public Point location() { |
89 | 248 | public abstract String instruction(); |
90 | 249 |
|
91 | 250 | /** |
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 |
116 | 253 | * @return String with type of maneuver |
117 | 254 | * @since 1.0.0 |
118 | 255 | */ |
119 | 256 | @Nullable |
| 257 | + @StepManeuverType |
120 | 258 | public abstract String type(); |
121 | 259 |
|
122 | 260 | /** |
@@ -241,10 +379,11 @@ public abstract Builder bearingAfter( |
241 | 379 | * options. |
242 | 380 | * |
243 | 381 | * @param type String with type of maneuver |
| 382 | + * @see StepManeuverType |
244 | 383 | * @return this builder for chaining options together |
245 | 384 | * @since 3.0.0 |
246 | 385 | */ |
247 | | - public abstract Builder type(@Nullable String type); |
| 386 | + public abstract Builder type(@Nullable @StepManeuverType String type); |
248 | 387 |
|
249 | 388 | /** |
250 | 389 | * This indicates the mode of the maneuver. If type is of turn, the modifier indicates the |
|
0 commit comments