11package com.mapbox.navigation.core.adasis
22
3+ import androidx.annotation.IntDef
34import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
5+ import com.mapbox.navigation.core.adasis.AdasisSpeedLimitInfo.SpeedLimitType
46import com.mapbox.navigation.core.sensor.SensorData
57
68/* *
79 * Speed limit restriction
810 *
911 * @param weather Weather conditions where the speed limit is applied. Empty means all
1012 * @param dateTimeCondition OSM "opening_hours" format, see https://wiki.openstreetmap.org/wiki/Key:opening_hours
11- * @param vehicleTypes A list of types of vehicles for that the speed limit is included. Empty means all
13+ * @param vehicleTypes A list of [VehicleType.Type] types for that the speed limit is included. Empty means all
1214 * @param lanes Lane numbers where the speed limit is valid. Empty array means all lanes
1315 */
1416@ExperimentalPreviewMapboxNavigationAPI
1517class AdasisSpeedLimitRestriction private constructor(
1618 val weather : List <SensorData .Weather .Condition >,
1719 val dateTimeCondition : String ,
18- val vehicleTypes : List <VehicleType >,
20+ val vehicleTypes : List <Int >,
1921 val lanes : List <Byte >
2022) {
2123
@@ -60,46 +62,45 @@ class AdasisSpeedLimitRestriction private constructor(
6062 /* *
6163 * Type of vehicle for which the speed limit is included.
6264 */
63- abstract class VehicleType internal constructor() {
65+ object VehicleType {
6466
6567 /* *
6668 * Car vehicle type
6769 */
68- object Car : VehicleType()
70+ const val CAR = 0
6971
7072 /* *
7173 * Truck vehicle type
7274 */
73- object Truck : VehicleType()
75+ const val TRUCK = 1
7476
7577 /* *
7678 * Bus vehicle type
7779 */
78- object Bus : VehicleType()
80+ const val BUS = 2
7981
8082 /* *
8183 * Trailer vehicle type
8284 */
83- object Trailer : VehicleType()
85+ const val TRAILER = 3
8486
8587 /* *
8688 * Motorcycle vehicle type
8789 */
88- object Motorcycle : VehicleType()
89-
90- internal companion object {
91-
92- @JvmSynthetic
93- fun createFromNativeObject (nativeObj : com.mapbox.navigator.VehicleType ): VehicleType {
94- return when (nativeObj) {
95- com.mapbox.navigator.VehicleType .CAR -> Car
96- com.mapbox.navigator.VehicleType .TRUCK -> Truck
97- com.mapbox.navigator.VehicleType .BUS -> Bus
98- com.mapbox.navigator.VehicleType .TRAILER -> Trailer
99- com.mapbox.navigator.VehicleType .MOTORCYCLE -> Motorcycle
100- }
101- }
102- }
90+ const val MOTORCYCLE = 4
91+
92+ /* *
93+ * Retention policy for the [VehicleType]
94+ */
95+ @Retention(AnnotationRetention .BINARY )
96+ @IntDef(
97+ CAR ,
98+ TRUCK ,
99+ BUS ,
100+ TRAILER ,
101+ MOTORCYCLE
102+ )
103+ annotation class Type
103104 }
104105
105106 internal companion object {
@@ -111,10 +112,20 @@ class AdasisSpeedLimitRestriction private constructor(
111112 SensorData .Weather .Condition .createFromNativeObject(it)
112113 },
113114 dateTimeCondition = nativeObj.dateTimeCondition,
114- vehicleTypes = nativeObj.vehicleTypes.map {
115- VehicleType .createFromNativeObject(it)
116- },
115+ vehicleTypes = nativeObj.vehicleTypes.map { createVehicleType(it) },
117116 lanes = nativeObj.lanes,
118117 )
118+
119+ @JvmSynthetic
120+ @VehicleType.Type
121+ private fun createVehicleType (nativeObj : com.mapbox.navigator.VehicleType ): Int {
122+ return when (nativeObj) {
123+ com.mapbox.navigator.VehicleType .CAR -> VehicleType .CAR
124+ com.mapbox.navigator.VehicleType .TRUCK -> VehicleType .TRUCK
125+ com.mapbox.navigator.VehicleType .BUS -> VehicleType .BUS
126+ com.mapbox.navigator.VehicleType .TRAILER -> VehicleType .TRAILER
127+ com.mapbox.navigator.VehicleType .MOTORCYCLE -> VehicleType .MOTORCYCLE
128+ }
129+ }
119130 }
120131}
0 commit comments