|
| 1 | +package com.mapbox.navigation.base.internal.route |
| 2 | + |
| 3 | +import androidx.annotation.IntDef |
| 4 | +import com.mapbox.geojson.Point |
| 5 | + |
| 6 | +class Waypoint internal constructor( |
| 7 | + val location: Point, |
| 8 | + val name: String, |
| 9 | + val target: Point?, |
| 10 | + internal val internalType: InternalType |
| 11 | +) { |
| 12 | + |
| 13 | + @Type |
| 14 | + val type: Int = when (internalType) { |
| 15 | + InternalType.Regular -> REGULAR |
| 16 | + InternalType.Silent -> SILENT |
| 17 | + InternalType.EvCharging -> EV_CHARGING |
| 18 | + } |
| 19 | + |
| 20 | + companion object { |
| 21 | + const val REGULAR = 1 |
| 22 | + const val SILENT = 2 |
| 23 | + const val EV_CHARGING = 3 |
| 24 | + } |
| 25 | + |
| 26 | + @Target( |
| 27 | + AnnotationTarget.PROPERTY, |
| 28 | + AnnotationTarget.VALUE_PARAMETER, |
| 29 | + AnnotationTarget.FUNCTION, |
| 30 | + AnnotationTarget.TYPE |
| 31 | + ) |
| 32 | + @Retention(AnnotationRetention.BINARY) |
| 33 | + @IntDef(REGULAR, SILENT, EV_CHARGING) |
| 34 | + annotation class Type |
| 35 | + |
| 36 | + override fun equals(other: Any?): Boolean { |
| 37 | + if (this === other) return true |
| 38 | + if (javaClass != other?.javaClass) return false |
| 39 | + |
| 40 | + other as Waypoint |
| 41 | + |
| 42 | + if (location != other.location) return false |
| 43 | + if (type != other.type) return false |
| 44 | + if (name != other.name) return false |
| 45 | + if (target != other.target) return false |
| 46 | + |
| 47 | + return true |
| 48 | + } |
| 49 | + |
| 50 | + override fun hashCode(): Int { |
| 51 | + var result = location.hashCode() |
| 52 | + result = 31 * result + type |
| 53 | + result = 31 * result + name.hashCode() |
| 54 | + result = 31 * result + target.hashCode() |
| 55 | + return result |
| 56 | + } |
| 57 | + |
| 58 | + override fun toString(): String { |
| 59 | + return "Waypoint(location=$location, type=$type, name='$name', target=$target)" |
| 60 | + } |
| 61 | + |
| 62 | + internal enum class InternalType { |
| 63 | + Regular, |
| 64 | + Silent, |
| 65 | + EvCharging, |
| 66 | + } |
| 67 | +} |
0 commit comments