|
| 1 | +package com.mapbox.maps.plugin.locationcomponent |
| 2 | + |
| 3 | +import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.BEARING_ICON |
| 4 | +import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.LOCATION_INDICATOR_LAYER |
| 5 | +import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.MODEL_LAYER |
| 6 | +import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.MODEL_SOURCE |
| 7 | +import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.SHADOW_ICON |
| 8 | +import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.TOP_ICON |
| 9 | +import java.util.Objects |
| 10 | +import kotlin.Any |
| 11 | +import kotlin.Boolean |
| 12 | +import kotlin.Int |
| 13 | +import kotlin.String |
| 14 | +import kotlin.Unit |
| 15 | +import kotlin.jvm.JvmSynthetic |
| 16 | + |
| 17 | +/** |
| 18 | + * Initialisation options for location component to allow multiple instances |
| 19 | + * of LocationComponent. |
| 20 | + */ |
| 21 | +public class LocationComponentInitOptions private constructor( |
| 22 | + public val puck2DLayerId: String, |
| 23 | + public val puck3DLayerId: String, |
| 24 | + public val puck3DSourceId: String, |
| 25 | + public val topIconImageId: String, |
| 26 | + public val shadowIconImageId: String, |
| 27 | + public val bearingIconImageId: String |
| 28 | +) { |
| 29 | + public override fun toString() = "LocationComponentInitOptions(puck2DLayerId=$puck2DLayerId,puck3DLayerId=$puck3DLayerId, puck3DSourceId=$puck3DSourceId, topIconImageId=$topIconImageId,shadowIconImageId=$shadowIconImageId, bearingIconImageId=$bearingIconImageId)" |
| 30 | + |
| 31 | + public override fun equals(other: Any?): Boolean = other is LocationComponentInitOptions |
| 32 | + && puck2DLayerId == other.puck2DLayerId |
| 33 | + && puck3DLayerId == other.puck3DLayerId |
| 34 | + && puck3DSourceId == other.puck3DSourceId |
| 35 | + && topIconImageId == other.topIconImageId |
| 36 | + && shadowIconImageId == other.shadowIconImageId |
| 37 | + && bearingIconImageId == other.bearingIconImageId |
| 38 | + |
| 39 | + public override fun hashCode(): Int = Objects.hash(puck2DLayerId, puck3DLayerId, puck3DSourceId, |
| 40 | + topIconImageId, shadowIconImageId, bearingIconImageId) |
| 41 | + |
| 42 | + /** |
| 43 | + * Composes and builds a [LocationComponentInitOptions] object. |
| 44 | + * |
| 45 | + * This is a concrete implementation of the builder design pattern. |
| 46 | + * |
| 47 | + * @property |
| 48 | + */ |
| 49 | + public class Builder { |
| 50 | + @set:JvmSynthetic |
| 51 | + public var puck2DLayerId: String = LOCATION_INDICATOR_LAYER |
| 52 | + |
| 53 | + @set:JvmSynthetic |
| 54 | + public var puck3DLayerId: String = MODEL_LAYER |
| 55 | + |
| 56 | + @set:JvmSynthetic |
| 57 | + public var puck3DSourceId: String = MODEL_SOURCE |
| 58 | + |
| 59 | + @set:JvmSynthetic |
| 60 | + public var topIconImageId: String = TOP_ICON |
| 61 | + |
| 62 | + @set:JvmSynthetic |
| 63 | + public var shadowIconImageId: String = SHADOW_ICON |
| 64 | + |
| 65 | + @set:JvmSynthetic |
| 66 | + public var bearingIconImageId: String = BEARING_ICON |
| 67 | + |
| 68 | + /** |
| 69 | + * Set puck2DLayerId |
| 70 | + * |
| 71 | + * @param puck2DLayerId puck2DLayerId |
| 72 | + * @return Builder |
| 73 | + */ |
| 74 | + public fun setPuck2DLayerId(puck2DLayerId: String): Builder { |
| 75 | + this.puck2DLayerId = puck2DLayerId |
| 76 | + return this |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Set puck3DLayerId |
| 81 | + * |
| 82 | + * @param puck3DLayerId puck3DLayerId |
| 83 | + * @return Builder |
| 84 | + */ |
| 85 | + public fun setPuck3DLayerId(puck3DLayerId: String): Builder { |
| 86 | + this.puck3DLayerId = puck3DLayerId |
| 87 | + return this |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Set puck3DSourceId |
| 92 | + * |
| 93 | + * @param puck3DSourceId puck3DSourceId |
| 94 | + * @return Builder |
| 95 | + */ |
| 96 | + public fun setPuck3DSourceId(puck3DSourceId: String): Builder { |
| 97 | + this.puck3DSourceId = puck3DSourceId |
| 98 | + return this |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Set topIconImageId |
| 103 | + * |
| 104 | + * @param topIconImageId topIconImageId |
| 105 | + * @return Builder |
| 106 | + */ |
| 107 | + public fun setTopIconImageId(topIconImageId: String): Builder { |
| 108 | + this.topIconImageId = topIconImageId |
| 109 | + return this |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * Set shadowIconImageId |
| 114 | + * |
| 115 | + * @param shadowIconImageId shadowIconImageId |
| 116 | + * @return Builder |
| 117 | + */ |
| 118 | + public fun setShadowIconImageId(shadowIconImageId: String): Builder { |
| 119 | + this.shadowIconImageId = shadowIconImageId |
| 120 | + return this |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * Set bearingIconImageId |
| 125 | + * |
| 126 | + * @param bearingIconImageId bearingIconImageId |
| 127 | + * @return Builder |
| 128 | + */ |
| 129 | + public fun setBearingIconImageId(bearingIconImageId: String): Builder { |
| 130 | + this.bearingIconImageId = bearingIconImageId |
| 131 | + return this |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * Returns a [LocationComponentInitOptions] reference to the object being constructed by the |
| 136 | + * builder. |
| 137 | + * |
| 138 | + * Throws an [IllegalArgumentException] when a non-null property wasn't initialised. |
| 139 | + * |
| 140 | + * @return LocationComponentInitOptions |
| 141 | + */ |
| 142 | + public fun build(): LocationComponentInitOptions { |
| 143 | + return LocationComponentInitOptions(puck2DLayerId, puck3DLayerId, puck3DSourceId, |
| 144 | + topIconImageId, shadowIconImageId, bearingIconImageId) |
| 145 | + } |
| 146 | + } |
| 147 | +} |
| 148 | + |
| 149 | +/** |
| 150 | + * Creates a [LocationComponentInitOptions] through a DSL-style builder. |
| 151 | + * |
| 152 | + * @param initializer the intialisation block |
| 153 | + * @return LocationComponentInitOptions |
| 154 | + */ |
| 155 | +@JvmSynthetic |
| 156 | +public fun LocationComponentInitOptions(initializer: LocationComponentInitOptions.Builder.() -> Unit): |
| 157 | + LocationComponentInitOptions = LocationComponentInitOptions.Builder().apply(initializer).build() |
0 commit comments