From fff5ec2ab5207e5e378a1cf59e79922f1f8ade21 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 14:50:35 +0000 Subject: [PATCH 01/38] feat(api): api update --- .stats.yml | 4 +- .../ScheduleForRouteRetrieveResponse.kt | 2825 +++++------------ .../StopsForAgencyListResponse.kt | 1267 ++++---- .../StopsForRouteListResponse.kt | 1725 +++++----- .../ScheduleForRouteRetrieveResponseTest.kt | 90 - .../StopsForAgencyListResponseTest.kt | 800 ++--- .../StopsForRouteListResponseTest.kt | 907 +++--- 7 files changed, 3322 insertions(+), 4296 deletions(-) diff --git a/.stats.yml b/.stats.yml index ad9cf70..26b456c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-4fcbe9547537b22a2d68329e1d94e0c1a6f81b5af734ca213f7b95eef5da7adb.yml -openapi_spec_hash: 417ea17b08e186b15b2986372592185e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-162c2011b5784e2258775ec72e5da7bc86cb411d738b627f1eae6a0d56ee3aec.yml +openapi_spec_hash: 2e32c25a86f9ff55bab7cfa1d9c985a7 config_hash: 3871f5d21bb38ddd334ec04721dea64d diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt index ba49db3..b9c6972 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt @@ -441,9 +441,7 @@ private constructor( private val routeId: JsonField, private val scheduleDate: JsonField, private val serviceIds: JsonField>, - private val stops: JsonField>, private val stopTripGroupings: JsonField>, - private val trips: JsonField>, private val additionalProperties: MutableMap, ) { @@ -458,24 +456,10 @@ private constructor( @JsonProperty("serviceIds") @ExcludeMissing serviceIds: JsonField> = JsonMissing.of(), - @JsonProperty("stops") - @ExcludeMissing - stops: JsonField> = JsonMissing.of(), @JsonProperty("stopTripGroupings") @ExcludeMissing stopTripGroupings: JsonField> = JsonMissing.of(), - @JsonProperty("trips") - @ExcludeMissing - trips: JsonField> = JsonMissing.of(), - ) : this( - routeId, - scheduleDate, - serviceIds, - stops, - stopTripGroupings, - trips, - mutableMapOf(), - ) + ) : this(routeId, scheduleDate, serviceIds, stopTripGroupings, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or @@ -498,13 +482,6 @@ private constructor( */ fun serviceIds(): List = serviceIds.getRequired("serviceIds") - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun stops(): List = stops.getRequired("stops") - /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -513,13 +490,6 @@ private constructor( fun stopTripGroupings(): List = stopTripGroupings.getRequired("stopTripGroupings") - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun trips(): List = trips.getRequired("trips") - /** * Returns the raw JSON value of [routeId]. * @@ -547,13 +517,6 @@ private constructor( @ExcludeMissing fun _serviceIds(): JsonField> = serviceIds - /** - * Returns the raw JSON value of [stops]. - * - * Unlike [stops], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("stops") @ExcludeMissing fun _stops(): JsonField> = stops - /** * Returns the raw JSON value of [stopTripGroupings]. * @@ -564,13 +527,6 @@ private constructor( @ExcludeMissing fun _stopTripGroupings(): JsonField> = stopTripGroupings - /** - * Returns the raw JSON value of [trips]. - * - * Unlike [trips], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -593,9 +549,7 @@ private constructor( * .routeId() * .scheduleDate() * .serviceIds() - * .stops() * .stopTripGroupings() - * .trips() * ``` */ @JvmStatic fun builder() = Builder() @@ -607,9 +561,7 @@ private constructor( private var routeId: JsonField? = null private var scheduleDate: JsonField? = null private var serviceIds: JsonField>? = null - private var stops: JsonField>? = null private var stopTripGroupings: JsonField>? = null - private var trips: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -617,9 +569,7 @@ private constructor( routeId = entry.routeId scheduleDate = entry.scheduleDate serviceIds = entry.serviceIds.map { it.toMutableList() } - stops = entry.stops.map { it.toMutableList() } stopTripGroupings = entry.stopTripGroupings.map { it.toMutableList() } - trips = entry.trips.map { it.toMutableList() } additionalProperties = entry.additionalProperties.toMutableMap() } @@ -672,31 +622,6 @@ private constructor( } } - fun stops(stops: List) = stops(JsonField.of(stops)) - - /** - * Sets [Builder.stops] to an arbitrary JSON value. - * - * You should usually call [Builder.stops] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun stops(stops: JsonField>) = apply { - this.stops = stops.map { it.toMutableList() } - } - - /** - * Adds a single [Stop] to [stops]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addStop(stop: Stop) = apply { - stops = - (stops ?: JsonField.of(mutableListOf())).also { - checkKnown("stops", it).add(stop) - } - } - fun stopTripGroupings(stopTripGroupings: List) = stopTripGroupings(JsonField.of(stopTripGroupings)) @@ -724,31 +649,6 @@ private constructor( } } - fun trips(trips: List) = trips(JsonField.of(trips)) - - /** - * Sets [Builder.trips] to an arbitrary JSON value. - * - * You should usually call [Builder.trips] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun trips(trips: JsonField>) = apply { - this.trips = trips.map { it.toMutableList() } - } - - /** - * Adds a single [Trip] to [trips]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTrip(trip: Trip) = apply { - trips = - (trips ?: JsonField.of(mutableListOf())).also { - checkKnown("trips", it).add(trip) - } - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -781,9 +681,7 @@ private constructor( * .routeId() * .scheduleDate() * .serviceIds() - * .stops() * .stopTripGroupings() - * .trips() * ``` * * @throws IllegalStateException if any required field is unset. @@ -793,11 +691,9 @@ private constructor( checkRequired("routeId", routeId), checkRequired("scheduleDate", scheduleDate), checkRequired("serviceIds", serviceIds).map { it.toImmutable() }, - checkRequired("stops", stops).map { it.toImmutable() }, checkRequired("stopTripGroupings", stopTripGroupings).map { it.toImmutable() }, - checkRequired("trips", trips).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -812,9 +708,7 @@ private constructor( routeId() scheduleDate() serviceIds() - stops().forEach { it.validate() } stopTripGroupings().forEach { it.validate() } - trips().forEach { it.validate() } validated = true } @@ -837,69 +731,42 @@ private constructor( (if (routeId.asKnown().isPresent) 1 else 0) + (if (scheduleDate.asKnown().isPresent) 1 else 0) + (serviceIds.asKnown().getOrNull()?.size ?: 0) + - (stops.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (stopTripGroupings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (trips.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (stopTripGroupings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - class Stop + class StopTripGrouping @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, - private val lat: JsonField, - private val locationType: JsonField, - private val lon: JsonField, - private val name: JsonField, - private val parent: JsonField, - private val routeIds: JsonField>, - private val staticRouteIds: JsonField>, - private val code: JsonField, - private val direction: JsonField, - private val wheelchairBoarding: JsonField, + private val directionId: JsonField, + private val stopIds: JsonField>, + private val tripHeadsigns: JsonField>, + private val tripIds: JsonField>, + private val tripsWithStopTimes: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - locationType: JsonField = JsonMissing.of(), - @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - parent: JsonField = JsonMissing.of(), - @JsonProperty("routeIds") + @JsonProperty("directionId") @ExcludeMissing - routeIds: JsonField> = JsonMissing.of(), - @JsonProperty("staticRouteIds") + directionId: JsonField = JsonMissing.of(), + @JsonProperty("stopIds") @ExcludeMissing - staticRouteIds: JsonField> = JsonMissing.of(), - @JsonProperty("code") + stopIds: JsonField> = JsonMissing.of(), + @JsonProperty("tripHeadsigns") @ExcludeMissing - code: JsonField = JsonMissing.of(), - @JsonProperty("direction") + tripHeadsigns: JsonField> = JsonMissing.of(), + @JsonProperty("tripIds") @ExcludeMissing - direction: JsonField = JsonMissing.of(), - @JsonProperty("wheelchairBoarding") + tripIds: JsonField> = JsonMissing.of(), + @JsonProperty("tripsWithStopTimes") @ExcludeMissing - wheelchairBoarding: JsonField = JsonMissing.of(), + tripsWithStopTimes: JsonField> = JsonMissing.of(), ) : this( - id, - lat, - locationType, - lon, - name, - parent, - routeIds, - staticRouteIds, - code, - direction, - wheelchairBoarding, + directionId, + stopIds, + tripHeadsigns, + tripIds, + tripsWithStopTimes, mutableMapOf(), ) @@ -908,170 +775,85 @@ private constructor( * type or is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun id(): String = id.getRequired("id") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun lat(): Double = lat.getRequired("lat") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun locationType(): Long = locationType.getRequired("locationType") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun lon(): Double = lon.getRequired("lon") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun name(): String = name.getRequired("name") + fun directionId(): String = directionId.getRequired("directionId") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun parent(): String = parent.getRequired("parent") + fun stopIds(): List = stopIds.getRequired("stopIds") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun routeIds(): List = routeIds.getRequired("routeIds") + fun tripHeadsigns(): List = tripHeadsigns.getRequired("tripHeadsigns") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun code(): Optional = code.getOptional("code") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun direction(): Optional = direction.getOptional("direction") + fun tripIds(): List = tripIds.getRequired("tripIds") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun wheelchairBoarding(): Optional = - wheelchairBoarding.getOptional("wheelchairBoarding") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [lat]. - * - * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + fun tripsWithStopTimes(): Optional> = + tripsWithStopTimes.getOptional("tripsWithStopTimes") /** - * Returns the raw JSON value of [locationType]. + * Returns the raw JSON value of [directionId]. * - * Unlike [locationType], this method doesn't throw if the JSON field has an + * Unlike [directionId], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("locationType") + @JsonProperty("directionId") @ExcludeMissing - fun _locationType(): JsonField = locationType - - /** - * Returns the raw JSON value of [lon]. - * - * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [parent]. - * - * Unlike [parent], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + fun _directionId(): JsonField = directionId /** - * Returns the raw JSON value of [routeIds]. + * Returns the raw JSON value of [stopIds]. * - * Unlike [routeIds], this method doesn't throw if the JSON field has an unexpected + * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("routeIds") + @JsonProperty("stopIds") @ExcludeMissing - fun _routeIds(): JsonField> = routeIds + fun _stopIds(): JsonField> = stopIds /** - * Returns the raw JSON value of [staticRouteIds]. + * Returns the raw JSON value of [tripHeadsigns]. * - * Unlike [staticRouteIds], this method doesn't throw if the JSON field has an + * Unlike [tripHeadsigns], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("staticRouteIds") + @JsonProperty("tripHeadsigns") @ExcludeMissing - fun _staticRouteIds(): JsonField> = staticRouteIds - - /** - * Returns the raw JSON value of [code]. - * - * Unlike [code], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + fun _tripHeadsigns(): JsonField> = tripHeadsigns /** - * Returns the raw JSON value of [direction]. + * Returns the raw JSON value of [tripIds]. * - * Unlike [direction], this method doesn't throw if the JSON field has an unexpected + * Unlike [tripIds], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("direction") + @JsonProperty("tripIds") @ExcludeMissing - fun _direction(): JsonField = direction + fun _tripIds(): JsonField> = tripIds /** - * Returns the raw JSON value of [wheelchairBoarding]. + * Returns the raw JSON value of [tripsWithStopTimes]. * - * Unlike [wheelchairBoarding], this method doesn't throw if the JSON field has an + * Unlike [tripsWithStopTimes], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("wheelchairBoarding") + @JsonProperty("tripsWithStopTimes") @ExcludeMissing - fun _wheelchairBoarding(): JsonField = wheelchairBoarding + fun _tripsWithStopTimes(): JsonField> = tripsWithStopTimes @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1088,210 +870,155 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Stop]. + * Returns a mutable builder for constructing an instance of [StopTripGrouping]. * * The following fields are required: * ```java - * .id() - * .lat() - * .locationType() - * .lon() - * .name() - * .parent() - * .routeIds() - * .staticRouteIds() + * .directionId() + * .stopIds() + * .tripHeadsigns() + * .tripIds() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Stop]. */ + /** A builder for [StopTripGrouping]. */ class Builder internal constructor() { - private var id: JsonField? = null - private var lat: JsonField? = null - private var locationType: JsonField? = null - private var lon: JsonField? = null - private var name: JsonField? = null - private var parent: JsonField? = null - private var routeIds: JsonField>? = null - private var staticRouteIds: JsonField>? = null - private var code: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var wheelchairBoarding: JsonField = JsonMissing.of() + private var directionId: JsonField? = null + private var stopIds: JsonField>? = null + private var tripHeadsigns: JsonField>? = null + private var tripIds: JsonField>? = null + private var tripsWithStopTimes: JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(stop: Stop) = apply { - id = stop.id - lat = stop.lat - locationType = stop.locationType - lon = stop.lon - name = stop.name - parent = stop.parent - routeIds = stop.routeIds.map { it.toMutableList() } - staticRouteIds = stop.staticRouteIds.map { it.toMutableList() } - code = stop.code - direction = stop.direction - wheelchairBoarding = stop.wheelchairBoarding - additionalProperties = stop.additionalProperties.toMutableMap() + internal fun from(stopTripGrouping: StopTripGrouping) = apply { + directionId = stopTripGrouping.directionId + stopIds = stopTripGrouping.stopIds.map { it.toMutableList() } + tripHeadsigns = stopTripGrouping.tripHeadsigns.map { it.toMutableList() } + tripIds = stopTripGrouping.tripIds.map { it.toMutableList() } + tripsWithStopTimes = + stopTripGrouping.tripsWithStopTimes.map { it.toMutableList() } + additionalProperties = stopTripGrouping.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** - * Sets [Builder.lat] to an arbitrary JSON value. - * - * You should usually call [Builder.lat] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + fun directionId(directionId: String) = directionId(JsonField.of(directionId)) /** - * Sets [Builder.locationType] to an arbitrary JSON value. + * Sets [Builder.directionId] to an arbitrary JSON value. * - * You should usually call [Builder.locationType] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.directionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType + fun directionId(directionId: JsonField) = apply { + this.directionId = directionId } - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** - * Sets [Builder.lon] to an arbitrary JSON value. - * - * You should usually call [Builder.lon] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - /** - * Sets [Builder.parent] to an arbitrary JSON value. - * - * You should usually call [Builder.parent] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) /** - * Sets [Builder.routeIds] to an arbitrary JSON value. + * Sets [Builder.stopIds] to an arbitrary JSON value. * - * You should usually call [Builder.routeIds] with a well-typed `List` + * You should usually call [Builder.stopIds] with a well-typed `List` * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds.map { it.toMutableList() } + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } } /** - * Adds a single [String] to [routeIds]. + * Adds a single [String] to [stopIds]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addRouteId(routeId: String) = apply { - routeIds = - (routeIds ?: JsonField.of(mutableListOf())).also { - checkKnown("routeIds", it).add(routeId) + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) } } - fun staticRouteIds(staticRouteIds: List) = - staticRouteIds(JsonField.of(staticRouteIds)) + fun tripHeadsigns(tripHeadsigns: List) = + tripHeadsigns(JsonField.of(tripHeadsigns)) /** - * Sets [Builder.staticRouteIds] to an arbitrary JSON value. + * Sets [Builder.tripHeadsigns] to an arbitrary JSON value. * - * You should usually call [Builder.staticRouteIds] with a well-typed + * You should usually call [Builder.tripHeadsigns] with a well-typed * `List` value instead. This method is primarily for setting the field * to an undocumented or not yet supported value. */ - fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + fun tripHeadsigns(tripHeadsigns: JsonField>) = apply { + this.tripHeadsigns = tripHeadsigns.map { it.toMutableList() } } /** - * Adds a single [String] to [staticRouteIds]. + * Adds a single [String] to [tripHeadsigns]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addStaticRouteId(staticRouteId: String) = apply { - staticRouteIds = - (staticRouteIds ?: JsonField.of(mutableListOf())).also { - checkKnown("staticRouteIds", it).add(staticRouteId) + fun addTripHeadsign(tripHeadsign: String) = apply { + tripHeadsigns = + (tripHeadsigns ?: JsonField.of(mutableListOf())).also { + checkKnown("tripHeadsigns", it).add(tripHeadsign) } } - fun code(code: String) = code(JsonField.of(code)) + fun tripIds(tripIds: List) = tripIds(JsonField.of(tripIds)) /** - * Sets [Builder.code] to an arbitrary JSON value. + * Sets [Builder.tripIds] to an arbitrary JSON value. * - * You should usually call [Builder.code] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.tripIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) + fun tripIds(tripIds: JsonField>) = apply { + this.tripIds = tripIds.map { it.toMutableList() } + } /** - * Sets [Builder.direction] to an arbitrary JSON value. + * Adds a single [String] to [tripIds]. * - * You should usually call [Builder.direction] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun direction(direction: JsonField) = apply { - this.direction = direction + fun addTripId(tripId: String) = apply { + tripIds = + (tripIds ?: JsonField.of(mutableListOf())).also { + checkKnown("tripIds", it).add(tripId) + } } - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) + fun tripsWithStopTimes(tripsWithStopTimes: List) = + tripsWithStopTimes(JsonField.of(tripsWithStopTimes)) /** - * Sets [Builder.wheelchairBoarding] to an arbitrary JSON value. + * Sets [Builder.tripsWithStopTimes] to an arbitrary JSON value. * - * You should usually call [Builder.wheelchairBoarding] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.tripsWithStopTimes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tripsWithStopTimes(tripsWithStopTimes: JsonField>) = + apply { + this.tripsWithStopTimes = tripsWithStopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [TripsWithStopTime] to [tripsWithStopTimes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { - this.wheelchairBoarding = wheelchairBoarding + fun addTripsWithStopTime(tripsWithStopTime: TripsWithStopTime) = apply { + tripsWithStopTimes = + (tripsWithStopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("tripsWithStopTimes", it).add(tripsWithStopTime) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1317,61 +1044,43 @@ private constructor( } /** - * Returns an immutable instance of [Stop]. + * Returns an immutable instance of [StopTripGrouping]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() - * .lat() - * .locationType() - * .lon() - * .name() - * .parent() - * .routeIds() - * .staticRouteIds() + * .directionId() + * .stopIds() + * .tripHeadsigns() + * .tripIds() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Stop = - Stop( - checkRequired("id", id), - checkRequired("lat", lat), - checkRequired("locationType", locationType), - checkRequired("lon", lon), - checkRequired("name", name), - checkRequired("parent", parent), - checkRequired("routeIds", routeIds).map { it.toImmutable() }, - checkRequired("staticRouteIds", staticRouteIds).map { - it.toImmutable() - }, - code, - direction, - wheelchairBoarding, + fun build(): StopTripGrouping = + StopTripGrouping( + checkRequired("directionId", directionId), + checkRequired("stopIds", stopIds).map { it.toImmutable() }, + checkRequired("tripHeadsigns", tripHeadsigns).map { it.toImmutable() }, + checkRequired("tripIds", tripIds).map { it.toImmutable() }, + (tripsWithStopTimes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Stop = apply { + fun validate(): StopTripGrouping = apply { if (validated) { return@apply } - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - code() - direction() - wheelchairBoarding() + directionId() + stopIds() + tripHeadsigns() + tripIds() + tripsWithStopTimes().ifPresent { it.forEach { it.validate() } } validated = true } @@ -1391,1746 +1100,748 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (lat.asKnown().isPresent) 1 else 0) + - (if (locationType.asKnown().isPresent) 1 else 0) + - (if (lon.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (parent.asKnown().isPresent) 1 else 0) + - (routeIds.asKnown().getOrNull()?.size ?: 0) + - (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + - (if (code.asKnown().isPresent) 1 else 0) + - (if (direction.asKnown().isPresent) 1 else 0) + - (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Stop && - id == other.id && - lat == other.lat && - locationType == other.locationType && - lon == other.lon && - name == other.name && - parent == other.parent && - routeIds == other.routeIds && - staticRouteIds == other.staticRouteIds && - code == other.code && - direction == other.direction && - wheelchairBoarding == other.wheelchairBoarding && - additionalProperties == other.additionalProperties - } + (if (directionId.asKnown().isPresent) 1 else 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) + + (tripHeadsigns.asKnown().getOrNull()?.size ?: 0) + + (tripIds.asKnown().getOrNull()?.size ?: 0) + + (tripsWithStopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) - private val hashCode: Int by lazy { - Objects.hash( - id, - lat, - locationType, - lon, - name, - parent, - routeIds, - staticRouteIds, - code, - direction, - wheelchairBoarding, - additionalProperties, - ) - } + class TripsWithStopTime + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val stopTimes: JsonField>, + private val tripId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + ) : this(stopTimes, tripId, mutableMapOf()) - override fun toString() = - "Stop{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" - } + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun stopTimes(): List = stopTimes.getRequired("stopTimes") - class StopTripGrouping - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val directionId: JsonField, - private val stopIds: JsonField>, - private val tripHeadsigns: JsonField>, - private val tripIds: JsonField>, - private val tripsWithStopTimes: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") - @JsonCreator - private constructor( - @JsonProperty("directionId") - @ExcludeMissing - directionId: JsonField = JsonMissing.of(), - @JsonProperty("stopIds") - @ExcludeMissing - stopIds: JsonField> = JsonMissing.of(), - @JsonProperty("tripHeadsigns") - @ExcludeMissing - tripHeadsigns: JsonField> = JsonMissing.of(), - @JsonProperty("tripIds") - @ExcludeMissing - tripIds: JsonField> = JsonMissing.of(), - @JsonProperty("tripsWithStopTimes") + /** + * Returns the raw JSON value of [stopTimes]. + * + * Unlike [stopTimes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopTimes") @ExcludeMissing - tripsWithStopTimes: JsonField> = JsonMissing.of(), - ) : this( - directionId, - stopIds, - tripHeadsigns, - tripIds, - tripsWithStopTimes, - mutableMapOf(), - ) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun directionId(): String = directionId.getRequired("directionId") + fun _stopTimes(): JsonField> = stopTimes - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun stopIds(): List = stopIds.getRequired("stopIds") + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tripHeadsigns(): List = tripHeadsigns.getRequired("tripHeadsigns") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tripIds(): List = tripIds.getRequired("tripIds") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun tripsWithStopTimes(): Optional> = - tripsWithStopTimes.getOptional("tripsWithStopTimes") + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [directionId]. - * - * Unlike [directionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("directionId") - @ExcludeMissing - fun _directionId(): JsonField = directionId + companion object { - /** - * Returns the raw JSON value of [stopIds]. - * - * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("stopIds") - @ExcludeMissing - fun _stopIds(): JsonField> = stopIds + /** + * Returns a mutable builder for constructing an instance of + * [TripsWithStopTime]. + * + * The following fields are required: + * ```java + * .stopTimes() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [tripHeadsigns]. - * - * Unlike [tripHeadsigns], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tripHeadsigns") - @ExcludeMissing - fun _tripHeadsigns(): JsonField> = tripHeadsigns + /** A builder for [TripsWithStopTime]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [tripIds]. - * - * Unlike [tripIds], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tripIds") - @ExcludeMissing - fun _tripIds(): JsonField> = tripIds + private var stopTimes: JsonField>? = null + private var tripId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [tripsWithStopTimes]. - * - * Unlike [tripsWithStopTimes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tripsWithStopTimes") - @ExcludeMissing - fun _tripsWithStopTimes(): JsonField> = tripsWithStopTimes + @JvmSynthetic + internal fun from(tripsWithStopTime: TripsWithStopTime) = apply { + stopTimes = tripsWithStopTime.stopTimes.map { it.toMutableList() } + tripId = tripsWithStopTime.tripId + additionalProperties = + tripsWithStopTime.additionalProperties.toMutableMap() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun stopTimes(stopTimes: List) = + stopTimes(JsonField.of(stopTimes)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [StopTripGrouping]. - * - * The following fields are required: - * ```java - * .directionId() - * .stopIds() - * .tripHeadsigns() - * .tripIds() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopTripGrouping]. */ - class Builder internal constructor() { - - private var directionId: JsonField? = null - private var stopIds: JsonField>? = null - private var tripHeadsigns: JsonField>? = null - private var tripIds: JsonField>? = null - private var tripsWithStopTimes: JsonField>? = - null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.stopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTimes] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTimes(stopTimes: JsonField>) = apply { + this.stopTimes = stopTimes.map { it.toMutableList() } + } - @JvmSynthetic - internal fun from(stopTripGrouping: StopTripGrouping) = apply { - directionId = stopTripGrouping.directionId - stopIds = stopTripGrouping.stopIds.map { it.toMutableList() } - tripHeadsigns = stopTripGrouping.tripHeadsigns.map { it.toMutableList() } - tripIds = stopTripGrouping.tripIds.map { it.toMutableList() } - tripsWithStopTimes = - stopTripGrouping.tripsWithStopTimes.map { it.toMutableList() } - additionalProperties = stopTripGrouping.additionalProperties.toMutableMap() - } + /** + * Adds a single [StopTime] to [stopTimes]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTimes", it).add(stopTime) + } + } - fun directionId(directionId: String) = directionId(JsonField.of(directionId)) + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - /** - * Sets [Builder.directionId] to an arbitrary JSON value. - * - * You should usually call [Builder.directionId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun directionId(directionId: JsonField) = apply { - this.directionId = directionId - } + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.stopIds] to an arbitrary JSON value. - * - * You should usually call [Builder.stopIds] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stopIds(stopIds: JsonField>) = apply { - this.stopIds = stopIds.map { it.toMutableList() } - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Adds a single [String] to [stopIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addStopId(stopId: String) = apply { - stopIds = - (stopIds ?: JsonField.of(mutableListOf())).also { - checkKnown("stopIds", it).add(stopId) - } - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun tripHeadsigns(tripHeadsigns: List) = - tripHeadsigns(JsonField.of(tripHeadsigns)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.tripHeadsigns] to an arbitrary JSON value. - * - * You should usually call [Builder.tripHeadsigns] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun tripHeadsigns(tripHeadsigns: JsonField>) = apply { - this.tripHeadsigns = tripHeadsigns.map { it.toMutableList() } - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Adds a single [String] to [tripHeadsigns]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTripHeadsign(tripHeadsign: String) = apply { - tripHeadsigns = - (tripHeadsigns ?: JsonField.of(mutableListOf())).also { - checkKnown("tripHeadsigns", it).add(tripHeadsign) - } + /** + * Returns an immutable instance of [TripsWithStopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .stopTimes() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripsWithStopTime = + TripsWithStopTime( + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("tripId", tripId), + additionalProperties.toMutableMap(), + ) } - fun tripIds(tripIds: List) = tripIds(JsonField.of(tripIds)) + private var validated: Boolean = false - /** - * Sets [Builder.tripIds] to an arbitrary JSON value. - * - * You should usually call [Builder.tripIds] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tripIds(tripIds: JsonField>) = apply { - this.tripIds = tripIds.map { it.toMutableList() } - } + fun validate(): TripsWithStopTime = apply { + if (validated) { + return@apply + } - /** - * Adds a single [String] to [tripIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTripId(tripId: String) = apply { - tripIds = - (tripIds ?: JsonField.of(mutableListOf())).also { - checkKnown("tripIds", it).add(tripId) - } + stopTimes().forEach { it.validate() } + tripId() + validated = true } - fun tripsWithStopTimes(tripsWithStopTimes: List) = - tripsWithStopTimes(JsonField.of(tripsWithStopTimes)) - - /** - * Sets [Builder.tripsWithStopTimes] to an arbitrary JSON value. - * - * You should usually call [Builder.tripsWithStopTimes] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun tripsWithStopTimes(tripsWithStopTimes: JsonField>) = - apply { - this.tripsWithStopTimes = tripsWithStopTimes.map { it.toMutableList() } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false } /** - * Adds a single [TripsWithStopTime] to [tripsWithStopTimes]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Used for best match union deserialization. */ - fun addTripsWithStopTime(tripsWithStopTime: TripsWithStopTime) = apply { - tripsWithStopTimes = - (tripsWithStopTimes ?: JsonField.of(mutableListOf())).also { - checkKnown("tripsWithStopTimes", it).add(tripsWithStopTime) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmSynthetic + internal fun validity(): Int = + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (tripId.asKnown().isPresent) 1 else 0) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + class StopTime + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arrivalEnabled: JsonField, + private val arrivalTime: JsonField, + private val departureEnabled: JsonField, + private val departureTime: JsonField, + private val stopId: JsonField, + private val tripId: JsonField, + private val serviceId: JsonField, + private val stopHeadsign: JsonField, + private val additionalProperties: MutableMap, + ) { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [StopTripGrouping]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .directionId() - * .stopIds() - * .tripHeadsigns() - * .tripIds() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): StopTripGrouping = - StopTripGrouping( - checkRequired("directionId", directionId), - checkRequired("stopIds", stopIds).map { it.toImmutable() }, - checkRequired("tripHeadsigns", tripHeadsigns).map { it.toImmutable() }, - checkRequired("tripIds", tripIds).map { it.toImmutable() }, - (tripsWithStopTimes ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), + @JsonCreator + private constructor( + @JsonProperty("arrivalEnabled") + @ExcludeMissing + arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + arrivalTime, + departureEnabled, + departureTime, + stopId, + tripId, + serviceId, + stopHeadsign, + mutableMapOf(), ) - } - - private var validated: Boolean = false - - fun validate(): StopTripGrouping = apply { - if (validated) { - return@apply - } - - directionId() - stopIds() - tripHeadsigns() - tripIds() - tripsWithStopTimes().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OnebusawaySdkInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (directionId.asKnown().isPresent) 1 else 0) + - (stopIds.asKnown().getOrNull()?.size ?: 0) + - (tripHeadsigns.asKnown().getOrNull()?.size ?: 0) + - (tripIds.asKnown().getOrNull()?.size ?: 0) + - (tripsWithStopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) - - class TripsWithStopTime - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val stopTimes: JsonField>, - private val tripId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("stopTimes") - @ExcludeMissing - stopTimes: JsonField> = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - tripId: JsonField = JsonMissing.of(), - ) : this(stopTimes, tripId, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tripId(): String = tripId.getRequired("tripId") - - /** - * Returns the raw JSON value of [stopTimes]. - * - * Unlike [stopTimes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("stopTimes") - @ExcludeMissing - fun _stopTimes(): JsonField> = stopTimes - - /** - * Returns the raw JSON value of [tripId]. - * - * Unlike [tripId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tripId") - @ExcludeMissing - fun _tripId(): JsonField = tripId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - fun toBuilder() = Builder().from(this) + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") - companion object { + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun departureEnabled(): Boolean = + departureEnabled.getRequired("departureEnabled") /** - * Returns a mutable builder for constructing an instance of - * [TripsWithStopTime]. - * - * The following fields are required: - * ```java - * .stopTimes() - * .tripId() - * ``` + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). */ - @JvmStatic fun builder() = Builder() - } + fun departureTime(): Long = departureTime.getRequired("departureTime") - /** A builder for [TripsWithStopTime]. */ - class Builder internal constructor() { + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun stopId(): String = stopId.getRequired("stopId") - private var stopTimes: JsonField>? = null - private var tripId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") - @JvmSynthetic - internal fun from(tripsWithStopTime: TripsWithStopTime) = apply { - stopTimes = tripsWithStopTime.stopTimes.map { it.toMutableList() } - tripId = tripsWithStopTime.tripId - additionalProperties = - tripsWithStopTime.additionalProperties.toMutableMap() - } + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun serviceId(): Optional = serviceId.getOptional("serviceId") - fun stopTimes(stopTimes: List) = - stopTimes(JsonField.of(stopTimes)) + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun stopHeadsign(): Optional = + stopHeadsign.getOptional("stopHeadsign") /** - * Sets [Builder.stopTimes] to an arbitrary JSON value. + * Returns the raw JSON value of [arrivalEnabled]. * - * You should usually call [Builder.stopTimes] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes.map { it.toMutableList() } - } + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled /** - * Adds a single [StopTime] to [stopTimes]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addStopTime(stopTime: StopTime) = apply { - stopTimes = - (stopTimes ?: JsonField.of(mutableListOf())).also { - checkKnown("stopTimes", it).add(stopTime) - } - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - /** - * Sets [Builder.tripId] to an arbitrary JSON value. - * - * You should usually call [Builder.tripId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TripsWithStopTime]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .stopTimes() - * .tripId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TripsWithStopTime = - TripsWithStopTime( - checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, - checkRequired("tripId", tripId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TripsWithStopTime = apply { - if (validated) { - return@apply - } - - stopTimes().forEach { it.validate() } - tripId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OnebusawaySdkInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (tripId.asKnown().isPresent) 1 else 0) - - class StopTime - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val arrivalEnabled: JsonField, - private val arrivalTime: JsonField, - private val departureEnabled: JsonField, - private val departureTime: JsonField, - private val stopId: JsonField, - private val tripId: JsonField, - private val serviceId: JsonField, - private val stopHeadsign: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("arrivalEnabled") - @ExcludeMissing - arrivalEnabled: JsonField = JsonMissing.of(), - @JsonProperty("arrivalTime") - @ExcludeMissing - arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureEnabled") - @ExcludeMissing - departureEnabled: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - departureTime: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - stopId: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - tripId: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - serviceId: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - stopHeadsign: JsonField = JsonMissing.of(), - ) : this( - arrivalEnabled, - arrivalTime, - departureEnabled, - departureTime, - stopId, - tripId, - serviceId, - stopHeadsign, - mutableMapOf(), - ) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the server - * responded with an unexpected value). - */ - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the server - * responded with an unexpected value). - */ - fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the server - * responded with an unexpected value). - */ - fun departureEnabled(): Boolean = - departureEnabled.getRequired("departureEnabled") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the server - * responded with an unexpected value). - */ - fun departureTime(): Long = departureTime.getRequired("departureTime") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the server - * responded with an unexpected value). - */ - fun stopId(): String = stopId.getRequired("stopId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the server - * responded with an unexpected value). - */ - fun tripId(): String = tripId.getRequired("tripId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun serviceId(): Optional = serviceId.getOptional("serviceId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun stopHeadsign(): Optional = - stopHeadsign.getOptional("stopHeadsign") - - /** - * Returns the raw JSON value of [arrivalEnabled]. - * - * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun _arrivalEnabled(): JsonField = arrivalEnabled - - /** - * Returns the raw JSON value of [arrivalTime]. + * Returns the raw JSON value of [arrivalTime]. * * Unlike [arrivalTime], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("arrivalTime") @ExcludeMissing - fun _arrivalTime(): JsonField = arrivalTime - - /** - * Returns the raw JSON value of [departureEnabled]. - * - * Unlike [departureEnabled], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled(): JsonField = departureEnabled - - /** - * Returns the raw JSON value of [departureTime]. - * - * Unlike [departureTime], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime(): JsonField = departureTime - - /** - * Returns the raw JSON value of [stopId]. - * - * Unlike [stopId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("stopId") - @ExcludeMissing - fun _stopId(): JsonField = stopId - - /** - * Returns the raw JSON value of [tripId]. - * - * Unlike [tripId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tripId") - @ExcludeMissing - fun _tripId(): JsonField = tripId - - /** - * Returns the raw JSON value of [serviceId]. - * - * Unlike [serviceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("serviceId") - @ExcludeMissing - fun _serviceId(): JsonField = serviceId - - /** - * Returns the raw JSON value of [stopHeadsign]. - * - * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign(): JsonField = stopHeadsign - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [StopTime]. - * - * The following fields are required: - * ```java - * .arrivalEnabled() - * .arrivalTime() - * .departureEnabled() - * .departureTime() - * .stopId() - * .tripId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopTime]. */ - class Builder internal constructor() { - - private var arrivalEnabled: JsonField? = null - private var arrivalTime: JsonField? = null - private var departureEnabled: JsonField? = null - private var departureTime: JsonField? = null - private var stopId: JsonField? = null - private var tripId: JsonField? = null - private var serviceId: JsonField = JsonMissing.of() - private var stopHeadsign: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopTime: StopTime) = apply { - arrivalEnabled = stopTime.arrivalEnabled - arrivalTime = stopTime.arrivalTime - departureEnabled = stopTime.departureEnabled - departureTime = stopTime.departureTime - stopId = stopTime.stopId - tripId = stopTime.tripId - serviceId = stopTime.serviceId - stopHeadsign = stopTime.stopHeadsign - additionalProperties = stopTime.additionalProperties.toMutableMap() - } - - fun arrivalEnabled(arrivalEnabled: Boolean) = - arrivalEnabled(JsonField.of(arrivalEnabled)) - - /** - * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. - * - * You should usually call [Builder.arrivalEnabled] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun arrivalEnabled(arrivalEnabled: JsonField) = apply { - this.arrivalEnabled = arrivalEnabled - } - - fun arrivalTime(arrivalTime: Long) = - arrivalTime(JsonField.of(arrivalTime)) - - /** - * Sets [Builder.arrivalTime] to an arbitrary JSON value. - * - * You should usually call [Builder.arrivalTime] with a well-typed - * [Long] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureEnabled(departureEnabled: Boolean) = - departureEnabled(JsonField.of(departureEnabled)) - - /** - * Sets [Builder.departureEnabled] to an arbitrary JSON value. - * - * You should usually call [Builder.departureEnabled] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun departureEnabled(departureEnabled: JsonField) = apply { - this.departureEnabled = departureEnabled - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - /** - * Sets [Builder.departureTime] to an arbitrary JSON value. - * - * You should usually call [Builder.departureTime] with a well-typed - * [Long] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - /** - * Sets [Builder.stopId] to an arbitrary JSON value. - * - * You should usually call [Builder.stopId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - /** - * Sets [Builder.tripId] to an arbitrary JSON value. - * - * You should usually call [Builder.tripId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - /** - * Sets [Builder.serviceId] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceId] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - /** - * Sets [Builder.stopHeadsign] to an arbitrary JSON value. - * - * You should usually call [Builder.stopHeadsign] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [StopTime]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .arrivalEnabled() - * .arrivalTime() - * .departureEnabled() - * .departureTime() - * .stopId() - * .tripId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): StopTime = - StopTime( - checkRequired("arrivalEnabled", arrivalEnabled), - checkRequired("arrivalTime", arrivalTime), - checkRequired("departureEnabled", departureEnabled), - checkRequired("departureTime", departureTime), - checkRequired("stopId", stopId), - checkRequired("tripId", tripId), - serviceId, - stopHeadsign, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): StopTime = apply { - if (validated) { - return@apply - } - - arrivalEnabled() - arrivalTime() - departureEnabled() - departureTime() - stopId() - tripId() - serviceId() - stopHeadsign() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OnebusawaySdkInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + - (if (arrivalTime.asKnown().isPresent) 1 else 0) + - (if (departureEnabled.asKnown().isPresent) 1 else 0) + - (if (departureTime.asKnown().isPresent) 1 else 0) + - (if (stopId.asKnown().isPresent) 1 else 0) + - (if (tripId.asKnown().isPresent) 1 else 0) + - (if (serviceId.asKnown().isPresent) 1 else 0) + - (if (stopHeadsign.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StopTime && - arrivalEnabled == other.arrivalEnabled && - arrivalTime == other.arrivalTime && - departureEnabled == other.departureEnabled && - departureTime == other.departureTime && - stopId == other.stopId && - tripId == other.tripId && - serviceId == other.serviceId && - stopHeadsign == other.stopHeadsign && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - arrivalEnabled, - arrivalTime, - departureEnabled, - departureTime, - stopId, - tripId, - serviceId, - stopHeadsign, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, stopId=$stopId, tripId=$tripId, serviceId=$serviceId, stopHeadsign=$stopHeadsign, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TripsWithStopTime && - stopTimes == other.stopTimes && - tripId == other.tripId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(stopTimes, tripId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TripsWithStopTime{stopTimes=$stopTimes, tripId=$tripId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StopTripGrouping && - directionId == other.directionId && - stopIds == other.stopIds && - tripHeadsigns == other.tripHeadsigns && - tripIds == other.tripIds && - tripsWithStopTimes == other.tripsWithStopTimes && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - directionId, - stopIds, - tripHeadsigns, - tripIds, - tripsWithStopTimes, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" - } - - class Trip - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val routeId: JsonField, - private val serviceId: JsonField, - private val blockId: JsonField, - private val directionId: JsonField, - private val peakOffpeak: JsonField, - private val routeShortName: JsonField, - private val shapeId: JsonField, - private val timeZone: JsonField, - private val tripHeadsign: JsonField, - private val tripShortName: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - routeId: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - serviceId: JsonField = JsonMissing.of(), - @JsonProperty("blockId") - @ExcludeMissing - blockId: JsonField = JsonMissing.of(), - @JsonProperty("directionId") - @ExcludeMissing - directionId: JsonField = JsonMissing.of(), - @JsonProperty("peakOffpeak") - @ExcludeMissing - peakOffpeak: JsonField = JsonMissing.of(), - @JsonProperty("routeShortName") - @ExcludeMissing - routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shapeId") - @ExcludeMissing - shapeId: JsonField = JsonMissing.of(), - @JsonProperty("timeZone") - @ExcludeMissing - timeZone: JsonField = JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("tripShortName") - @ExcludeMissing - tripShortName: JsonField = JsonMissing.of(), - ) : this( - id, - routeId, - serviceId, - blockId, - directionId, - peakOffpeak, - routeShortName, - shapeId, - timeZone, - tripHeadsign, - tripShortName, - mutableMapOf(), - ) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun routeId(): String = routeId.getRequired("routeId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceId(): String = serviceId.getRequired("serviceId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun blockId(): Optional = blockId.getOptional("blockId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun directionId(): Optional = directionId.getOptional("directionId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun peakOffpeak(): Optional = peakOffpeak.getOptional("peakOffpeak") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun routeShortName(): Optional = - routeShortName.getOptional("routeShortName") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun shapeId(): Optional = shapeId.getOptional("shapeId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun timeZone(): Optional = timeZone.getOptional("timeZone") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun tripHeadsign(): Optional = tripHeadsign.getOptional("tripHeadsign") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun tripShortName(): Optional = tripShortName.getOptional("tripShortName") + fun _arrivalTime(): JsonField = arrivalTime - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [departureEnabled]. + * + * Unlike [departureEnabled], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("departureEnabled") + @ExcludeMissing + fun _departureEnabled(): JsonField = departureEnabled - /** - * Returns the raw JSON value of [routeId]. - * - * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime - /** - * Returns the raw JSON value of [serviceId]. - * - * Unlike [serviceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("serviceId") - @ExcludeMissing - fun _serviceId(): JsonField = serviceId + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId - /** - * Returns the raw JSON value of [blockId]. - * - * Unlike [blockId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("blockId") @ExcludeMissing fun _blockId(): JsonField = blockId + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId - /** - * Returns the raw JSON value of [directionId]. - * - * Unlike [directionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("directionId") - @ExcludeMissing - fun _directionId(): JsonField = directionId + /** + * Returns the raw JSON value of [serviceId]. + * + * Unlike [serviceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId - /** - * Returns the raw JSON value of [peakOffpeak]. - * - * Unlike [peakOffpeak], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("peakOffpeak") - @ExcludeMissing - fun _peakOffpeak(): JsonField = peakOffpeak + /** + * Returns the raw JSON value of [stopHeadsign]. + * + * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign - /** - * Returns the raw JSON value of [routeShortName]. - * - * Unlike [routeShortName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("routeShortName") - @ExcludeMissing - fun _routeShortName(): JsonField = routeShortName + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [shapeId]. - * - * Unlike [shapeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [timeZone]. - * - * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("timeZone") - @ExcludeMissing - fun _timeZone(): JsonField = timeZone + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [tripHeadsign]. - * - * Unlike [tripHeadsign], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun _tripHeadsign(): JsonField = tripHeadsign + companion object { - /** - * Returns the raw JSON value of [tripShortName]. - * - * Unlike [tripShortName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tripShortName") - @ExcludeMissing - fun _tripShortName(): JsonField = tripShortName + /** + * Returns a mutable builder for constructing an instance of [StopTime]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .stopId() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** A builder for [StopTime]. */ + class Builder internal constructor() { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var arrivalEnabled: JsonField? = null + private var arrivalTime: JsonField? = null + private var departureEnabled: JsonField? = null + private var departureTime: JsonField? = null + private var stopId: JsonField? = null + private var tripId: JsonField? = null + private var serviceId: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun toBuilder() = Builder().from(this) + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalEnabled = stopTime.arrivalEnabled + arrivalTime = stopTime.arrivalTime + departureEnabled = stopTime.departureEnabled + departureTime = stopTime.departureTime + stopId = stopTime.stopId + tripId = stopTime.tripId + serviceId = stopTime.serviceId + stopHeadsign = stopTime.stopHeadsign + additionalProperties = stopTime.additionalProperties.toMutableMap() + } - companion object { + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) - /** - * Returns a mutable builder for constructing an instance of [Trip]. - * - * The following fields are required: - * ```java - * .id() - * .routeId() - * .serviceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun arrivalEnabled(arrivalEnabled: JsonField) = apply { + this.arrivalEnabled = arrivalEnabled + } - /** A builder for [Trip]. */ - class Builder internal constructor() { + fun arrivalTime(arrivalTime: Long) = + arrivalTime(JsonField.of(arrivalTime)) - private var id: JsonField? = null - private var routeId: JsonField? = null - private var serviceId: JsonField? = null - private var blockId: JsonField = JsonMissing.of() - private var directionId: JsonField = JsonMissing.of() - private var peakOffpeak: JsonField = JsonMissing.of() - private var routeShortName: JsonField = JsonMissing.of() - private var shapeId: JsonField = JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() - private var tripShortName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } - @JvmSynthetic - internal fun from(trip: Trip) = apply { - id = trip.id - routeId = trip.routeId - serviceId = trip.serviceId - blockId = trip.blockId - directionId = trip.directionId - peakOffpeak = trip.peakOffpeak - routeShortName = trip.routeShortName - shapeId = trip.shapeId - timeZone = trip.timeZone - tripHeadsign = trip.tripHeadsign - tripShortName = trip.tripShortName - additionalProperties = trip.additionalProperties.toMutableMap() - } + fun departureEnabled(departureEnabled: Boolean) = + departureEnabled(JsonField.of(departureEnabled)) - fun id(id: String) = id(JsonField.of(id)) + /** + * Sets [Builder.departureEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.departureEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun departureEnabled(departureEnabled: JsonField) = apply { + this.departureEnabled = departureEnabled + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } - /** - * Sets [Builder.routeId] to an arbitrary JSON value. - * - * You should usually call [Builder.routeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - /** - * Sets [Builder.serviceId] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - /** - * Sets [Builder.blockId] to an arbitrary JSON value. - * - * You should usually call [Builder.blockId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - fun directionId(directionId: String) = directionId(JsonField.of(directionId)) + /** + * Sets [Builder.serviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun serviceId(serviceId: JsonField) = apply { + this.serviceId = serviceId + } - /** - * Sets [Builder.directionId] to an arbitrary JSON value. - * - * You should usually call [Builder.directionId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun directionId(directionId: JsonField) = apply { - this.directionId = directionId - } + fun stopHeadsign(stopHeadsign: String) = + stopHeadsign(JsonField.of(stopHeadsign)) - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) + /** + * Sets [Builder.stopHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.stopHeadsign] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopHeadsign(stopHeadsign: JsonField) = apply { + this.stopHeadsign = stopHeadsign + } - /** - * Sets [Builder.peakOffpeak] to an arbitrary JSON value. - * - * You should usually call [Builder.peakOffpeak] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun peakOffpeak(peakOffpeak: JsonField) = apply { - this.peakOffpeak = peakOffpeak - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun routeShortName(routeShortName: String) = - routeShortName(JsonField.of(routeShortName)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.routeShortName] to an arbitrary JSON value. - * - * You should usually call [Builder.routeShortName] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.shapeId] to an arbitrary JSON value. - * - * You should usually call [Builder.shapeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .stopId() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopTime = + StopTime( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureEnabled", departureEnabled), + checkRequired("departureTime", departureTime), + checkRequired("stopId", stopId), + checkRequired("tripId", tripId), + serviceId, + stopHeadsign, + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.timeZone] to an arbitrary JSON value. - * - * You should usually call [Builder.timeZone] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + private var validated: Boolean = false - fun tripHeadsign(tripHeadsign: String) = - tripHeadsign(JsonField.of(tripHeadsign)) + fun validate(): StopTime = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.tripHeadsign] to an arbitrary JSON value. - * - * You should usually call [Builder.tripHeadsign] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } + arrivalEnabled() + arrivalTime() + departureEnabled() + departureTime() + stopId() + tripId() + serviceId() + stopHeadsign() + validated = true + } - fun tripShortName(tripShortName: String) = - tripShortName(JsonField.of(tripShortName)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } - /** - * Sets [Builder.tripShortName] to an arbitrary JSON value. - * - * You should usually call [Builder.tripShortName] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tripShortName(tripShortName: JsonField) = apply { - this.tripShortName = tripShortName - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureEnabled.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + return other is StopTime && + arrivalEnabled == other.arrivalEnabled && + arrivalTime == other.arrivalTime && + departureEnabled == other.departureEnabled && + departureTime == other.departureTime && + stopId == other.stopId && + tripId == other.tripId && + serviceId == other.serviceId && + stopHeadsign == other.stopHeadsign && + additionalProperties == other.additionalProperties + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + private val hashCode: Int by lazy { + Objects.hash( + arrivalEnabled, + arrivalTime, + departureEnabled, + departureTime, + stopId, + tripId, + serviceId, + stopHeadsign, + additionalProperties, + ) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun hashCode(): Int = hashCode - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun toString() = + "StopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, stopId=$stopId, tripId=$tripId, serviceId=$serviceId, stopHeadsign=$stopHeadsign, additionalProperties=$additionalProperties}" } - /** - * Returns an immutable instance of [Trip]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .routeId() - * .serviceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Trip = - Trip( - checkRequired("id", id), - checkRequired("routeId", routeId), - checkRequired("serviceId", serviceId), - blockId, - directionId, - peakOffpeak, - routeShortName, - shapeId, - timeZone, - tripHeadsign, - tripShortName, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Trip = apply { - if (validated) { - return@apply + return other is TripsWithStopTime && + stopTimes == other.stopTimes && + tripId == other.tripId && + additionalProperties == other.additionalProperties } - id() - routeId() - serviceId() - blockId() - directionId() - peakOffpeak() - routeShortName() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OnebusawaySdkInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(stopTimes, tripId, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (routeId.asKnown().isPresent) 1 else 0) + - (if (serviceId.asKnown().isPresent) 1 else 0) + - (if (blockId.asKnown().isPresent) 1 else 0) + - (if (directionId.asKnown().isPresent) 1 else 0) + - (if (peakOffpeak.asKnown().isPresent) 1 else 0) + - (if (routeShortName.asKnown().isPresent) 1 else 0) + - (if (shapeId.asKnown().isPresent) 1 else 0) + - (if (timeZone.asKnown().isPresent) 1 else 0) + - (if (tripHeadsign.asKnown().isPresent) 1 else 0) + - (if (tripShortName.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripsWithStopTime{stopTimes=$stopTimes, tripId=$tripId, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Trip && - id == other.id && - routeId == other.routeId && - serviceId == other.serviceId && - blockId == other.blockId && + return other is StopTripGrouping && directionId == other.directionId && - peakOffpeak == other.peakOffpeak && - routeShortName == other.routeShortName && - shapeId == other.shapeId && - timeZone == other.timeZone && - tripHeadsign == other.tripHeadsign && - tripShortName == other.tripShortName && + stopIds == other.stopIds && + tripHeadsigns == other.tripHeadsigns && + tripIds == other.tripIds && + tripsWithStopTimes == other.tripsWithStopTimes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, - routeId, - serviceId, - blockId, directionId, - peakOffpeak, - routeShortName, - shapeId, - timeZone, - tripHeadsign, - tripShortName, + stopIds, + tripHeadsigns, + tripIds, + tripsWithStopTimes, additionalProperties, ) } @@ -3138,7 +1849,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Trip{id=$id, routeId=$routeId, serviceId=$serviceId, blockId=$blockId, directionId=$directionId, peakOffpeak=$peakOffpeak, routeShortName=$routeShortName, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" + "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3150,9 +1861,7 @@ private constructor( routeId == other.routeId && scheduleDate == other.scheduleDate && serviceIds == other.serviceIds && - stops == other.stops && stopTripGroupings == other.stopTripGroupings && - trips == other.trips && additionalProperties == other.additionalProperties } @@ -3161,9 +1870,7 @@ private constructor( routeId, scheduleDate, serviceIds, - stops, stopTripGroupings, - trips, additionalProperties, ) } @@ -3171,7 +1878,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stops=$stops, stopTripGroupings=$stopTripGroupings, trips=$trips, additionalProperties=$additionalProperties}" + "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stopTripGroupings=$stopTripGroupings, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt index 910a451..a896858 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt @@ -28,10 +28,7 @@ private constructor( private val currentTime: JsonField, private val text: JsonField, private val version: JsonField, - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val outOfRange: JsonField, + private val data: JsonField, private val additionalProperties: MutableMap, ) { @@ -43,29 +40,8 @@ private constructor( currentTime: JsonField = JsonMissing.of(), @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - references: JsonField = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - outOfRange: JsonField = JsonMissing.of(), - ) : this( - code, - currentTime, - text, - version, - limitExceeded, - list, - references, - outOfRange, - mutableMapOf(), - ) + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) fun toResponseWrapper(): ResponseWrapper = ResponseWrapper.builder() @@ -103,25 +79,7 @@ private constructor( * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun list(): kotlin.collections.List = list.getRequired("list") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun references(): References = references.getRequired("references") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") + fun data(): Data = data.getRequired("data") /** * Returns the raw JSON value of [code]. @@ -152,38 +110,11 @@ private constructor( @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - /** - * Returns the raw JSON value of [list]. - * - * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - /** - * Returns the raw JSON value of [references]. - * - * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - /** - * Returns the raw JSON value of [outOfRange]. + * Returns the raw JSON value of [data]. * - * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange(): JsonField = outOfRange + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -208,9 +139,7 @@ private constructor( * .currentTime() * .text() * .version() - * .limitExceeded() - * .list() - * .references() + * .data() * ``` */ @JvmStatic fun builder() = Builder() @@ -223,10 +152,7 @@ private constructor( private var currentTime: JsonField? = null private var text: JsonField? = null private var version: JsonField? = null - private var limitExceeded: JsonField? = null - private var list: JsonField>? = null - private var references: JsonField? = null - private var outOfRange: JsonField = JsonMissing.of() + private var data: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -235,10 +161,7 @@ private constructor( currentTime = stopsForAgencyListResponse.currentTime text = stopsForAgencyListResponse.text version = stopsForAgencyListResponse.version - limitExceeded = stopsForAgencyListResponse.limitExceeded - list = stopsForAgencyListResponse.list.map { it.toMutableList() } - references = stopsForAgencyListResponse.references - outOfRange = stopsForAgencyListResponse.outOfRange + data = stopsForAgencyListResponse.data additionalProperties = stopsForAgencyListResponse.additionalProperties.toMutableMap() } @@ -283,64 +206,15 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + fun data(data: Data) = data(JsonField.of(data)) /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * Sets [Builder.data] to an arbitrary JSON value. * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - /** - * Sets [Builder.list] to an arbitrary JSON value. - * - * You should usually call [Builder.list] with a well-typed `List` value instead. This + * You should usually call [Builder.data] with a well-typed [Data] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - /** - * Adds a single [List] to [Builder.list]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).also { - checkKnown("list", it).add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - /** - * Sets [Builder.references] to an arbitrary JSON value. - * - * You should usually call [Builder.references] with a well-typed [References] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun references(references: JsonField) = apply { this.references = references } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - /** - * Sets [Builder.outOfRange] to an arbitrary JSON value. - * - * You should usually call [Builder.outOfRange] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -372,9 +246,7 @@ private constructor( * .currentTime() * .text() * .version() - * .limitExceeded() - * .list() - * .references() + * .data() * ``` * * @throws IllegalStateException if any required field is unset. @@ -385,10 +257,7 @@ private constructor( checkRequired("currentTime", currentTime), checkRequired("text", text), checkRequired("version", version), - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - outOfRange, + checkRequired("data", data), additionalProperties.toMutableMap(), ) } @@ -404,10 +273,7 @@ private constructor( currentTime() text() version() - limitExceeded() - list().forEach { it.validate() } - references().validate() - outOfRange() + data().validate() validated = true } @@ -430,221 +296,90 @@ private constructor( (if (currentTime.asKnown().isPresent) 1 else 0) + (if (text.asKnown().isPresent) 1 else 0) + (if (version.asKnown().isPresent) 1 else 0) + - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + - (if (outOfRange.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) - class List + class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, - private val lat: JsonField, - private val locationType: JsonField, - private val lon: JsonField, - private val name: JsonField, - private val parent: JsonField, - private val routeIds: JsonField>, - private val staticRouteIds: JsonField>, - private val code: JsonField, - private val direction: JsonField, - private val wheelchairBoarding: JsonField, + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: JsonField, + private val outOfRange: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - locationType: JsonField = JsonMissing.of(), - @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("parent") @ExcludeMissing parent: JsonField = JsonMissing.of(), - @JsonProperty("routeIds") - @ExcludeMissing - routeIds: JsonField> = JsonMissing.of(), - @JsonProperty("staticRouteIds") + @JsonProperty("limitExceeded") @ExcludeMissing - staticRouteIds: JsonField> = JsonMissing.of(), - @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), - @JsonProperty("direction") + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), + @JsonProperty("references") @ExcludeMissing - direction: JsonField = JsonMissing.of(), - @JsonProperty("wheelchairBoarding") + references: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") @ExcludeMissing - wheelchairBoarding: JsonField = JsonMissing.of(), - ) : this( - id, - lat, - locationType, - lon, - name, - parent, - routeIds, - staticRouteIds, - code, - direction, - wheelchairBoarding, - mutableMapOf(), - ) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lat(): Double = lat.getRequired("lat") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun locationType(): Long = locationType.getRequired("locationType") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lon(): Double = lon.getRequired("lon") + outOfRange: JsonField = JsonMissing.of(), + ) : this(limitExceeded, list, references, outOfRange, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun name(): String = name.getRequired("name") + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun parent(): String = parent.getRequired("parent") + fun list(): List = list.getRequired("list") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun staticRouteIds(): kotlin.collections.List = - staticRouteIds.getRequired("staticRouteIds") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun code(): Optional = code.getOptional("code") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun direction(): Optional = direction.getOptional("direction") + fun references(): References = references.getRequired("references") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun wheelchairBoarding(): Optional = - wheelchairBoarding.getOptional("wheelchairBoarding") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [lat]. - * - * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") /** - * Returns the raw JSON value of [locationType]. + * Returns the raw JSON value of [limitExceeded]. * - * Unlike [locationType], this method doesn't throw if the JSON field has an unexpected + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("locationType") + @JsonProperty("limitExceeded") @ExcludeMissing - fun _locationType(): JsonField = locationType - - /** - * Returns the raw JSON value of [lon]. - * - * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [parent]. - * - * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + fun _limitExceeded(): JsonField = limitExceeded /** - * Returns the raw JSON value of [routeIds]. + * Returns the raw JSON value of [list]. * - * Unlike [routeIds], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("routeIds") - @ExcludeMissing - fun _routeIds(): JsonField> = routeIds + @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list /** - * Returns the raw JSON value of [staticRouteIds]. + * Returns the raw JSON value of [references]. * - * Unlike [staticRouteIds], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("staticRouteIds") + @JsonProperty("references") @ExcludeMissing - fun _staticRouteIds(): JsonField> = staticRouteIds - - /** - * Returns the raw JSON value of [code]. - * - * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - /** - * Returns the raw JSON value of [direction]. - * - * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("direction") @ExcludeMissing fun _direction(): JsonField = direction + fun _references(): JsonField = references /** - * Returns the raw JSON value of [wheelchairBoarding]. + * Returns the raw JSON value of [outOfRange]. * - * Unlike [wheelchairBoarding], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("wheelchairBoarding") + @JsonProperty("outOfRange") @ExcludeMissing - fun _wheelchairBoarding(): JsonField = wheelchairBoarding + fun _outOfRange(): JsonField = outOfRange @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -661,210 +396,97 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [List]. + * Returns a mutable builder for constructing an instance of [Data]. * * The following fields are required: * ```java - * .id() - * .lat() - * .locationType() - * .lon() - * .name() - * .parent() - * .routeIds() - * .staticRouteIds() + * .limitExceeded() + * .list() + * .references() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [List]. */ + /** A builder for [Data]. */ class Builder internal constructor() { - private var id: JsonField? = null - private var lat: JsonField? = null - private var locationType: JsonField? = null - private var lon: JsonField? = null - private var name: JsonField? = null - private var parent: JsonField? = null - private var routeIds: JsonField>? = null - private var staticRouteIds: JsonField>? = null - private var code: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var wheelchairBoarding: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null + private var outOfRange: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(list: List) = apply { - id = list.id - lat = list.lat - locationType = list.locationType - lon = list.lon - name = list.name - parent = list.parent - routeIds = list.routeIds.map { it.toMutableList() } - staticRouteIds = list.staticRouteIds.map { it.toMutableList() } - code = list.code - direction = list.direction - wheelchairBoarding = list.wheelchairBoarding - additionalProperties = list.additionalProperties.toMutableMap() + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + outOfRange = data.outOfRange + additionalProperties = data.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - /** - * Sets [Builder.lat] to an arbitrary JSON value. - * - * You should usually call [Builder.lat] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) /** - * Sets [Builder.locationType] to an arbitrary JSON value. + * Sets [Builder.limitExceeded] to an arbitrary JSON value. * - * You should usually call [Builder.locationType] with a well-typed [Long] value + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded } - fun lon(lon: Double) = lon(JsonField.of(lon)) - - /** - * Sets [Builder.lon] to an arbitrary JSON value. - * - * You should usually call [Builder.lon] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) + fun list(list: List) = list(JsonField.of(list)) /** - * Sets [Builder.parent] to an arbitrary JSON value. + * Sets [Builder.list] to an arbitrary JSON value. * - * You should usually call [Builder.parent] with a well-typed [String] value instead. + * You should usually call [Builder.list] with a well-typed `List` value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: kotlin.collections.List) = - routeIds(JsonField.of(routeIds)) - - /** - * Sets [Builder.routeIds] to an arbitrary JSON value. - * - * You should usually call [Builder.routeIds] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [routeIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRouteId(routeId: String) = apply { - routeIds = - (routeIds ?: JsonField.of(mutableListOf())).also { - checkKnown("routeIds", it).add(routeId) - } - } - - fun staticRouteIds(staticRouteIds: kotlin.collections.List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - /** - * Sets [Builder.staticRouteIds] to an arbitrary JSON value. - * - * You should usually call [Builder.staticRouteIds] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } } /** - * Adds a single [String] to [staticRouteIds]. + * Adds a single [List] to [Builder.list]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addStaticRouteId(staticRouteId: String) = apply { - staticRouteIds = - (staticRouteIds ?: JsonField.of(mutableListOf())).also { - checkKnown("staticRouteIds", it).add(staticRouteId) + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).also { + checkKnown("list", it).add(list) } } - fun code(code: String) = code(JsonField.of(code)) + fun references(references: References) = references(JsonField.of(references)) /** - * Sets [Builder.code] to an arbitrary JSON value. + * Sets [Builder.references] to an arbitrary JSON value. * - * You should usually call [Builder.code] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - /** - * Sets [Builder.direction] to an arbitrary JSON value. - * - * You should usually call [Builder.direction] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun direction(direction: JsonField) = apply { this.direction = direction } + fun references(references: JsonField) = apply { + this.references = references + } - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) /** - * Sets [Builder.wheelchairBoarding] to an arbitrary JSON value. + * Sets [Builder.outOfRange] to an arbitrary JSON value. * - * You should usually call [Builder.wheelchairBoarding] with a well-typed [String] value + * You should usually call [Builder.outOfRange] with a well-typed [Boolean] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { - this.wheelchairBoarding = wheelchairBoarding - } + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -886,59 +508,40 @@ private constructor( } /** - * Returns an immutable instance of [List]. + * Returns an immutable instance of [Data]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() - * .lat() - * .locationType() - * .lon() - * .name() - * .parent() - * .routeIds() - * .staticRouteIds() + * .limitExceeded() + * .list() + * .references() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): List = - List( - checkRequired("id", id), - checkRequired("lat", lat), - checkRequired("locationType", locationType), - checkRequired("lon", lon), - checkRequired("name", name), - checkRequired("parent", parent), - checkRequired("routeIds", routeIds).map { it.toImmutable() }, - checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, - code, - direction, - wheelchairBoarding, + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + outOfRange, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): List = apply { + fun validate(): Data = apply { if (validated) { return@apply } - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - code() - direction() - wheelchairBoarding() + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() validated = true } @@ -958,40 +561,54 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (lat.asKnown().isPresent) 1 else 0) + - (if (locationType.asKnown().isPresent) 1 else 0) + - (if (lon.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (parent.asKnown().isPresent) 1 else 0) + - (routeIds.asKnown().getOrNull()?.size ?: 0) + - (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + - (if (code.asKnown().isPresent) 1 else 0) + - (if (direction.asKnown().isPresent) 1 else 0) + - (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is List && - id == other.id && - lat == other.lat && - locationType == other.locationType && - lon == other.lon && - name == other.name && - parent == other.parent && - routeIds == other.routeIds && - staticRouteIds == other.staticRouteIds && - code == other.code && - direction == other.direction && - wheelchairBoarding == other.wheelchairBoarding && - additionalProperties == other.additionalProperties - } + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) - private val hashCode: Int by lazy { - Objects.hash( + class List + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( id, lat, locationType, @@ -1003,14 +620,569 @@ private constructor( code, direction, wheelchairBoarding, - additionalProperties, + mutableMapOf(), ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Double = lat.getRequired("lat") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun locationType(): Long = locationType.getRequired("locationType") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Double = lon.getRequired("lon") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun parent(): String = parent.getRequired("parent") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun staticRouteIds(): kotlin.collections.List = + staticRouteIds.getRequired("staticRouteIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun code(): Optional = code.getOptional("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun direction(): Optional = direction.getOptional("direction") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun wheelchairBoarding(): Optional = + wheelchairBoarding.getOptional("wheelchairBoarding") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [locationType]. + * + * Unlike [locationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + + /** + * Returns the raw JSON value of [routeIds]. + * + * Unlike [routeIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds + + /** + * Returns the raw JSON value of [staticRouteIds]. + * + * Unlike [staticRouteIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [wheelchairBoarding]. + * + * Unlike [wheelchairBoarding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + fun _wheelchairBoarding(): JsonField = wheelchairBoarding + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var lat: JsonField? = null + private var locationType: JsonField? = null + private var lon: JsonField? = null + private var name: JsonField? = null + private var parent: JsonField? = null + private var routeIds: JsonField>? = null + private var staticRouteIds: JsonField>? = null + private var code: JsonField = JsonMissing.of() + private var direction: JsonField = JsonMissing.of() + private var wheelchairBoarding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + lat = list.lat + locationType = list.locationType + lon = list.lon + name = list.name + parent = list.parent + routeIds = list.routeIds.map { it.toMutableList() } + staticRouteIds = list.staticRouteIds.map { it.toMutableList() } + code = list.code + direction = list.direction + wheelchairBoarding = list.wheelchairBoarding + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + /** + * Sets [Builder.locationType] to an arbitrary JSON value. + * + * You should usually call [Builder.locationType] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun parent(parent: String) = parent(JsonField.of(parent)) + + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + fun routeIds(routeIds: kotlin.collections.List) = + routeIds(JsonField.of(routeIds)) + + /** + * Sets [Builder.routeIds] to an arbitrary JSON value. + * + * You should usually call [Builder.routeIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeIds(routeIds: JsonField>) = apply { + this.routeIds = routeIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [routeIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).also { + checkKnown("routeIds", it).add(routeId) + } + } + + fun staticRouteIds(staticRouteIds: kotlin.collections.List) = + staticRouteIds(JsonField.of(staticRouteIds)) + + /** + * Sets [Builder.staticRouteIds] to an arbitrary JSON value. + * + * You should usually call [Builder.staticRouteIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun staticRouteIds(staticRouteIds: JsonField>) = + apply { + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [staticRouteIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).also { + checkKnown("staticRouteIds", it).add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun wheelchairBoarding(wheelchairBoarding: String) = + wheelchairBoarding(JsonField.of(wheelchairBoarding)) + + /** + * Sets [Builder.wheelchairBoarding] to an arbitrary JSON value. + * + * You should usually call [Builder.wheelchairBoarding] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { + this.wheelchairBoarding = wheelchairBoarding + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is List && + id == other.id && + lat == other.lat && + locationType == other.locationType && + lon == other.lon && + name == other.name && + parent == other.parent && + routeIds == other.routeIds && + staticRouteIds == other.staticRouteIds && + code == other.code && + direction == other.direction && + wheelchairBoarding == other.wheelchairBoarding && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + outOfRange == other.outOfRange && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "List{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1023,29 +1195,16 @@ private constructor( currentTime == other.currentTime && text == other.text && version == other.version && - limitExceeded == other.limitExceeded && - list == other.list && - references == other.references && - outOfRange == other.outOfRange && + data == other.data && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - code, - currentTime, - text, - version, - limitExceeded, - list, - references, - outOfRange, - additionalProperties, - ) + Objects.hash(code, currentTime, text, version, data, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "StopsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + "StopsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt index 4b154f5..d604328 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt @@ -301,46 +301,27 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val entry: JsonField, - private val references: JsonField, + private val data: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - references: JsonField = JsonMissing.of(), - ) : this(entry, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun entry(): Entry = entry.getRequired("entry") + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun references(): References = references.getRequired("references") - - /** - * Returns the raw JSON value of [entry]. - * - * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + fun data(): InnerData = data.getRequired("data") /** - * Returns the raw JSON value of [references]. + * Returns the raw JSON value of [data]. * - * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -361,8 +342,7 @@ private constructor( * * The following fields are required: * ```java - * .entry() - * .references() + * .data() * ``` */ @JvmStatic fun builder() = Builder() @@ -371,40 +351,25 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var entry: JsonField? = null - private var references: JsonField? = null + private var data: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - entry = data.entry - references = data.references + this.data = data.data additionalProperties = data.additionalProperties.toMutableMap() } - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - /** - * Sets [Builder.entry] to an arbitrary JSON value. - * - * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) + fun data(data: InnerData) = data(JsonField.of(data)) /** - * Sets [Builder.references] to an arbitrary JSON value. + * Sets [Builder.data] to an arbitrary JSON value. * - * You should usually call [Builder.references] with a well-typed [References] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.data] with a well-typed [InnerData] value instead. + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun references(references: JsonField) = apply { - this.references = references - } + fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -432,18 +397,13 @@ private constructor( * * The following fields are required: * ```java - * .entry() - * .references() + * .data() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toMutableMap(), - ) + Data(checkRequired("data", data), additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -453,8 +413,7 @@ private constructor( return@apply } - entry().validate() - references().validate() + data().validate() validated = true } @@ -472,97 +431,54 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (entry.asKnown().getOrNull()?.validity() ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) - class Entry + class InnerData @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val polylines: JsonField>, - private val routeId: JsonField, - private val stopGroupings: JsonField>, - private val stopIds: JsonField>, + private val entry: JsonField, + private val references: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("polylines") - @ExcludeMissing - polylines: JsonField> = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - routeId: JsonField = JsonMissing.of(), - @JsonProperty("stopGroupings") - @ExcludeMissing - stopGroupings: JsonField> = JsonMissing.of(), - @JsonProperty("stopIds") + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") @ExcludeMissing - stopIds: JsonField> = JsonMissing.of(), - ) : this(polylines, routeId, stopGroupings, stopIds, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun polylines(): Optional> = polylines.getOptional("polylines") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun routeId(): Optional = routeId.getOptional("routeId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun stopGroupings(): Optional> = - stopGroupings.getOptional("stopGroupings") + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun stopIds(): Optional> = stopIds.getOptional("stopIds") + fun entry(): Entry = entry.getRequired("entry") /** - * Returns the raw JSON value of [polylines]. - * - * Unlike [polylines], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @JsonProperty("polylines") - @ExcludeMissing - fun _polylines(): JsonField> = polylines + fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [routeId]. + * Returns the raw JSON value of [entry]. * - * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry /** - * Returns the raw JSON value of [stopGroupings]. + * Returns the raw JSON value of [references]. * - * Unlike [stopGroupings], this method doesn't throw if the JSON field has an unexpected + * Unlike [references], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("stopGroupings") - @ExcludeMissing - fun _stopGroupings(): JsonField> = stopGroupings - - /** - * Returns the raw JSON value of [stopIds]. - * - * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("stopIds") + @JsonProperty("references") @ExcludeMissing - fun _stopIds(): JsonField> = stopIds + fun _references(): JsonField = references @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -578,113 +494,54 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Entry]. */ + /** + * Returns a mutable builder for constructing an instance of [InnerData]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Entry]. */ + /** A builder for [InnerData]. */ class Builder internal constructor() { - private var polylines: JsonField>? = null - private var routeId: JsonField = JsonMissing.of() - private var stopGroupings: JsonField>? = null - private var stopIds: JsonField>? = null + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(entry: Entry) = apply { - polylines = entry.polylines.map { it.toMutableList() } - routeId = entry.routeId - stopGroupings = entry.stopGroupings.map { it.toMutableList() } - stopIds = entry.stopIds.map { it.toMutableList() } - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun polylines(polylines: List) = polylines(JsonField.of(polylines)) - - /** - * Sets [Builder.polylines] to an arbitrary JSON value. - * - * You should usually call [Builder.polylines] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines.map { it.toMutableList() } - } - - /** - * Adds a single [Polyline] to [polylines]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPolyline(polyline: Polyline) = apply { - polylines = - (polylines ?: JsonField.of(mutableListOf())).also { - checkKnown("polylines", it).add(polyline) - } + internal fun from(innerData: InnerData) = apply { + entry = innerData.entry + references = innerData.references + additionalProperties = innerData.additionalProperties.toMutableMap() } - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - /** - * Sets [Builder.routeId] to an arbitrary JSON value. - * - * You should usually call [Builder.routeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun stopGroupings(stopGroupings: List) = - stopGroupings(JsonField.of(stopGroupings)) - - /** - * Sets [Builder.stopGroupings] to an arbitrary JSON value. - * - * You should usually call [Builder.stopGroupings] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun stopGroupings(stopGroupings: JsonField>) = apply { - this.stopGroupings = stopGroupings.map { it.toMutableList() } - } + fun entry(entry: Entry) = entry(JsonField.of(entry)) /** - * Adds a single [StopGrouping] to [stopGroupings]. + * Sets [Builder.entry] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addStopGrouping(stopGrouping: StopGrouping) = apply { - stopGroupings = - (stopGroupings ?: JsonField.of(mutableListOf())).also { - checkKnown("stopGroupings", it).add(stopGrouping) - } - } + fun entry(entry: JsonField) = apply { this.entry = entry } - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + fun references(references: References) = references(JsonField.of(references)) /** - * Sets [Builder.stopIds] to an arbitrary JSON value. + * Sets [Builder.references] to an arbitrary JSON value. * - * You should usually call [Builder.stopIds] with a well-typed `List` value + * You should usually call [Builder.references] with a well-typed [References] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun stopIds(stopIds: JsonField>) = apply { - this.stopIds = stopIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [stopIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addStopId(stopId: String) = apply { - stopIds = - (stopIds ?: JsonField.of(mutableListOf())).also { - checkKnown("stopIds", it).add(stopId) - } + fun references(references: JsonField) = apply { + this.references = references } fun additionalProperties(additionalProperties: Map) = apply { @@ -710,31 +567,35 @@ private constructor( } /** - * Returns an immutable instance of [Entry]. + * Returns an immutable instance of [InnerData]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Entry = - Entry( - (polylines ?: JsonMissing.of()).map { it.toImmutable() }, - routeId, - (stopGroupings ?: JsonMissing.of()).map { it.toImmutable() }, - (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, + fun build(): InnerData = + InnerData( + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Entry = apply { + fun validate(): InnerData = apply { if (validated) { return@apply } - polylines().ifPresent { it.forEach { it.validate() } } - routeId() - stopGroupings().ifPresent { it.forEach { it.validate() } } - stopIds() + entry().validate() + references().validate() validated = true } @@ -754,74 +615,97 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (routeId.asKnown().isPresent) 1 else 0) + - (stopGroupings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (stopIds.asKnown().getOrNull()?.size ?: 0) + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) - class Polyline + class Entry @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, + private val polylines: JsonField>, + private val routeId: JsonField, + private val stopGroupings: JsonField>, + private val stopIds: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("length") + @JsonProperty("polylines") @ExcludeMissing - length: JsonField = JsonMissing.of(), - @JsonProperty("levels") + polylines: JsonField> = JsonMissing.of(), + @JsonProperty("routeId") @ExcludeMissing - levels: JsonField = JsonMissing.of(), - @JsonProperty("points") + routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopGroupings") + @ExcludeMissing + stopGroupings: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") @ExcludeMissing - points: JsonField = JsonMissing.of(), - ) : this(length, levels, points, mutableMapOf()) + stopIds: JsonField> = JsonMissing.of(), + ) : this(polylines, routeId, stopGroupings, stopIds, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun polylines(): Optional> = polylines.getOptional("polylines") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun length(): Optional = length.getOptional("length") + fun routeId(): Optional = routeId.getOptional("routeId") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun levels(): Optional = levels.getOptional("levels") + fun stopGroupings(): Optional> = + stopGroupings.getOptional("stopGroupings") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun points(): Optional = points.getOptional("points") + fun stopIds(): Optional> = stopIds.getOptional("stopIds") /** - * Returns the raw JSON value of [length]. + * Returns the raw JSON value of [polylines]. * - * Unlike [length], this method doesn't throw if the JSON field has an unexpected + * Unlike [polylines], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + @JsonProperty("polylines") + @ExcludeMissing + fun _polylines(): JsonField> = polylines /** - * Returns the raw JSON value of [levels]. + * Returns the raw JSON value of [routeId]. * - * Unlike [levels], this method doesn't throw if the JSON field has an unexpected + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [stopGroupings]. + * + * Unlike [stopGroupings], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopGroupings") + @ExcludeMissing + fun _stopGroupings(): JsonField> = stopGroupings /** - * Returns the raw JSON value of [points]. + * Returns the raw JSON value of [stopIds]. * - * Unlike [points], this method doesn't throw if the JSON field has an unexpected + * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -837,58 +721,114 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Polyline]. */ + /** Returns a mutable builder for constructing an instance of [Entry]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Polyline]. */ + /** A builder for [Entry]. */ class Builder internal constructor() { - private var length: JsonField = JsonMissing.of() - private var levels: JsonField = JsonMissing.of() - private var points: JsonField = JsonMissing.of() + private var polylines: JsonField>? = null + private var routeId: JsonField = JsonMissing.of() + private var stopGroupings: JsonField>? = null + private var stopIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(polyline: Polyline) = apply { - length = polyline.length - levels = polyline.levels - points = polyline.points - additionalProperties = polyline.additionalProperties.toMutableMap() + internal fun from(entry: Entry) = apply { + polylines = entry.polylines.map { it.toMutableList() } + routeId = entry.routeId + stopGroupings = entry.stopGroupings.map { it.toMutableList() } + stopIds = entry.stopIds.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() } - fun length(length: Long) = length(JsonField.of(length)) + fun polylines(polylines: List) = polylines(JsonField.of(polylines)) /** - * Sets [Builder.length] to an arbitrary JSON value. + * Sets [Builder.polylines] to an arbitrary JSON value. * - * You should usually call [Builder.length] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.polylines] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun polylines(polylines: JsonField>) = apply { + this.polylines = polylines.map { it.toMutableList() } + } + + /** + * Adds a single [Polyline] to [polylines]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun length(length: JsonField) = apply { this.length = length } + fun addPolyline(polyline: Polyline) = apply { + polylines = + (polylines ?: JsonField.of(mutableListOf())).also { + checkKnown("polylines", it).add(polyline) + } + } - fun levels(levels: String) = levels(JsonField.of(levels)) + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) /** - * Sets [Builder.levels] to an arbitrary JSON value. + * Sets [Builder.routeId] to an arbitrary JSON value. * - * You should usually call [Builder.levels] with a well-typed [String] value + * You should usually call [Builder.routeId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun levels(levels: JsonField) = apply { this.levels = levels } + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - fun points(points: String) = points(JsonField.of(points)) + fun stopGroupings(stopGroupings: List) = + stopGroupings(JsonField.of(stopGroupings)) /** - * Sets [Builder.points] to an arbitrary JSON value. + * Sets [Builder.stopGroupings] to an arbitrary JSON value. * - * You should usually call [Builder.points] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.stopGroupings] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopGroupings(stopGroupings: JsonField>) = apply { + this.stopGroupings = stopGroupings.map { it.toMutableList() } + } + + /** + * Adds a single [StopGrouping] to [stopGroupings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopGrouping(stopGrouping: StopGrouping) = apply { + stopGroupings = + (stopGroupings ?: JsonField.of(mutableListOf())).also { + checkKnown("stopGroupings", it).add(stopGrouping) + } + } + + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + + /** + * Sets [Builder.stopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.stopIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [stopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun points(points: JsonField) = apply { this.points = points } + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -913,24 +853,31 @@ private constructor( } /** - * Returns an immutable instance of [Polyline]. + * Returns an immutable instance of [Entry]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Polyline = - Polyline(length, levels, points, additionalProperties.toMutableMap()) + fun build(): Entry = + Entry( + (polylines ?: JsonMissing.of()).map { it.toImmutable() }, + routeId, + (stopGroupings ?: JsonMissing.of()).map { it.toImmutable() }, + (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Polyline = apply { + fun validate(): Entry = apply { if (validated) { return@apply } - length() - levels() - points() + polylines().ifPresent { it.forEach { it.validate() } } + routeId() + stopGroupings().ifPresent { it.forEach { it.validate() } } + stopIds() validated = true } @@ -950,358 +897,79 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (length.asKnown().isPresent) 1 else 0) + - (if (levels.asKnown().isPresent) 1 else 0) + - (if (points.asKnown().isPresent) 1 else 0) + (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (stopGroupings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class Polyline + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is Polyline && - length == other.length && - levels == other.levels && - points == other.points && - additionalProperties == other.additionalProperties - } + @JsonCreator + private constructor( + @JsonProperty("length") + @ExcludeMissing + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) - private val hashCode: Int by lazy { - Objects.hash(length, levels, points, additionalProperties) - } + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun length(): Optional = length.getOptional("length") - override fun hashCode(): Int = hashCode + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun levels(): Optional = levels.getOptional("levels") - override fun toString() = - "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" - } + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun points(): Optional = points.getOptional("points") - class StopGrouping - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val polylines: JsonField>, - private val stopIds: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [length]. + * + * Unlike [length], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("polylines") - @ExcludeMissing - polylines: JsonField> = JsonMissing.of(), - @JsonProperty("stopIds") + /** + * Returns the raw JSON value of [levels]. + * + * Unlike [levels], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("levels") @ExcludeMissing - stopIds: JsonField> = JsonMissing.of(), - ) : this(id, name, polylines, stopIds, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun polylines(): Optional> = polylines.getOptional("polylines") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun stopIds(): Optional> = stopIds.getOptional("stopIds") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [polylines]. - * - * Unlike [polylines], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("polylines") - @ExcludeMissing - fun _polylines(): JsonField> = polylines - - /** - * Returns the raw JSON value of [stopIds]. - * - * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("stopIds") - @ExcludeMissing - fun _stopIds(): JsonField> = stopIds - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [StopGrouping]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopGrouping]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var polylines: JsonField>? = null - private var stopIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopGrouping: StopGrouping) = apply { - id = stopGrouping.id - name = stopGrouping.name - polylines = stopGrouping.polylines.map { it.toMutableList() } - stopIds = stopGrouping.stopIds.map { it.toMutableList() } - additionalProperties = stopGrouping.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: Name) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Name] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun polylines(polylines: List) = polylines(JsonField.of(polylines)) - - /** - * Sets [Builder.polylines] to an arbitrary JSON value. - * - * You should usually call [Builder.polylines] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines.map { it.toMutableList() } - } - - /** - * Adds a single [Polyline] to [polylines]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPolyline(polyline: Polyline) = apply { - polylines = - (polylines ?: JsonField.of(mutableListOf())).also { - checkKnown("polylines", it).add(polyline) - } - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - - /** - * Sets [Builder.stopIds] to an arbitrary JSON value. - * - * You should usually call [Builder.stopIds] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stopIds(stopIds: JsonField>) = apply { - this.stopIds = stopIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [stopIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addStopId(stopId: String) = apply { - stopIds = - (stopIds ?: JsonField.of(mutableListOf())).also { - checkKnown("stopIds", it).add(stopId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [StopGrouping]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): StopGrouping = - StopGrouping( - id, - name, - (polylines ?: JsonMissing.of()).map { it.toImmutable() }, - (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): StopGrouping = apply { - if (validated) { - return@apply - } - - id() - name().ifPresent { it.validate() } - polylines().ifPresent { it.forEach { it.validate() } } - stopIds() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OnebusawaySdkInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (name.asKnown().getOrNull()?.validity() ?: 0) + - (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (stopIds.asKnown().getOrNull()?.size ?: 0) - - class Name - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonField, - private val names: JsonField>, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("names") - @ExcludeMissing - names: JsonField> = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - ) : this(name, names, type, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun names(): Optional> = names.getOptional("names") + fun _levels(): JsonField = levels /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [names]. + * Returns the raw JSON value of [points]. * - * Unlike [names], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [points], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("names") + @JsonProperty("points") @ExcludeMissing - fun _names(): JsonField> = names - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + fun _points(): JsonField = points @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1317,74 +985,59 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Name]. */ + /** Returns a mutable builder for constructing an instance of [Polyline]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Name]. */ + /** A builder for [Polyline]. */ class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() - private var names: JsonField>? = null - private var type: JsonField = JsonMissing.of() + private var length: JsonField = JsonMissing.of() + private var levels: JsonField = JsonMissing.of() + private var points: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - names = name.names.map { it.toMutableList() } - type = name.type - additionalProperties = name.additionalProperties.toMutableMap() + internal fun from(polyline: Polyline) = apply { + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() } - fun name(name: String) = name(JsonField.of(name)) + fun length(length: Long) = length(JsonField.of(length)) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.length] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value + * You should usually call [Builder.length] with a well-typed [Long] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun length(length: JsonField) = apply { this.length = length } - fun names(names: List) = names(JsonField.of(names)) + fun levels(levels: String) = levels(JsonField.of(levels)) /** - * Sets [Builder.names] to an arbitrary JSON value. + * Sets [Builder.levels] to an arbitrary JSON value. * - * You should usually call [Builder.names] with a well-typed `List` - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.levels] with a well-typed [String] value + * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun names(names: JsonField>) = apply { - this.names = names.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [names]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addName(name: String) = apply { - names = - (names ?: JsonField.of(mutableListOf())).also { - checkKnown("names", it).add(name) - } - } + fun levels(levels: JsonField) = apply { this.levels = levels } - fun type(type: String) = type(JsonField.of(type)) + fun points(points: String) = points(JsonField.of(points)) /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets [Builder.points] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [String] value + * You should usually call [Builder.points] with a well-typed [String] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun type(type: JsonField) = apply { this.type = type } + fun points(points: JsonField) = apply { this.points = points } fun additionalProperties(additionalProperties: Map) = apply { @@ -1409,29 +1062,24 @@ private constructor( } /** - * Returns an immutable instance of [Name]. + * Returns an immutable instance of [Polyline]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Name = - Name( - name, - (names ?: JsonMissing.of()).map { it.toImmutable() }, - type, - additionalProperties.toMutableMap(), - ) + fun build(): Polyline = + Polyline(length, levels, points, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): Name = apply { + fun validate(): Polyline = apply { if (validated) { return@apply } - name() - names() - type() + length() + levels() + points() validated = true } @@ -1451,99 +1099,117 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + - (names.asKnown().getOrNull()?.size ?: 0) + - (if (type.asKnown().isPresent) 1 else 0) + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Name && - name == other.name && - names == other.names && - type == other.type && + return other is Polyline && + length == other.length && + levels == other.levels && + points == other.points && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(name, names, type, additionalProperties) + Objects.hash(length, levels, points, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" } - class Polyline + class StopGrouping @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, + private val id: JsonField, + private val name: JsonField, + private val polylines: JsonField>, + private val stopIds: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("length") + @JsonProperty("id") @ExcludeMissing - length: JsonField = JsonMissing.of(), - @JsonProperty("levels") + id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing - levels: JsonField = JsonMissing.of(), - @JsonProperty("points") + name: JsonField = JsonMissing.of(), + @JsonProperty("polylines") @ExcludeMissing - points: JsonField = JsonMissing.of(), - ) : this(length, levels, points, mutableMapOf()) + polylines: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + stopIds: JsonField> = JsonMissing.of(), + ) : this(id, name, polylines, stopIds, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun length(): Optional = length.getOptional("length") + fun id(): Optional = id.getOptional("id") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun levels(): Optional = levels.getOptional("levels") + fun name(): Optional = name.getOptional("name") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun points(): Optional = points.getOptional("points") + fun polylines(): Optional> = polylines.getOptional("polylines") /** - * Returns the raw JSON value of [length]. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopIds(): Optional> = stopIds.getOptional("stopIds") + + /** + * Returns the raw JSON value of [id]. * - * Unlike [length], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [levels]. + * Returns the raw JSON value of [name]. * - * Unlike [levels], this method doesn't throw if the JSON field has an + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [polylines]. + * + * Unlike [polylines], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("levels") + @JsonProperty("polylines") @ExcludeMissing - fun _levels(): JsonField = levels + fun _polylines(): JsonField> = polylines /** - * Returns the raw JSON value of [points]. + * Returns the raw JSON value of [stopIds]. * - * Unlike [points], this method doesn't throw if the JSON field has an + * Unlike [stopIds], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("points") + @JsonProperty("stopIds") @ExcludeMissing - fun _points(): JsonField = points + fun _stopIds(): JsonField> = stopIds @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1559,59 +1225,105 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Polyline]. */ + /** + * Returns a mutable builder for constructing an instance of [StopGrouping]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Polyline]. */ + /** A builder for [StopGrouping]. */ class Builder internal constructor() { - private var length: JsonField = JsonMissing.of() - private var levels: JsonField = JsonMissing.of() - private var points: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var polylines: JsonField>? = null + private var stopIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(polyline: Polyline) = apply { - length = polyline.length - levels = polyline.levels - points = polyline.points - additionalProperties = polyline.additionalProperties.toMutableMap() + internal fun from(stopGrouping: StopGrouping) = apply { + id = stopGrouping.id + name = stopGrouping.name + polylines = stopGrouping.polylines.map { it.toMutableList() } + stopIds = stopGrouping.stopIds.map { it.toMutableList() } + additionalProperties = stopGrouping.additionalProperties.toMutableMap() } - fun length(length: Long) = length(JsonField.of(length)) + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.length] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.length] with a well-typed [Long] value + * You should usually call [Builder.id] with a well-typed [String] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun length(length: JsonField) = apply { this.length = length } + fun id(id: JsonField) = apply { this.id = id } - fun levels(levels: String) = levels(JsonField.of(levels)) + fun name(name: Name) = name(JsonField.of(name)) /** - * Sets [Builder.levels] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.levels] with a well-typed [String] value + * You should usually call [Builder.name] with a well-typed [Name] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun levels(levels: JsonField) = apply { this.levels = levels } + fun name(name: JsonField) = apply { this.name = name } - fun points(points: String) = points(JsonField.of(points)) + fun polylines(polylines: List) = + polylines(JsonField.of(polylines)) /** - * Sets [Builder.points] to an arbitrary JSON value. + * Sets [Builder.polylines] to an arbitrary JSON value. * - * You should usually call [Builder.points] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.polylines] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun points(points: JsonField) = apply { this.points = points } + fun polylines(polylines: JsonField>) = apply { + this.polylines = polylines.map { it.toMutableList() } + } + + /** + * Adds a single [Polyline] to [polylines]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addPolyline(polyline: Polyline) = apply { + polylines = + (polylines ?: JsonField.of(mutableListOf())).also { + checkKnown("polylines", it).add(polyline) + } + } + + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + + /** + * Sets [Builder.stopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.stopIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [stopIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) + } + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1636,24 +1348,31 @@ private constructor( } /** - * Returns an immutable instance of [Polyline]. + * Returns an immutable instance of [StopGrouping]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Polyline = - Polyline(length, levels, points, additionalProperties.toMutableMap()) + fun build(): StopGrouping = + StopGrouping( + id, + name, + (polylines ?: JsonMissing.of()).map { it.toImmutable() }, + (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Polyline = apply { + fun validate(): StopGrouping = apply { if (validated) { return@apply } - length() - levels() - points() + id() + name().ifPresent { it.validate() } + polylines().ifPresent { it.forEach { it.validate() } } + stopIds() validated = true } @@ -1673,30 +1392,512 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (length.asKnown().isPresent) 1 else 0) + - (if (levels.asKnown().isPresent) 1 else 0) + - (if (points.asKnown().isPresent) 1 else 0) + (if (id.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) + + class Name + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val names: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("names") + @ExcludeMissing + names: JsonField> = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + ) : this(name, names, type, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun names(): Optional> = names.getOptional("names") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [names]. + * + * Unlike [names], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("names") + @ExcludeMissing + fun _names(): JsonField> = names + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Name]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Name]. */ + class Builder internal constructor() { + + private var name: JsonField = JsonMissing.of() + private var names: JsonField>? = null + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(name: Name) = apply { + this.name = name.name + names = name.names.map { it.toMutableList() } + type = name.type + additionalProperties = name.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun names(names: List) = names(JsonField.of(names)) + + /** + * Sets [Builder.names] to an arbitrary JSON value. + * + * You should usually call [Builder.names] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun names(names: JsonField>) = apply { + this.names = names.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [names]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addName(name: String) = apply { + names = + (names ?: JsonField.of(mutableListOf())).also { + checkKnown("names", it).add(name) + } + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Name]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Name = + Name( + name, + (names ?: JsonMissing.of()).map { it.toImmutable() }, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + name() + names() + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (names.asKnown().getOrNull()?.size ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && + name == other.name && + names == other.names && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, names, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" + } + + class Polyline + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("length") + @ExcludeMissing + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun length(): Optional = length.getOptional("length") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun levels(): Optional = levels.getOptional("levels") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun points(): Optional = points.getOptional("points") + + /** + * Returns the raw JSON value of [length]. + * + * Unlike [length], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("length") + @ExcludeMissing + fun _length(): JsonField = length + + /** + * Returns the raw JSON value of [levels]. + * + * Unlike [levels], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("levels") + @ExcludeMissing + fun _levels(): JsonField = levels + + /** + * Returns the raw JSON value of [points]. + * + * Unlike [points], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("points") + @ExcludeMissing + fun _points(): JsonField = points + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Polyline]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Polyline]. */ + class Builder internal constructor() { + + private var length: JsonField = JsonMissing.of() + private var levels: JsonField = JsonMissing.of() + private var points: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(polyline: Polyline) = apply { + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() + } + + fun length(length: Long) = length(JsonField.of(length)) + + /** + * Sets [Builder.length] to an arbitrary JSON value. + * + * You should usually call [Builder.length] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun length(length: JsonField) = apply { this.length = length } + + fun levels(levels: String) = levels(JsonField.of(levels)) + + /** + * Sets [Builder.levels] to an arbitrary JSON value. + * + * You should usually call [Builder.levels] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun levels(levels: JsonField) = apply { this.levels = levels } + + fun points(points: String) = points(JsonField.of(points)) + + /** + * Sets [Builder.points] to an arbitrary JSON value. + * + * You should usually call [Builder.points] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun points(points: JsonField) = apply { this.points = points } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Polyline]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Polyline = + Polyline( + length, + levels, + points, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Polyline = apply { + if (validated) { + return@apply + } + + length() + levels() + points() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Polyline && + length == other.length && + levels == other.levels && + points == other.points && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(length, levels, points, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Polyline && - length == other.length && - levels == other.levels && - points == other.points && + return other is StopGrouping && + id == other.id && + name == other.name && + polylines == other.polylines && + stopIds == other.stopIds && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(length, levels, points, additionalProperties) + Objects.hash(id, name, polylines, stopIds, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1704,22 +1905,22 @@ private constructor( return true } - return other is StopGrouping && - id == other.id && - name == other.name && + return other is Entry && polylines == other.polylines && + routeId == other.routeId && + stopGroupings == other.stopGroupings && stopIds == other.stopIds && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, name, polylines, stopIds, additionalProperties) + Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" + "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1727,22 +1928,20 @@ private constructor( return true } - return other is Entry && - polylines == other.polylines && - routeId == other.routeId && - stopGroupings == other.stopGroupings && - stopIds == other.stopIds && + return other is InnerData && + entry == other.entry && + references == other.references && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) + Objects.hash(entry, references, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" + "InnerData{entry=$entry, references=$references, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1751,17 +1950,15 @@ private constructor( } return other is Data && - entry == other.entry && - references == other.references && + data == other.data && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + override fun toString() = "Data{data=$data, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponseTest.kt index da850ec..299b6a9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponseTest.kt @@ -24,21 +24,6 @@ internal class ScheduleForRouteRetrieveResponseTest { .routeId("routeId") .scheduleDate(0L) .addServiceId("string") - .addStop( - ScheduleForRouteRetrieveResponse.Data.Entry.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) .addStopTripGrouping( ScheduleForRouteRetrieveResponse.Data.Entry.StopTripGrouping .builder() @@ -72,21 +57,6 @@ internal class ScheduleForRouteRetrieveResponseTest { ) .build() ) - .addTrip( - ScheduleForRouteRetrieveResponse.Data.Entry.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) .build() ) .build() @@ -105,21 +75,6 @@ internal class ScheduleForRouteRetrieveResponseTest { .routeId("routeId") .scheduleDate(0L) .addServiceId("string") - .addStop( - ScheduleForRouteRetrieveResponse.Data.Entry.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) .addStopTripGrouping( ScheduleForRouteRetrieveResponse.Data.Entry.StopTripGrouping .builder() @@ -152,21 +107,6 @@ internal class ScheduleForRouteRetrieveResponseTest { ) .build() ) - .addTrip( - ScheduleForRouteRetrieveResponse.Data.Entry.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) .build() ) .build() @@ -189,21 +129,6 @@ internal class ScheduleForRouteRetrieveResponseTest { .routeId("routeId") .scheduleDate(0L) .addServiceId("string") - .addStop( - ScheduleForRouteRetrieveResponse.Data.Entry.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) .addStopTripGrouping( ScheduleForRouteRetrieveResponse.Data.Entry.StopTripGrouping .builder() @@ -237,21 +162,6 @@ internal class ScheduleForRouteRetrieveResponseTest { ) .build() ) - .addTrip( - ScheduleForRouteRetrieveResponse.Data.Entry.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt index 29422fd..6530d77 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt @@ -18,327 +18,340 @@ internal class StopsForAgencyListResponseTest { .currentTime(0L) .text("text") .version(0L) - .limitExceeded(true) - .addList( - StopsForAgencyListResponse.List.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - .references( - References.builder() - .addAgency( - References.Agency.builder() + .data( + StopsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + StopsForAgencyListResponse.Data.List.builder() .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) - .addRoute( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) .build() ) - .addAllAffect( - References.Situation.AllAffect.builder() + .addRoute( + References.Route.builder() + .id("id") .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") .build() ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( - References.Situation.Consequence.ConditionDetails - .builder() - .diversionPath( + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( References.Situation.Consequence .ConditionDetails - .DiversionPath .builder() - .length(0L) - .levels("levels") - .points("points") + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") .build() ) - .addDiversionStopId("string") + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") .build() ) .build() ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") .build() ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) + .outOfRange(true) .build() ) - .outOfRange(true) .build() assertThat(stopsForAgencyListResponse.code()).isEqualTo(0L) assertThat(stopsForAgencyListResponse.currentTime()).isEqualTo(0L) assertThat(stopsForAgencyListResponse.text()).isEqualTo("text") assertThat(stopsForAgencyListResponse.version()).isEqualTo(0L) - assertThat(stopsForAgencyListResponse.limitExceeded()).isEqualTo(true) - assertThat(stopsForAgencyListResponse.list()) - .containsExactly( - StopsForAgencyListResponse.List.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - assertThat(stopsForAgencyListResponse.references()) + assertThat(stopsForAgencyListResponse.data()) .isEqualTo( - References.builder() - .addAgency( - References.Agency.builder() + StopsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + StopsForAgencyListResponse.Data.List.builder() .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) - .addRoute( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder().from(0L).to(0L).build() + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() ) - .addAllAffect( - References.Situation.AllAffect.builder() + .addRoute( + References.Route.builder() + .id("id") .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") .build() ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( - References.Situation.Consequence.ConditionDetails.builder() - .diversionPath( + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( References.Situation.Consequence.ConditionDetails - .DiversionPath .builder() - .length(0L) - .levels("levels") - .points("points") + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") .build() ) - .addDiversionStopId("string") + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") .build() ) .build() ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") .build() ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) + .outOfRange(true) .build() ) - assertThat(stopsForAgencyListResponse.outOfRange()).contains(true) } @Test @@ -350,165 +363,170 @@ internal class StopsForAgencyListResponseTest { .currentTime(0L) .text("text") .version(0L) - .limitExceeded(true) - .addList( - StopsForAgencyListResponse.List.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - .references( - References.builder() - .addAgency( - References.Agency.builder() + .data( + StopsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + StopsForAgencyListResponse.Data.List.builder() .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) - .addRoute( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) .build() ) - .addAllAffect( - References.Situation.AllAffect.builder() + .addRoute( + References.Route.builder() + .id("id") .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") .build() ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( - References.Situation.Consequence.ConditionDetails - .builder() - .diversionPath( + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( References.Situation.Consequence .ConditionDetails - .DiversionPath .builder() - .length(0L) - .levels("levels") - .points("points") + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") .build() ) - .addDiversionStopId("string") + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") .build() ) .build() ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") .build() ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) + .outOfRange(true) .build() ) - .outOfRange(true) .build() val roundtrippedStopsForAgencyListResponse = diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt index 7e35cf7..421a7c8 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt @@ -20,183 +20,195 @@ internal class StopsForRouteListResponseTest { .version(0L) .data( StopsForRouteListResponse.Data.builder() - .entry( - StopsForRouteListResponse.Data.Entry.builder() - .addPolyline( - StopsForRouteListResponse.Data.Entry.Polyline.builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .routeId("1_100224") - .addStopGrouping( - StopsForRouteListResponse.Data.Entry.StopGrouping.builder() - .id("id") - .name( - StopsForRouteListResponse.Data.Entry.StopGrouping.Name - .builder() - .name("name") - .addName("string") - .type("type") - .build() - ) + .data( + StopsForRouteListResponse.Data.InnerData.builder() + .entry( + StopsForRouteListResponse.Data.InnerData.Entry.builder() .addPolyline( - StopsForRouteListResponse.Data.Entry.StopGrouping - .Polyline + StopsForRouteListResponse.Data.InnerData.Entry.Polyline .builder() .length(0L) .levels("levels") .points("points") .build() ) - .addStopId("string") - .build() - ) - .addStopId("1_10911") - .build() - ) - .references( - References.builder() - .addAgency( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) - .addRoute( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .routeId("1_100224") + .addStopGrouping( + StopsForRouteListResponse.Data.InnerData.Entry + .StopGrouping + .builder() + .id("id") + .name( + StopsForRouteListResponse.Data.InnerData.Entry + .StopGrouping + .Name + .builder() + .name("name") + .addName("string") + .type("type") + .build() + ) + .addPolyline( + StopsForRouteListResponse.Data.InnerData.Entry + .StopGrouping + .Polyline + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addStopId("string") + .build() + ) + .addStopId("1_10911") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) .build() ) - .addAllAffect( - References.Situation.AllAffect.builder() + .addRoute( + References.Route.builder() + .id("id") .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") .build() ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( - References.Situation.Consequence - .ConditionDetails - .builder() - .diversionPath( + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( References.Situation.Consequence .ConditionDetails - .DiversionPath .builder() - .length(0L) - .levels("levels") - .points("points") + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") .build() ) - .addDiversionStopId("string") + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason( + References.Situation.Reason.EQUIPMENT_REASON + ) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") .build() ) .build() ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") .build() ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) .build() ) .build() @@ -210,181 +222,192 @@ internal class StopsForRouteListResponseTest { assertThat(stopsForRouteListResponse.data()) .isEqualTo( StopsForRouteListResponse.Data.builder() - .entry( - StopsForRouteListResponse.Data.Entry.builder() - .addPolyline( - StopsForRouteListResponse.Data.Entry.Polyline.builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .routeId("1_100224") - .addStopGrouping( - StopsForRouteListResponse.Data.Entry.StopGrouping.builder() - .id("id") - .name( - StopsForRouteListResponse.Data.Entry.StopGrouping.Name - .builder() - .name("name") - .addName("string") - .type("type") - .build() - ) + .data( + StopsForRouteListResponse.Data.InnerData.builder() + .entry( + StopsForRouteListResponse.Data.InnerData.Entry.builder() .addPolyline( - StopsForRouteListResponse.Data.Entry.StopGrouping.Polyline + StopsForRouteListResponse.Data.InnerData.Entry.Polyline .builder() .length(0L) .levels("levels") .points("points") .build() ) - .addStopId("string") - .build() - ) - .addStopId("1_10911") - .build() - ) - .references( - References.builder() - .addAgency( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) - .addRoute( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .routeId("1_100224") + .addStopGrouping( + StopsForRouteListResponse.Data.InnerData.Entry.StopGrouping + .builder() + .id("id") + .name( + StopsForRouteListResponse.Data.InnerData.Entry + .StopGrouping + .Name + .builder() + .name("name") + .addName("string") + .type("type") + .build() + ) + .addPolyline( + StopsForRouteListResponse.Data.InnerData.Entry + .StopGrouping + .Polyline + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addStopId("string") + .build() + ) + .addStopId("1_10911") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) .build() ) - .addAllAffect( - References.Situation.AllAffect.builder() + .addRoute( + References.Route.builder() + .id("id") .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") .build() ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( - References.Situation.Consequence.ConditionDetails - .builder() - .diversionPath( + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( References.Situation.Consequence .ConditionDetails - .DiversionPath .builder() - .length(0L) - .levels("levels") - .points("points") + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") .build() ) - .addDiversionStopId("string") + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") .build() ) .build() ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") .build() ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) .build() ) .build() @@ -402,183 +425,195 @@ internal class StopsForRouteListResponseTest { .version(0L) .data( StopsForRouteListResponse.Data.builder() - .entry( - StopsForRouteListResponse.Data.Entry.builder() - .addPolyline( - StopsForRouteListResponse.Data.Entry.Polyline.builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .routeId("1_100224") - .addStopGrouping( - StopsForRouteListResponse.Data.Entry.StopGrouping.builder() - .id("id") - .name( - StopsForRouteListResponse.Data.Entry.StopGrouping.Name - .builder() - .name("name") - .addName("string") - .type("type") - .build() - ) + .data( + StopsForRouteListResponse.Data.InnerData.builder() + .entry( + StopsForRouteListResponse.Data.InnerData.Entry.builder() .addPolyline( - StopsForRouteListResponse.Data.Entry.StopGrouping - .Polyline + StopsForRouteListResponse.Data.InnerData.Entry.Polyline .builder() .length(0L) .levels("levels") .points("points") .build() ) - .addStopId("string") - .build() - ) - .addStopId("1_10911") - .build() - ) - .references( - References.builder() - .addAgency( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) - .addRoute( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .routeId("1_100224") + .addStopGrouping( + StopsForRouteListResponse.Data.InnerData.Entry + .StopGrouping + .builder() + .id("id") + .name( + StopsForRouteListResponse.Data.InnerData.Entry + .StopGrouping + .Name + .builder() + .name("name") + .addName("string") + .type("type") + .build() + ) + .addPolyline( + StopsForRouteListResponse.Data.InnerData.Entry + .StopGrouping + .Polyline + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addStopId("string") + .build() + ) + .addStopId("1_10911") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) .build() ) - .addAllAffect( - References.Situation.AllAffect.builder() + .addRoute( + References.Route.builder() + .id("id") .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") .build() ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( - References.Situation.Consequence - .ConditionDetails - .builder() - .diversionPath( + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( References.Situation.Consequence .ConditionDetails - .DiversionPath .builder() - .length(0L) - .levels("levels") - .points("points") + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") .build() ) - .addDiversionStopId("string") + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason( + References.Situation.Reason.EQUIPMENT_REASON + ) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") .build() ) .build() ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") .build() ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") - .build() - ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") - .build() - ) .build() ) .build() From 1e5faa0e778189bb3ffc214ac370b0f8c5085824 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 9 Mar 2026 18:48:35 +0000 Subject: [PATCH 02/38] feat(api): api update --- .stats.yml | 4 +- .../StopsForRouteListResponse.kt | 1729 ++++++++--------- .../VehiclesForAgencyListResponse.kt | 235 ++- .../StopsForRouteListResponseTest.kt | 907 +++++---- .../VehiclesForAgencyListResponseTest.kt | 36 +- 5 files changed, 1336 insertions(+), 1575 deletions(-) diff --git a/.stats.yml b/.stats.yml index 26b456c..8dd1ce7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-162c2011b5784e2258775ec72e5da7bc86cb411d738b627f1eae6a0d56ee3aec.yml -openapi_spec_hash: 2e32c25a86f9ff55bab7cfa1d9c985a7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-22e1c98416f77779b2c07db272016be0b623b94f6b55cca2d1909f9dc4032c3f.yml +openapi_spec_hash: dd25fff6bc185752d92e93f6e47d3a5e config_hash: 3871f5d21bb38ddd334ec04721dea64d diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt index d604328..4b154f5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt @@ -301,27 +301,46 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val data: JsonField, + private val entry: JsonField, + private val references: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() - ) : this(data, mutableMapOf()) + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun data(): InnerData = data.getRequired("data") + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry /** - * Returns the raw JSON value of [data]. + * Returns the raw JSON value of [references]. * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -342,7 +361,8 @@ private constructor( * * The following fields are required: * ```java - * .data() + * .entry() + * .references() * ``` */ @JvmStatic fun builder() = Builder() @@ -351,25 +371,40 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var data: JsonField? = null + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - this.data = data.data + entry = data.entry + references = data.references additionalProperties = data.additionalProperties.toMutableMap() } - fun data(data: InnerData) = data(JsonField.of(data)) + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) /** - * Sets [Builder.data] to an arbitrary JSON value. + * Sets [Builder.references] to an arbitrary JSON value. * - * You should usually call [Builder.data] with a well-typed [InnerData] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun data(data: JsonField) = apply { this.data = data } + fun references(references: JsonField) = apply { + this.references = references + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -397,13 +432,18 @@ private constructor( * * The following fields are required: * ```java - * .data() + * .entry() + * .references() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): Data = - Data(checkRequired("data", data), additionalProperties.toMutableMap()) + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -413,7 +453,8 @@ private constructor( return@apply } - data().validate() + entry().validate() + references().validate() validated = true } @@ -431,54 +472,97 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) - class InnerData + class Entry @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val entry: JsonField, - private val references: JsonField, + private val polylines: JsonField>, + private val routeId: JsonField, + private val stopGroupings: JsonField>, + private val stopIds: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), - @JsonProperty("references") + @JsonProperty("polylines") + @ExcludeMissing + polylines: JsonField> = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopGroupings") + @ExcludeMissing + stopGroupings: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") @ExcludeMissing - references: JsonField = JsonMissing.of(), - ) : this(entry, references, mutableMapOf()) + stopIds: JsonField> = JsonMissing.of(), + ) : this(polylines, routeId, stopGroupings, stopIds, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun polylines(): Optional> = polylines.getOptional("polylines") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun routeId(): Optional = routeId.getOptional("routeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun stopGroupings(): Optional> = + stopGroupings.getOptional("stopGroupings") /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun entry(): Entry = entry.getRequired("entry") + fun stopIds(): Optional> = stopIds.getOptional("stopIds") /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Returns the raw JSON value of [polylines]. + * + * Unlike [polylines], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun references(): References = references.getRequired("references") + @JsonProperty("polylines") + @ExcludeMissing + fun _polylines(): JsonField> = polylines /** - * Returns the raw JSON value of [entry]. + * Returns the raw JSON value of [routeId]. * - * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId /** - * Returns the raw JSON value of [references]. + * Returns the raw JSON value of [stopGroupings]. * - * Unlike [references], this method doesn't throw if the JSON field has an unexpected + * Unlike [stopGroupings], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("references") + @JsonProperty("stopGroupings") + @ExcludeMissing + fun _stopGroupings(): JsonField> = stopGroupings + + /** + * Returns the raw JSON value of [stopIds]. + * + * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stopIds") @ExcludeMissing - fun _references(): JsonField = references + fun _stopIds(): JsonField> = stopIds @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -494,54 +578,113 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [InnerData]. - * - * The following fields are required: - * ```java - * .entry() - * .references() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Entry]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InnerData]. */ + /** A builder for [Entry]. */ class Builder internal constructor() { - private var entry: JsonField? = null - private var references: JsonField? = null + private var polylines: JsonField>? = null + private var routeId: JsonField = JsonMissing.of() + private var stopGroupings: JsonField>? = null + private var stopIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(innerData: InnerData) = apply { - entry = innerData.entry - references = innerData.references - additionalProperties = innerData.additionalProperties.toMutableMap() + internal fun from(entry: Entry) = apply { + polylines = entry.polylines.map { it.toMutableList() } + routeId = entry.routeId + stopGroupings = entry.stopGroupings.map { it.toMutableList() } + stopIds = entry.stopIds.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun polylines(polylines: List) = polylines(JsonField.of(polylines)) + + /** + * Sets [Builder.polylines] to an arbitrary JSON value. + * + * You should usually call [Builder.polylines] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun polylines(polylines: JsonField>) = apply { + this.polylines = polylines.map { it.toMutableList() } + } + + /** + * Adds a single [Polyline] to [polylines]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPolyline(polyline: Polyline) = apply { + polylines = + (polylines ?: JsonField.of(mutableListOf())).also { + checkKnown("polylines", it).add(polyline) + } } - fun entry(entry: Entry) = entry(JsonField.of(entry)) + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun stopGroupings(stopGroupings: List) = + stopGroupings(JsonField.of(stopGroupings)) + + /** + * Sets [Builder.stopGroupings] to an arbitrary JSON value. + * + * You should usually call [Builder.stopGroupings] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopGroupings(stopGroupings: JsonField>) = apply { + this.stopGroupings = stopGroupings.map { it.toMutableList() } + } /** - * Sets [Builder.entry] to an arbitrary JSON value. + * Adds a single [StopGrouping] to [stopGroupings]. * - * You should usually call [Builder.entry] with a well-typed [Entry] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun entry(entry: JsonField) = apply { this.entry = entry } + fun addStopGrouping(stopGrouping: StopGrouping) = apply { + stopGroupings = + (stopGroupings ?: JsonField.of(mutableListOf())).also { + checkKnown("stopGroupings", it).add(stopGrouping) + } + } - fun references(references: References) = references(JsonField.of(references)) + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) /** - * Sets [Builder.references] to an arbitrary JSON value. + * Sets [Builder.stopIds] to an arbitrary JSON value. * - * You should usually call [Builder.references] with a well-typed [References] value + * You should usually call [Builder.stopIds] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun references(references: JsonField) = apply { - this.references = references + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [stopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -567,35 +710,31 @@ private constructor( } /** - * Returns an immutable instance of [InnerData]. + * Returns an immutable instance of [Entry]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .entry() - * .references() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): InnerData = - InnerData( - checkRequired("entry", entry), - checkRequired("references", references), + fun build(): Entry = + Entry( + (polylines ?: JsonMissing.of()).map { it.toImmutable() }, + routeId, + (stopGroupings ?: JsonMissing.of()).map { it.toImmutable() }, + (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): InnerData = apply { + fun validate(): Entry = apply { if (validated) { return@apply } - entry().validate() - references().validate() + polylines().ifPresent { it.forEach { it.validate() } } + routeId() + stopGroupings().ifPresent { it.forEach { it.validate() } } + stopIds() validated = true } @@ -615,97 +754,74 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (entry.asKnown().getOrNull()?.validity() ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (stopGroupings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) - class Entry + class Polyline @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val polylines: JsonField>, - private val routeId: JsonField, - private val stopGroupings: JsonField>, - private val stopIds: JsonField>, + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("polylines") - @ExcludeMissing - polylines: JsonField> = JsonMissing.of(), - @JsonProperty("routeId") + @JsonProperty("length") @ExcludeMissing - routeId: JsonField = JsonMissing.of(), - @JsonProperty("stopGroupings") + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") @ExcludeMissing - stopGroupings: JsonField> = JsonMissing.of(), - @JsonProperty("stopIds") + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") @ExcludeMissing - stopIds: JsonField> = JsonMissing.of(), - ) : this(polylines, routeId, stopGroupings, stopIds, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun polylines(): Optional> = polylines.getOptional("polylines") + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun routeId(): Optional = routeId.getOptional("routeId") + fun length(): Optional = length.getOptional("length") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun stopGroupings(): Optional> = - stopGroupings.getOptional("stopGroupings") + fun levels(): Optional = levels.getOptional("levels") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun stopIds(): Optional> = stopIds.getOptional("stopIds") + fun points(): Optional = points.getOptional("points") /** - * Returns the raw JSON value of [polylines]. + * Returns the raw JSON value of [length]. * - * Unlike [polylines], this method doesn't throw if the JSON field has an unexpected + * Unlike [length], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("polylines") - @ExcludeMissing - fun _polylines(): JsonField> = polylines + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length /** - * Returns the raw JSON value of [routeId]. + * Returns the raw JSON value of [levels]. * - * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected + * Unlike [levels], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - - /** - * Returns the raw JSON value of [stopGroupings]. - * - * Unlike [stopGroupings], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("stopGroupings") - @ExcludeMissing - fun _stopGroupings(): JsonField> = stopGroupings + @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels /** - * Returns the raw JSON value of [stopIds]. + * Returns the raw JSON value of [points]. * - * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected + * Unlike [points], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("stopIds") - @ExcludeMissing - fun _stopIds(): JsonField> = stopIds + @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -721,114 +837,58 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Entry]. */ + /** Returns a mutable builder for constructing an instance of [Polyline]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Entry]. */ + /** A builder for [Polyline]. */ class Builder internal constructor() { - private var polylines: JsonField>? = null - private var routeId: JsonField = JsonMissing.of() - private var stopGroupings: JsonField>? = null - private var stopIds: JsonField>? = null + private var length: JsonField = JsonMissing.of() + private var levels: JsonField = JsonMissing.of() + private var points: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(entry: Entry) = apply { - polylines = entry.polylines.map { it.toMutableList() } - routeId = entry.routeId - stopGroupings = entry.stopGroupings.map { it.toMutableList() } - stopIds = entry.stopIds.map { it.toMutableList() } - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun polylines(polylines: List) = polylines(JsonField.of(polylines)) - - /** - * Sets [Builder.polylines] to an arbitrary JSON value. - * - * You should usually call [Builder.polylines] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines.map { it.toMutableList() } - } - - /** - * Adds a single [Polyline] to [polylines]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPolyline(polyline: Polyline) = apply { - polylines = - (polylines ?: JsonField.of(mutableListOf())).also { - checkKnown("polylines", it).add(polyline) - } + internal fun from(polyline: Polyline) = apply { + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() } - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + fun length(length: Long) = length(JsonField.of(length)) /** - * Sets [Builder.routeId] to an arbitrary JSON value. + * Sets [Builder.length] to an arbitrary JSON value. * - * You should usually call [Builder.routeId] with a well-typed [String] value + * You should usually call [Builder.length] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun stopGroupings(stopGroupings: List) = - stopGroupings(JsonField.of(stopGroupings)) + fun length(length: JsonField) = apply { this.length = length } - /** - * Sets [Builder.stopGroupings] to an arbitrary JSON value. - * - * You should usually call [Builder.stopGroupings] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun stopGroupings(stopGroupings: JsonField>) = apply { - this.stopGroupings = stopGroupings.map { it.toMutableList() } - } + fun levels(levels: String) = levels(JsonField.of(levels)) /** - * Adds a single [StopGrouping] to [stopGroupings]. + * Sets [Builder.levels] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.levels] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun addStopGrouping(stopGrouping: StopGrouping) = apply { - stopGroupings = - (stopGroupings ?: JsonField.of(mutableListOf())).also { - checkKnown("stopGroupings", it).add(stopGrouping) - } - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + fun levels(levels: JsonField) = apply { this.levels = levels } - /** - * Sets [Builder.stopIds] to an arbitrary JSON value. - * - * You should usually call [Builder.stopIds] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stopIds(stopIds: JsonField>) = apply { - this.stopIds = stopIds.map { it.toMutableList() } - } + fun points(points: String) = points(JsonField.of(points)) /** - * Adds a single [String] to [stopIds]. + * Sets [Builder.points] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.points] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun addStopId(stopId: String) = apply { - stopIds = - (stopIds ?: JsonField.of(mutableListOf())).also { - checkKnown("stopIds", it).add(stopId) - } - } + fun points(points: JsonField) = apply { this.points = points } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -853,31 +913,24 @@ private constructor( } /** - * Returns an immutable instance of [Entry]. + * Returns an immutable instance of [Polyline]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Entry = - Entry( - (polylines ?: JsonMissing.of()).map { it.toImmutable() }, - routeId, - (stopGroupings ?: JsonMissing.of()).map { it.toImmutable() }, - (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): Polyline = + Polyline(length, levels, points, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): Entry = apply { + fun validate(): Polyline = apply { if (validated) { return@apply } - polylines().ifPresent { it.forEach { it.validate() } } - routeId() - stopGroupings().ifPresent { it.forEach { it.validate() } } - stopIds() + length() + levels() + points() validated = true } @@ -897,79 +950,358 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (routeId.asKnown().isPresent) 1 else 0) + - (stopGroupings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (stopIds.asKnown().getOrNull()?.size ?: 0) + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) - class Polyline - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("length") - @ExcludeMissing - length: JsonField = JsonMissing.of(), - @JsonProperty("levels") - @ExcludeMissing - levels: JsonField = JsonMissing.of(), - @JsonProperty("points") - @ExcludeMissing - points: JsonField = JsonMissing.of(), - ) : this(length, levels, points, mutableMapOf()) + return other is Polyline && + length == other.length && + levels == other.levels && + points == other.points && + additionalProperties == other.additionalProperties + } - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun length(): Optional = length.getOptional("length") + private val hashCode: Int by lazy { + Objects.hash(length, levels, points, additionalProperties) + } - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun levels(): Optional = levels.getOptional("levels") + override fun hashCode(): Int = hashCode - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun points(): Optional = points.getOptional("points") + override fun toString() = + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [length]. - * - * Unlike [length], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + class StopGrouping + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val polylines: JsonField>, + private val stopIds: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [levels]. - * - * Unlike [levels], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("levels") + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("polylines") @ExcludeMissing - fun _levels(): JsonField = levels + polylines: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + stopIds: JsonField> = JsonMissing.of(), + ) : this(id, name, polylines, stopIds, mutableMapOf()) - /** - * Returns the raw JSON value of [points]. - * - * Unlike [points], this method doesn't throw if the JSON field has an - * unexpected type. + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun polylines(): Optional> = polylines.getOptional("polylines") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopIds(): Optional> = stopIds.getOptional("stopIds") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [polylines]. + * + * Unlike [polylines], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("polylines") + @ExcludeMissing + fun _polylines(): JsonField> = polylines + + /** + * Returns the raw JSON value of [stopIds]. + * + * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StopGrouping]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopGrouping]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var polylines: JsonField>? = null + private var stopIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopGrouping: StopGrouping) = apply { + id = stopGrouping.id + name = stopGrouping.name + polylines = stopGrouping.polylines.map { it.toMutableList() } + stopIds = stopGrouping.stopIds.map { it.toMutableList() } + additionalProperties = stopGrouping.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("points") + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun polylines(polylines: List) = polylines(JsonField.of(polylines)) + + /** + * Sets [Builder.polylines] to an arbitrary JSON value. + * + * You should usually call [Builder.polylines] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun polylines(polylines: JsonField>) = apply { + this.polylines = polylines.map { it.toMutableList() } + } + + /** + * Adds a single [Polyline] to [polylines]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPolyline(polyline: Polyline) = apply { + polylines = + (polylines ?: JsonField.of(mutableListOf())).also { + checkKnown("polylines", it).add(polyline) + } + } + + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + + /** + * Sets [Builder.stopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.stopIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [stopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopGrouping]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopGrouping = + StopGrouping( + id, + name, + (polylines ?: JsonMissing.of()).map { it.toImmutable() }, + (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopGrouping = apply { + if (validated) { + return@apply + } + + id() + name().ifPresent { it.validate() } + polylines().ifPresent { it.forEach { it.validate() } } + stopIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) + + class Name + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val names: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("names") + @ExcludeMissing + names: JsonField> = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + ) : this(name, names, type, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun names(): Optional> = names.getOptional("names") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [names]. + * + * Unlike [names], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("names") @ExcludeMissing - fun _points(): JsonField = points + fun _names(): JsonField> = names + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -985,59 +1317,74 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Polyline]. */ + /** Returns a mutable builder for constructing an instance of [Name]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Polyline]. */ + /** A builder for [Name]. */ class Builder internal constructor() { - private var length: JsonField = JsonMissing.of() - private var levels: JsonField = JsonMissing.of() - private var points: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var names: JsonField>? = null + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(polyline: Polyline) = apply { - length = polyline.length - levels = polyline.levels - points = polyline.points - additionalProperties = polyline.additionalProperties.toMutableMap() + internal fun from(name: Name) = apply { + this.name = name.name + names = name.names.map { it.toMutableList() } + type = name.type + additionalProperties = name.additionalProperties.toMutableMap() } - fun length(length: Long) = length(JsonField.of(length)) + fun name(name: String) = name(JsonField.of(name)) /** - * Sets [Builder.length] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.length] with a well-typed [Long] value + * You should usually call [Builder.name] with a well-typed [String] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun length(length: JsonField) = apply { this.length = length } + fun name(name: JsonField) = apply { this.name = name } - fun levels(levels: String) = levels(JsonField.of(levels)) + fun names(names: List) = names(JsonField.of(names)) /** - * Sets [Builder.levels] to an arbitrary JSON value. + * Sets [Builder.names] to an arbitrary JSON value. * - * You should usually call [Builder.levels] with a well-typed [String] value - * instead. This method is primarily for setting the field to an + * You should usually call [Builder.names] with a well-typed `List` + * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun levels(levels: JsonField) = apply { this.levels = levels } + fun names(names: JsonField>) = apply { + this.names = names.map { it.toMutableList() } + } - fun points(points: String) = points(JsonField.of(points)) + /** + * Adds a single [String] to [names]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addName(name: String) = apply { + names = + (names ?: JsonField.of(mutableListOf())).also { + checkKnown("names", it).add(name) + } + } + + fun type(type: String) = type(JsonField.of(type)) /** - * Sets [Builder.points] to an arbitrary JSON value. + * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.points] with a well-typed [String] value + * You should usually call [Builder.type] with a well-typed [String] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun points(points: JsonField) = apply { this.points = points } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1062,24 +1409,29 @@ private constructor( } /** - * Returns an immutable instance of [Polyline]. + * Returns an immutable instance of [Name]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Polyline = - Polyline(length, levels, points, additionalProperties.toMutableMap()) + fun build(): Name = + Name( + name, + (names ?: JsonMissing.of()).map { it.toImmutable() }, + type, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Polyline = apply { + fun validate(): Name = apply { if (validated) { return@apply } - length() - levels() - points() + name() + names() + type() validated = true } @@ -1099,117 +1451,99 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (length.asKnown().isPresent) 1 else 0) + - (if (levels.asKnown().isPresent) 1 else 0) + - (if (points.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + (names.asKnown().getOrNull()?.size ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Polyline && - length == other.length && - levels == other.levels && - points == other.points && + return other is Name && + name == other.name && + names == other.names && + type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(length, levels, points, additionalProperties) + Objects.hash(name, names, type, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" } - class StopGrouping + class Polyline @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, - private val name: JsonField, - private val polylines: JsonField>, - private val stopIds: JsonField>, + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("name") + @JsonProperty("length") @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("polylines") + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") @ExcludeMissing - polylines: JsonField> = JsonMissing.of(), - @JsonProperty("stopIds") + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") @ExcludeMissing - stopIds: JsonField> = JsonMissing.of(), - ) : this(id, name, polylines, stopIds, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun name(): Optional = name.getOptional("name") + fun length(): Optional = length.getOptional("length") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun polylines(): Optional> = polylines.getOptional("polylines") + fun levels(): Optional = levels.getOptional("levels") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun stopIds(): Optional> = stopIds.getOptional("stopIds") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun points(): Optional = points.getOptional("points") /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [length]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [length], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length /** - * Returns the raw JSON value of [polylines]. + * Returns the raw JSON value of [levels]. * - * Unlike [polylines], this method doesn't throw if the JSON field has an + * Unlike [levels], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("polylines") + @JsonProperty("levels") @ExcludeMissing - fun _polylines(): JsonField> = polylines + fun _levels(): JsonField = levels /** - * Returns the raw JSON value of [stopIds]. + * Returns the raw JSON value of [points]. * - * Unlike [stopIds], this method doesn't throw if the JSON field has an + * Unlike [points], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("stopIds") + @JsonProperty("points") @ExcludeMissing - fun _stopIds(): JsonField> = stopIds + fun _points(): JsonField = points @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1225,105 +1559,59 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [StopGrouping]. - */ + /** Returns a mutable builder for constructing an instance of [Polyline]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [StopGrouping]. */ + /** A builder for [Polyline]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var polylines: JsonField>? = null - private var stopIds: JsonField>? = null + private var length: JsonField = JsonMissing.of() + private var levels: JsonField = JsonMissing.of() + private var points: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(stopGrouping: StopGrouping) = apply { - id = stopGrouping.id - name = stopGrouping.name - polylines = stopGrouping.polylines.map { it.toMutableList() } - stopIds = stopGrouping.stopIds.map { it.toMutableList() } - additionalProperties = stopGrouping.additionalProperties.toMutableMap() + internal fun from(polyline: Polyline) = apply { + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + fun length(length: Long) = length(JsonField.of(length)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.length] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] value + * You should usually call [Builder.length] with a well-typed [Long] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun id(id: JsonField) = apply { this.id = id } + fun length(length: JsonField) = apply { this.length = length } - fun name(name: Name) = name(JsonField.of(name)) + fun levels(levels: String) = levels(JsonField.of(levels)) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.levels] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [Name] value + * You should usually call [Builder.levels] with a well-typed [String] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } - - fun polylines(polylines: List) = - polylines(JsonField.of(polylines)) - - /** - * Sets [Builder.polylines] to an arbitrary JSON value. - * - * You should usually call [Builder.polylines] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines.map { it.toMutableList() } - } - - /** - * Adds a single [Polyline] to [polylines]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addPolyline(polyline: Polyline) = apply { - polylines = - (polylines ?: JsonField.of(mutableListOf())).also { - checkKnown("polylines", it).add(polyline) - } - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + fun levels(levels: JsonField) = apply { this.levels = levels } - /** - * Sets [Builder.stopIds] to an arbitrary JSON value. - * - * You should usually call [Builder.stopIds] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun stopIds(stopIds: JsonField>) = apply { - this.stopIds = stopIds.map { it.toMutableList() } - } + fun points(points: String) = points(JsonField.of(points)) /** - * Adds a single [String] to [stopIds]. + * Sets [Builder.points] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.points] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addStopId(stopId: String) = apply { - stopIds = - (stopIds ?: JsonField.of(mutableListOf())).also { - checkKnown("stopIds", it).add(stopId) - } - } + fun points(points: JsonField) = apply { this.points = points } fun additionalProperties(additionalProperties: Map) = apply { @@ -1348,31 +1636,24 @@ private constructor( } /** - * Returns an immutable instance of [StopGrouping]. + * Returns an immutable instance of [Polyline]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): StopGrouping = - StopGrouping( - id, - name, - (polylines ?: JsonMissing.of()).map { it.toImmutable() }, - (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): Polyline = + Polyline(length, levels, points, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): StopGrouping = apply { + fun validate(): Polyline = apply { if (validated) { return@apply } - id() - name().ifPresent { it.validate() } - polylines().ifPresent { it.forEach { it.validate() } } - stopIds() + length() + levels() + points() validated = true } @@ -1392,512 +1673,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (name.asKnown().getOrNull()?.validity() ?: 0) + - (polylines.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (stopIds.asKnown().getOrNull()?.size ?: 0) - - class Name - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonField, - private val names: JsonField>, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("names") - @ExcludeMissing - names: JsonField> = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - ) : this(name, names, type, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun names(): Optional> = names.getOptional("names") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [names]. - * - * Unlike [names], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("names") - @ExcludeMissing - fun _names(): JsonField> = names - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Name]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Name]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var names: JsonField>? = null - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - names = name.names.map { it.toMutableList() } - type = name.type - additionalProperties = name.additionalProperties.toMutableMap() - } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun names(names: List) = names(JsonField.of(names)) - - /** - * Sets [Builder.names] to an arbitrary JSON value. - * - * You should usually call [Builder.names] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun names(names: JsonField>) = apply { - this.names = names.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [names]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addName(name: String) = apply { - names = - (names ?: JsonField.of(mutableListOf())).also { - checkKnown("names", it).add(name) - } - } - - fun type(type: String) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Name]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Name = - Name( - name, - (names ?: JsonMissing.of()).map { it.toImmutable() }, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - name() - names() - type() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OnebusawaySdkInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + - (names.asKnown().getOrNull()?.size ?: 0) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && - name == other.name && - names == other.names && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, names, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" - } - - class Polyline - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("length") - @ExcludeMissing - length: JsonField = JsonMissing.of(), - @JsonProperty("levels") - @ExcludeMissing - levels: JsonField = JsonMissing.of(), - @JsonProperty("points") - @ExcludeMissing - points: JsonField = JsonMissing.of(), - ) : this(length, levels, points, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun length(): Optional = length.getOptional("length") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun levels(): Optional = levels.getOptional("levels") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun points(): Optional = points.getOptional("points") - - /** - * Returns the raw JSON value of [length]. - * - * Unlike [length], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("length") - @ExcludeMissing - fun _length(): JsonField = length - - /** - * Returns the raw JSON value of [levels]. - * - * Unlike [levels], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("levels") - @ExcludeMissing - fun _levels(): JsonField = levels - - /** - * Returns the raw JSON value of [points]. - * - * Unlike [points], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("points") - @ExcludeMissing - fun _points(): JsonField = points - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Polyline]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Polyline]. */ - class Builder internal constructor() { - - private var length: JsonField = JsonMissing.of() - private var levels: JsonField = JsonMissing.of() - private var points: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(polyline: Polyline) = apply { - length = polyline.length - levels = polyline.levels - points = polyline.points - additionalProperties = polyline.additionalProperties.toMutableMap() - } - - fun length(length: Long) = length(JsonField.of(length)) - - /** - * Sets [Builder.length] to an arbitrary JSON value. - * - * You should usually call [Builder.length] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun length(length: JsonField) = apply { this.length = length } - - fun levels(levels: String) = levels(JsonField.of(levels)) - - /** - * Sets [Builder.levels] to an arbitrary JSON value. - * - * You should usually call [Builder.levels] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun levels(levels: JsonField) = apply { this.levels = levels } - - fun points(points: String) = points(JsonField.of(points)) - - /** - * Sets [Builder.points] to an arbitrary JSON value. - * - * You should usually call [Builder.points] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun points(points: JsonField) = apply { this.points = points } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Polyline]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Polyline = - Polyline( - length, - levels, - points, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Polyline = apply { - if (validated) { - return@apply - } - - length() - levels() - points() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OnebusawaySdkInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (length.asKnown().isPresent) 1 else 0) + - (if (levels.asKnown().isPresent) 1 else 0) + - (if (points.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Polyline && - length == other.length && - levels == other.levels && - points == other.points && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(length, levels, points, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" - } + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is StopGrouping && - id == other.id && - name == other.name && - polylines == other.polylines && - stopIds == other.stopIds && + return other is Polyline && + length == other.length && + levels == other.levels && + points == other.points && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, name, polylines, stopIds, additionalProperties) + Objects.hash(length, levels, points, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1905,22 +1704,22 @@ private constructor( return true } - return other is Entry && + return other is StopGrouping && + id == other.id && + name == other.name && polylines == other.polylines && - routeId == other.routeId && - stopGroupings == other.stopGroupings && stopIds == other.stopIds && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) + Objects.hash(id, name, polylines, stopIds, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" + "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1928,20 +1727,22 @@ private constructor( return true } - return other is InnerData && - entry == other.entry && - references == other.references && + return other is Entry && + polylines == other.polylines && + routeId == other.routeId && + stopGroupings == other.stopGroupings && + stopIds == other.stopIds && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(entry, references, additionalProperties) + Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "InnerData{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1950,15 +1751,17 @@ private constructor( } return other is Data && - data == other.data && + entry == other.entry && + references == other.references && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "Data{data=$data, additionalProperties=$additionalProperties}" + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt index 406c02a..6e5e903 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -541,15 +541,15 @@ private constructor( private constructor( private val lastLocationUpdateTime: JsonField, private val lastUpdateTime: JsonField, - private val location: JsonField, - private val tripId: JsonField, - private val tripStatus: JsonField, private val vehicleId: JsonField, + private val location: JsonField, private val occupancyCapacity: JsonField, private val occupancyCount: JsonField, private val occupancyStatus: JsonField, private val phase: JsonField, private val status: JsonField, + private val tripId: JsonField, + private val tripStatus: JsonField, private val additionalProperties: MutableMap, ) { @@ -561,18 +561,12 @@ private constructor( @JsonProperty("lastUpdateTime") @ExcludeMissing lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - location: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - tripId: JsonField = JsonMissing.of(), - @JsonProperty("tripStatus") - @ExcludeMissing - tripStatus: JsonField = JsonMissing.of(), @JsonProperty("vehicleId") @ExcludeMissing vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + location: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing occupancyCapacity: JsonField = JsonMissing.of(), @@ -583,19 +577,27 @@ private constructor( @ExcludeMissing occupancyStatus: JsonField = JsonMissing.of(), @JsonProperty("phase") @ExcludeMissing phase: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + tripStatus: JsonField = JsonMissing.of(), ) : this( lastLocationUpdateTime, lastUpdateTime, - location, - tripId, - tripStatus, vehicleId, + location, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, + tripId, + tripStatus, mutableMapOf(), ) @@ -619,28 +621,13 @@ private constructor( * is unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun location(): Location = location.getRequired("location") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tripId(): String = tripId.getRequired("tripId") - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tripStatus(): TripStatus = tripStatus.getRequired("tripStatus") + fun vehicleId(): String = vehicleId.getRequired("vehicleId") /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun vehicleId(): String = vehicleId.getRequired("vehicleId") + fun location(): Optional = location.getOptional("location") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type @@ -673,6 +660,18 @@ private constructor( */ fun status(): Optional = status.getOptional("status") + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tripId(): Optional = tripId.getOptional("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tripStatus(): Optional = tripStatus.getOptional("tripStatus") + /** * Returns the raw JSON value of [lastLocationUpdateTime]. * @@ -694,41 +693,24 @@ private constructor( fun _lastUpdateTime(): JsonField = lastUpdateTime /** - * Returns the raw JSON value of [location]. - * - * Unlike [location], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("location") - @ExcludeMissing - fun _location(): JsonField = location - - /** - * Returns the raw JSON value of [tripId]. - * - * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - - /** - * Returns the raw JSON value of [tripStatus]. + * Returns the raw JSON value of [vehicleId]. * - * Unlike [tripStatus], this method doesn't throw if the JSON field has an unexpected + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("tripStatus") + @JsonProperty("vehicleId") @ExcludeMissing - fun _tripStatus(): JsonField = tripStatus + fun _vehicleId(): JsonField = vehicleId /** - * Returns the raw JSON value of [vehicleId]. + * Returns the raw JSON value of [location]. * - * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * Unlike [location], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("vehicleId") + @JsonProperty("location") @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId + fun _location(): JsonField = location /** * Returns the raw JSON value of [occupancyCapacity]. @@ -774,6 +756,23 @@ private constructor( */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [tripStatus]. + * + * Unlike [tripStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -795,9 +794,6 @@ private constructor( * ```java * .lastLocationUpdateTime() * .lastUpdateTime() - * .location() - * .tripId() - * .tripStatus() * .vehicleId() * ``` */ @@ -809,30 +805,30 @@ private constructor( private var lastLocationUpdateTime: JsonField? = null private var lastUpdateTime: JsonField? = null - private var location: JsonField? = null - private var tripId: JsonField? = null - private var tripStatus: JsonField? = null private var vehicleId: JsonField? = null + private var location: JsonField = JsonMissing.of() private var occupancyCapacity: JsonField = JsonMissing.of() private var occupancyCount: JsonField = JsonMissing.of() private var occupancyStatus: JsonField = JsonMissing.of() private var phase: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() + private var tripId: JsonField = JsonMissing.of() + private var tripStatus: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { lastLocationUpdateTime = list.lastLocationUpdateTime lastUpdateTime = list.lastUpdateTime - location = list.location - tripId = list.tripId - tripStatus = list.tripStatus vehicleId = list.vehicleId + location = list.location occupancyCapacity = list.occupancyCapacity occupancyCount = list.occupancyCount occupancyStatus = list.occupancyStatus phase = list.phase status = list.status + tripId = list.tripId + tripStatus = list.tripStatus additionalProperties = list.additionalProperties.toMutableMap() } @@ -864,51 +860,27 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - fun location(location: Location) = location(JsonField.of(location)) - - /** - * Sets [Builder.location] to an arbitrary JSON value. - * - * You should usually call [Builder.location] with a well-typed [Location] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun location(location: JsonField) = apply { this.location = location } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - /** - * Sets [Builder.tripId] to an arbitrary JSON value. - * - * You should usually call [Builder.tripId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** - * Sets [Builder.tripStatus] to an arbitrary JSON value. + * Sets [Builder.vehicleId] to an arbitrary JSON value. * - * You should usually call [Builder.tripStatus] with a well-typed [TripStatus] value + * You should usually call [Builder.vehicleId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun tripStatus(tripStatus: JsonField) = apply { - this.tripStatus = tripStatus - } + fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + fun location(location: Location) = location(JsonField.of(location)) /** - * Sets [Builder.vehicleId] to an arbitrary JSON value. + * Sets [Builder.location] to an arbitrary JSON value. * - * You should usually call [Builder.vehicleId] with a well-typed [String] value + * You should usually call [Builder.location] with a well-typed [Location] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } + fun location(location: JsonField) = apply { this.location = location } fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -974,6 +946,30 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) + + /** + * Sets [Builder.tripStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.tripStatus] with a well-typed [TripStatus] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tripStatus(tripStatus: JsonField) = apply { + this.tripStatus = tripStatus + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1005,9 +1001,6 @@ private constructor( * ```java * .lastLocationUpdateTime() * .lastUpdateTime() - * .location() - * .tripId() - * .tripStatus() * .vehicleId() * ``` * @@ -1017,15 +1010,15 @@ private constructor( List( checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), checkRequired("lastUpdateTime", lastUpdateTime), - checkRequired("location", location), - checkRequired("tripId", tripId), - checkRequired("tripStatus", tripStatus), checkRequired("vehicleId", vehicleId), + location, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, + tripId, + tripStatus, additionalProperties.toMutableMap(), ) } @@ -1039,15 +1032,15 @@ private constructor( lastLocationUpdateTime() lastUpdateTime() - location().validate() - tripId() - tripStatus().validate() vehicleId() + location().ifPresent { it.validate() } occupancyCapacity() occupancyCount() occupancyStatus() phase() status() + tripId() + tripStatus().ifPresent { it.validate() } validated = true } @@ -1069,15 +1062,15 @@ private constructor( internal fun validity(): Int = (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + - (location.asKnown().getOrNull()?.validity() ?: 0) + - (if (tripId.asKnown().isPresent) 1 else 0) + - (tripStatus.asKnown().getOrNull()?.validity() ?: 0) + (if (vehicleId.asKnown().isPresent) 1 else 0) + + (location.asKnown().getOrNull()?.validity() ?: 0) + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + (if (occupancyCount.asKnown().isPresent) 1 else 0) + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + (if (phase.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (tripStatus.asKnown().getOrNull()?.validity() ?: 0) class Location @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -3076,15 +3069,15 @@ private constructor( return other is List && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && - location == other.location && - tripId == other.tripId && - tripStatus == other.tripStatus && vehicleId == other.vehicleId && + location == other.location && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && status == other.status && + tripId == other.tripId && + tripStatus == other.tripStatus && additionalProperties == other.additionalProperties } @@ -3092,15 +3085,15 @@ private constructor( Objects.hash( lastLocationUpdateTime, lastUpdateTime, - location, - tripId, - tripStatus, vehicleId, + location, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, + tripId, + tripStatus, additionalProperties, ) } @@ -3108,7 +3101,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "List{lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, location=$location, tripId=$tripId, tripStatus=$tripStatus, vehicleId=$vehicleId, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, status=$status, additionalProperties=$additionalProperties}" + "List{lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, vehicleId=$vehicleId, location=$location, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, status=$status, tripId=$tripId, tripStatus=$tripStatus, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt index 421a7c8..7e35cf7 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt @@ -20,195 +20,183 @@ internal class StopsForRouteListResponseTest { .version(0L) .data( StopsForRouteListResponse.Data.builder() - .data( - StopsForRouteListResponse.Data.InnerData.builder() - .entry( - StopsForRouteListResponse.Data.InnerData.Entry.builder() + .entry( + StopsForRouteListResponse.Data.Entry.builder() + .addPolyline( + StopsForRouteListResponse.Data.Entry.Polyline.builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .routeId("1_100224") + .addStopGrouping( + StopsForRouteListResponse.Data.Entry.StopGrouping.builder() + .id("id") + .name( + StopsForRouteListResponse.Data.Entry.StopGrouping.Name + .builder() + .name("name") + .addName("string") + .type("type") + .build() + ) .addPolyline( - StopsForRouteListResponse.Data.InnerData.Entry.Polyline + StopsForRouteListResponse.Data.Entry.StopGrouping + .Polyline .builder() .length(0L) .levels("levels") .points("points") .build() ) - .routeId("1_100224") - .addStopGrouping( - StopsForRouteListResponse.Data.InnerData.Entry - .StopGrouping - .builder() - .id("id") - .name( - StopsForRouteListResponse.Data.InnerData.Entry - .StopGrouping - .Name - .builder() - .name("name") - .addName("string") - .type("type") - .build() - ) - .addPolyline( - StopsForRouteListResponse.Data.InnerData.Entry - .StopGrouping - .Polyline - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .addStopId("string") - .build() - ) - .addStopId("1_10911") + .addStopId("string") .build() ) - .references( - References.builder() - .addAgency( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) + .addStopId("1_10911") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) .build() ) - .addRoute( - References.Route.builder() - .id("id") + .addAllAffect( + References.Situation.AllAffect.builder() .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) - .build() - ) - .addAllAffect( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( References.Situation.Consequence .ConditionDetails + .DiversionPath .builder() - .diversionPath( - References.Situation.Consequence - .ConditionDetails - .DiversionPath - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .addDiversionStopId("string") + .length(0L) + .levels("levels") + .points("points") .build() ) - .build() - ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) - .build() - ) - .reason( - References.Situation.Reason.EQUIPMENT_REASON - ) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") - .build() - ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addDiversionStopId("string") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") .build() ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) .build() ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") .build() ) .build() ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) .build() ) .build() @@ -222,192 +210,181 @@ internal class StopsForRouteListResponseTest { assertThat(stopsForRouteListResponse.data()) .isEqualTo( StopsForRouteListResponse.Data.builder() - .data( - StopsForRouteListResponse.Data.InnerData.builder() - .entry( - StopsForRouteListResponse.Data.InnerData.Entry.builder() + .entry( + StopsForRouteListResponse.Data.Entry.builder() + .addPolyline( + StopsForRouteListResponse.Data.Entry.Polyline.builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .routeId("1_100224") + .addStopGrouping( + StopsForRouteListResponse.Data.Entry.StopGrouping.builder() + .id("id") + .name( + StopsForRouteListResponse.Data.Entry.StopGrouping.Name + .builder() + .name("name") + .addName("string") + .type("type") + .build() + ) .addPolyline( - StopsForRouteListResponse.Data.InnerData.Entry.Polyline + StopsForRouteListResponse.Data.Entry.StopGrouping.Polyline .builder() .length(0L) .levels("levels") .points("points") .build() ) - .routeId("1_100224") - .addStopGrouping( - StopsForRouteListResponse.Data.InnerData.Entry.StopGrouping - .builder() - .id("id") - .name( - StopsForRouteListResponse.Data.InnerData.Entry - .StopGrouping - .Name - .builder() - .name("name") - .addName("string") - .type("type") - .build() - ) - .addPolyline( - StopsForRouteListResponse.Data.InnerData.Entry - .StopGrouping - .Polyline - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .addStopId("string") - .build() - ) - .addStopId("1_10911") + .addStopId("string") .build() ) - .references( - References.builder() - .addAgency( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) + .addStopId("1_10911") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) .build() ) - .addRoute( - References.Route.builder() - .id("id") + .addAllAffect( + References.Situation.AllAffect.builder() .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) - .build() - ) - .addAllAffect( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( References.Situation.Consequence .ConditionDetails + .DiversionPath .builder() - .diversionPath( - References.Situation.Consequence - .ConditionDetails - .DiversionPath - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .addDiversionStopId("string") + .length(0L) + .levels("levels") + .points("points") .build() ) - .build() - ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) - .build() - ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") - .build() - ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addDiversionStopId("string") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") .build() ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) .build() ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") .build() ) .build() ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) .build() ) .build() @@ -425,193 +402,181 @@ internal class StopsForRouteListResponseTest { .version(0L) .data( StopsForRouteListResponse.Data.builder() - .data( - StopsForRouteListResponse.Data.InnerData.builder() - .entry( - StopsForRouteListResponse.Data.InnerData.Entry.builder() + .entry( + StopsForRouteListResponse.Data.Entry.builder() + .addPolyline( + StopsForRouteListResponse.Data.Entry.Polyline.builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .routeId("1_100224") + .addStopGrouping( + StopsForRouteListResponse.Data.Entry.StopGrouping.builder() + .id("id") + .name( + StopsForRouteListResponse.Data.Entry.StopGrouping.Name + .builder() + .name("name") + .addName("string") + .type("type") + .build() + ) .addPolyline( - StopsForRouteListResponse.Data.InnerData.Entry.Polyline + StopsForRouteListResponse.Data.Entry.StopGrouping + .Polyline .builder() .length(0L) .levels("levels") .points("points") .build() ) - .routeId("1_100224") - .addStopGrouping( - StopsForRouteListResponse.Data.InnerData.Entry - .StopGrouping - .builder() - .id("id") - .name( - StopsForRouteListResponse.Data.InnerData.Entry - .StopGrouping - .Name - .builder() - .name("name") - .addName("string") - .type("type") - .build() - ) - .addPolyline( - StopsForRouteListResponse.Data.InnerData.Entry - .StopGrouping - .Polyline - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .addStopId("string") - .build() - ) - .addStopId("1_10911") + .addStopId("string") .build() ) - .references( - References.builder() - .addAgency( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) + .addStopId("1_10911") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) .build() ) - .addRoute( - References.Route.builder() - .id("id") + .addAllAffect( + References.Situation.AllAffect.builder() .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") .build() ) - .addSituation( - References.Situation.builder() - .id("id") - .creationTime(0L) - .addActiveWindow( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) - .build() - ) - .addAllAffect( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) - .consequenceMessage("consequenceMessage") - .addConsequence( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( References.Situation.Consequence .ConditionDetails + .DiversionPath .builder() - .diversionPath( - References.Situation.Consequence - .ConditionDetails - .DiversionPath - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .addDiversionStopId("string") + .length(0L) + .levels("levels") + .points("points") .build() ) - .build() - ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .addPublicationWindow( - References.Situation.PublicationWindow.builder() - .from(0L) - .to(0L) - .build() - ) - .reason( - References.Situation.Reason.EQUIPMENT_REASON - ) - .severity("severity") - .summary( - References.Situation.Summary.builder() - .lang("lang") - .value("value") - .build() - ) - .url( - References.Situation.Url.builder() - .lang("lang") - .value("value") + .addDiversionStopId("string") .build() ) .build() ) - .addStop( - References.Stop.builder() - .id("id") - .lat(0.0) - .locationType(0L) - .lon(0.0) - .name("name") - .parent("parent") - .addRouteId("string") - .addStaticRouteId("string") - .code("code") - .direction("direction") - .wheelchairBoarding("wheelchairBoarding") + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") .build() ) - .addStopTime( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) .build() ) - .addTrip( - References.Trip.builder() - .id("id") - .routeId("routeId") - .serviceId("serviceId") - .blockId("blockId") - .directionId("directionId") - .peakOffpeak(0L) - .routeShortName("routeShortName") - .shapeId("shapeId") - .timeZone("timeZone") - .tripHeadsign("tripHeadsign") - .tripShortName("tripShortName") + .reason(References.Situation.Reason.EQUIPMENT_REASON) + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") .build() ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt index 401640e..48feaa0 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt @@ -25,12 +25,18 @@ internal class VehiclesForAgencyListResponseTest { VehiclesForAgencyListResponse.Data.List.builder() .lastLocationUpdateTime(0L) .lastUpdateTime(0L) + .vehicleId("vehicleId") .location( VehiclesForAgencyListResponse.Data.List.Location.builder() .lat(0.0) .lon(0.0) .build() ) + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .status("status") .tripId("tripId") .tripStatus( VehiclesForAgencyListResponse.Data.List.TripStatus.builder() @@ -77,12 +83,6 @@ internal class VehiclesForAgencyListResponseTest { .vehicleId("vehicleId") .build() ) - .vehicleId("vehicleId") - .occupancyCapacity(0L) - .occupancyCount(0L) - .occupancyStatus("occupancyStatus") - .phase("phase") - .status("status") .build() ) .references( @@ -244,12 +244,18 @@ internal class VehiclesForAgencyListResponseTest { VehiclesForAgencyListResponse.Data.List.builder() .lastLocationUpdateTime(0L) .lastUpdateTime(0L) + .vehicleId("vehicleId") .location( VehiclesForAgencyListResponse.Data.List.Location.builder() .lat(0.0) .lon(0.0) .build() ) + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .status("status") .tripId("tripId") .tripStatus( VehiclesForAgencyListResponse.Data.List.TripStatus.builder() @@ -295,12 +301,6 @@ internal class VehiclesForAgencyListResponseTest { .vehicleId("vehicleId") .build() ) - .vehicleId("vehicleId") - .occupancyCapacity(0L) - .occupancyCount(0L) - .occupancyStatus("occupancyStatus") - .phase("phase") - .status("status") .build() ) .references( @@ -465,12 +465,18 @@ internal class VehiclesForAgencyListResponseTest { VehiclesForAgencyListResponse.Data.List.builder() .lastLocationUpdateTime(0L) .lastUpdateTime(0L) + .vehicleId("vehicleId") .location( VehiclesForAgencyListResponse.Data.List.Location.builder() .lat(0.0) .lon(0.0) .build() ) + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .status("status") .tripId("tripId") .tripStatus( VehiclesForAgencyListResponse.Data.List.TripStatus.builder() @@ -517,12 +523,6 @@ internal class VehiclesForAgencyListResponseTest { .vehicleId("vehicleId") .build() ) - .vehicleId("vehicleId") - .occupancyCapacity(0L) - .occupancyCount(0L) - .occupancyStatus("occupancyStatus") - .phase("phase") - .status("status") .build() ) .references( From 0d4ee8e11408ed9a067d3a45038d1bfe45ad58a3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 15:00:14 +0000 Subject: [PATCH 03/38] feat(api): api update --- .stats.yml | 4 +- .../org/onebusaway/models/References.kt | 169 ++---------------- .../AgenciesWithCoverageListResponse.kt | 85 +++++---- .../models/agency/AgencyRetrieveResponse.kt | 49 +---- .../RouteIdsForAgencyListResponse.kt | 85 +++++---- .../RoutesForAgencyListResponse.kt | 84 +++++---- .../RoutesForLocationListResponse.kt | 84 +++++---- .../SearchForRouteListResponse.kt | 84 +++++---- .../SearchForStopListResponse.kt | 84 +++++---- .../StopIdsForAgencyListResponse.kt | 85 +++++---- .../StopsForAgencyListResponse.kt | 84 +++++---- .../StopsForLocationListResponse.kt | 84 +++++---- .../TripsForLocationListResponse.kt | 90 +++++----- .../TripsForRouteListResponse.kt | 84 +++++---- .../VehiclesForAgencyListResponse.kt | 84 +++++---- .../org/onebusaway/models/ReferencesTest.kt | 6 +- .../AgenciesWithCoverageListResponseTest.kt | 12 +- .../agency/AgencyRetrieveResponseTest.kt | 9 +- .../ArrivalAndDepartureListResponseTest.kt | 6 +- ...ArrivalAndDepartureRetrieveResponseTest.kt | 6 +- .../models/block/BlockRetrieveResponseTest.kt | 6 +- .../config/ConfigRetrieveResponseTest.kt | 6 +- .../CurrentTimeRetrieveResponseTest.kt | 6 +- .../models/route/RouteRetrieveResponseTest.kt | 6 +- .../RouteIdsForAgencyListResponseTest.kt | 12 +- .../RoutesForAgencyListResponseTest.kt | 12 +- .../RoutesForLocationListResponseTest.kt | 12 +- .../ScheduleForStopRetrieveResponseTest.kt | 6 +- .../SearchForRouteListResponseTest.kt | 12 +- .../SearchForStopListResponseTest.kt | 12 +- .../models/shape/ShapeRetrieveResponseTest.kt | 6 +- .../models/stop/StopRetrieveResponseTest.kt | 6 +- .../StopIdsForAgencyListResponseTest.kt | 12 +- .../StopsForAgencyListResponseTest.kt | 12 +- .../StopsForLocationListResponseTest.kt | 12 +- .../StopsForRouteListResponseTest.kt | 6 +- .../models/trip/TripRetrieveResponseTest.kt | 6 +- .../TripDetailRetrieveResponseTest.kt | 6 +- .../TripForVehicleRetrieveResponseTest.kt | 6 +- .../TripsForLocationListResponseTest.kt | 12 +- .../TripsForRouteListResponseTest.kt | 12 +- .../VehiclesForAgencyListResponseTest.kt | 12 +- .../proguard/ProGuardCompatibilityTest.kt | 2 +- 43 files changed, 631 insertions(+), 847 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8dd1ce7..1594ba1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-22e1c98416f77779b2c07db272016be0b623b94f6b55cca2d1909f9dc4032c3f.yml -openapi_spec_hash: dd25fff6bc185752d92e93f6e47d3a5e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-0c305d11543f8fc11bd55586c4dc4a724b10de1898cab0fe11364b4db6455752.yml +openapi_spec_hash: 6d10c2ac411cd65f30d200f298577b32 config_hash: 3871f5d21bb38ddd334ec04721dea64d diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt index 0a75035..7469078 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt @@ -10,7 +10,6 @@ import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -import org.onebusaway.core.Enum import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing @@ -1416,7 +1415,7 @@ private constructor( private val consequences: JsonField>, private val description: JsonField, private val publicationWindows: JsonField>, - private val reason: JsonField, + private val reason: JsonField, private val severity: JsonField, private val summary: JsonField, private val url: JsonField, @@ -1447,7 +1446,7 @@ private constructor( @JsonProperty("publicationWindows") @ExcludeMissing publicationWindows: JsonField> = JsonMissing.of(), - @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("severity") @ExcludeMissing severity: JsonField = JsonMissing.of(), @@ -1532,7 +1531,7 @@ private constructor( * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun reason(): Optional = reason.getOptional("reason") + fun reason(): Optional = reason.getOptional("reason") /** * Severity of the situation. @@ -1634,7 +1633,7 @@ private constructor( * * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * Returns the raw JSON value of [severity]. @@ -1694,7 +1693,7 @@ private constructor( private var consequences: JsonField>? = null private var description: JsonField = JsonMissing.of() private var publicationWindows: JsonField>? = null - private var reason: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() private var severity: JsonField = JsonMissing.of() private var summary: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() @@ -1875,16 +1874,16 @@ private constructor( } /** Reason for the service alert, taken from TPEG codes. */ - fun reason(reason: Reason) = reason(JsonField.of(reason)) + fun reason(reason: String) = reason(JsonField.of(reason)) /** * Sets [Builder.reason] to an arbitrary JSON value. * - * You should usually call [Builder.reason] with a well-typed [Reason] value instead. + * You should usually call [Builder.reason] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reason(reason: JsonField) = apply { this.reason = reason } + fun reason(reason: JsonField) = apply { this.reason = reason } /** Severity of the situation. */ fun severity(severity: String) = severity(JsonField.of(severity)) @@ -1985,7 +1984,7 @@ private constructor( consequences().ifPresent { it.forEach { it.validate() } } description().ifPresent { it.validate() } publicationWindows().ifPresent { it.forEach { it.validate() } } - reason().ifPresent { it.validate() } + reason() severity() summary().ifPresent { it.validate() } url().ifPresent { it.validate() } @@ -2016,7 +2015,7 @@ private constructor( (consequences.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (description.asKnown().getOrNull()?.validity() ?: 0) + (publicationWindows.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (reason.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + (if (severity.asKnown().isPresent) 1 else 0) + (summary.asKnown().getOrNull()?.validity() ?: 0) + (url.asKnown().getOrNull()?.validity() ?: 0) @@ -3587,154 +3586,6 @@ private constructor( "PublicationWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" } - /** Reason for the service alert, taken from TPEG codes. */ - class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EQUIPMENT_REASON = of("equipmentReason") - - @JvmField val ENVIRONMENT_REASON = of("environmentReason") - - @JvmField val PERSONNEL_REASON = of("personnelReason") - - @JvmField val MISCELLANEOUS_REASON = of("miscellaneousReason") - - @JvmField val SECURITY_ALERT = of("securityAlert") - - @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) - } - - /** An enum containing [Reason]'s known values. */ - enum class Known { - EQUIPMENT_REASON, - ENVIRONMENT_REASON, - PERSONNEL_REASON, - MISCELLANEOUS_REASON, - SECURITY_ALERT, - } - - /** - * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Reason] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EQUIPMENT_REASON, - ENVIRONMENT_REASON, - PERSONNEL_REASON, - MISCELLANEOUS_REASON, - SECURITY_ALERT, - /** - * An enum member indicating that [Reason] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EQUIPMENT_REASON -> Value.EQUIPMENT_REASON - ENVIRONMENT_REASON -> Value.ENVIRONMENT_REASON - PERSONNEL_REASON -> Value.PERSONNEL_REASON - MISCELLANEOUS_REASON -> Value.MISCELLANEOUS_REASON - SECURITY_ALERT -> Value.SECURITY_ALERT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OnebusawaySdkInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - EQUIPMENT_REASON -> Known.EQUIPMENT_REASON - ENVIRONMENT_REASON -> Known.ENVIRONMENT_REASON - PERSONNEL_REASON -> Known.PERSONNEL_REASON - MISCELLANEOUS_REASON -> Known.MISCELLANEOUS_REASON - SECURITY_ALERT -> Known.SECURITY_ALERT - else -> throw OnebusawaySdkInvalidDataException("Unknown Reason: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OnebusawaySdkInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OnebusawaySdkInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Reason = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OnebusawaySdkInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Reason && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - class Summary @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt index b9e7051..0c30497 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects +import java.util.Optional import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField @@ -303,30 +304,24 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -341,14 +336,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -368,6 +359,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -387,7 +388,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -398,32 +398,19 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -462,6 +449,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -488,7 +488,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -497,9 +496,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -511,9 +510,9 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } references().validate() + limitExceeded() validated = true } @@ -533,9 +532,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) class List @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -854,20 +853,20 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, additionalProperties) + Objects.hash(list, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt index 05eaaf3..c22083c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt @@ -300,7 +300,6 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val entry: JsonField, - private val limitExceeded: JsonField, private val references: JsonField, private val additionalProperties: MutableMap, ) { @@ -308,13 +307,10 @@ private constructor( @JsonCreator private constructor( @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(entry, limitExceeded, references, mutableMapOf()) + ) : this(entry, references, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -322,12 +318,6 @@ private constructor( */ fun entry(): Entry = entry.getRequired("entry") - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -341,16 +331,6 @@ private constructor( */ @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - /** * Returns the raw JSON value of [references]. * @@ -380,7 +360,6 @@ private constructor( * The following fields are required: * ```java * .entry() - * .limitExceeded() * .references() * ``` */ @@ -391,14 +370,12 @@ private constructor( class Builder internal constructor() { private var entry: JsonField? = null - private var limitExceeded: JsonField? = null private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { entry = data.entry - limitExceeded = data.limitExceeded references = data.references additionalProperties = data.additionalProperties.toMutableMap() } @@ -414,19 +391,6 @@ private constructor( */ fun entry(entry: JsonField) = apply { this.entry = entry } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun references(references: References) = references(JsonField.of(references)) /** @@ -467,7 +431,6 @@ private constructor( * The following fields are required: * ```java * .entry() - * .limitExceeded() * .references() * ``` * @@ -476,7 +439,6 @@ private constructor( fun build(): Data = Data( checkRequired("entry", entry), - checkRequired("limitExceeded", limitExceeded), checkRequired("references", references), additionalProperties.toMutableMap(), ) @@ -490,7 +452,6 @@ private constructor( } entry().validate() - limitExceeded() references().validate() validated = true } @@ -512,7 +473,6 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (entry.asKnown().getOrNull()?.validity() ?: 0) + - (if (limitExceeded.asKnown().isPresent) 1 else 0) + (references.asKnown().getOrNull()?.validity() ?: 0) class Entry @@ -1027,19 +987,16 @@ private constructor( return other is Data && entry == other.entry && - limitExceeded == other.limitExceeded && references == other.references && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(entry, limitExceeded, references, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{entry=$entry, limitExceeded=$limitExceeded, references=$references, additionalProperties=$additionalProperties}" + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt index 9da440b..afff93d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects +import java.util.Optional import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField @@ -301,28 +302,22 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -337,14 +332,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -362,6 +353,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -381,7 +382,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -392,32 +392,19 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: List) = list(JsonField.of(list)) /** @@ -456,6 +443,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -482,7 +482,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -491,9 +490,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -505,9 +504,9 @@ private constructor( return@apply } - limitExceeded() list() references().validate() + limitExceeded() validated = true } @@ -527,9 +526,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.size ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (list.asKnown().getOrNull()?.size ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -537,20 +536,20 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, additionalProperties) + Objects.hash(list, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt index 55899d5..1668fe3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt @@ -301,30 +301,24 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -339,14 +333,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -366,6 +356,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -385,7 +385,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -396,32 +395,19 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -460,6 +446,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -486,7 +485,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -495,9 +493,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -509,9 +507,9 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } references().validate() + limitExceeded() validated = true } @@ -531,9 +529,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) class List @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -1055,20 +1053,20 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, additionalProperties) + Objects.hash(list, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt index 9046f31..4996e7c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt @@ -302,18 +302,15 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val outOfRange: JsonField, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @@ -323,13 +320,10 @@ private constructor( @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, outOfRange, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, outOfRange, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -350,14 +344,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -386,6 +376,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -405,7 +405,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .outOfRange() * .references() @@ -417,34 +416,21 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var outOfRange: JsonField? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } outOfRange = data.outOfRange references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -494,6 +480,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -520,7 +519,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .outOfRange() * .references() @@ -530,10 +528,10 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("outOfRange", outOfRange), checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -545,10 +543,10 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } outOfRange() references().validate() + limitExceeded() validated = true } @@ -568,10 +566,10 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (outOfRange.asKnown().isPresent) 1 else 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) class List @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -1093,21 +1091,21 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) + Objects.hash(list, outOfRange, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, outOfRange=$outOfRange, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt index e63e932..9afba19 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt @@ -299,18 +299,15 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val outOfRange: JsonField, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @@ -320,13 +317,10 @@ private constructor( @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, outOfRange, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, outOfRange, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -347,14 +341,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -383,6 +373,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -402,7 +402,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .outOfRange() * .references() @@ -414,34 +413,21 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var outOfRange: JsonField? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } outOfRange = data.outOfRange references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -491,6 +477,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -517,7 +516,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .outOfRange() * .references() @@ -527,10 +525,10 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("outOfRange", outOfRange), checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -542,10 +540,10 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } outOfRange() references().validate() + limitExceeded() validated = true } @@ -565,10 +563,10 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (outOfRange.asKnown().isPresent) 1 else 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) class List @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -1090,21 +1088,21 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) + Objects.hash(list, outOfRange, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, outOfRange=$outOfRange, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt index 746a510..d10d023 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt @@ -299,18 +299,15 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val outOfRange: JsonField, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @@ -320,13 +317,10 @@ private constructor( @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, outOfRange, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, outOfRange, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -347,14 +341,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -383,6 +373,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -402,7 +402,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .outOfRange() * .references() @@ -414,34 +413,21 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var outOfRange: JsonField? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } outOfRange = data.outOfRange references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -491,6 +477,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -517,7 +516,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .outOfRange() * .references() @@ -527,10 +525,10 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("outOfRange", outOfRange), checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -542,10 +540,10 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } outOfRange() references().validate() + limitExceeded() validated = true } @@ -565,10 +563,10 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (outOfRange.asKnown().isPresent) 1 else 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) class List @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -1172,21 +1170,21 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) + Objects.hash(list, outOfRange, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, outOfRange=$outOfRange, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt index 51ec3c5..3f99781 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects +import java.util.Optional import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField @@ -300,28 +301,22 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -336,14 +331,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -361,6 +352,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -380,7 +381,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -391,32 +391,19 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: List) = list(JsonField.of(list)) /** @@ -455,6 +442,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -481,7 +481,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -490,9 +489,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -504,9 +503,9 @@ private constructor( return@apply } - limitExceeded() list() references().validate() + limitExceeded() validated = true } @@ -526,9 +525,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.size ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (list.asKnown().getOrNull()?.size ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -536,20 +535,20 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, additionalProperties) + Objects.hash(list, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt index a896858..3a14a75 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt @@ -301,32 +301,26 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val outOfRange: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("outOfRange") @ExcludeMissing outOfRange: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, outOfRange, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + ) : this(list, references, limitExceeded, outOfRange, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -344,17 +338,13 @@ private constructor( * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") /** * Returns the raw JSON value of [list]. @@ -372,6 +362,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + /** * Returns the raw JSON value of [outOfRange]. * @@ -400,7 +400,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -411,34 +410,21 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var outOfRange: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded outOfRange = data.outOfRange additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: List) = list(JsonField.of(list)) /** @@ -477,6 +463,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) /** @@ -514,7 +513,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -523,9 +521,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, outOfRange, additionalProperties.toMutableMap(), ) @@ -538,9 +536,9 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } references().validate() + limitExceeded() outOfRange() validated = true } @@ -561,9 +559,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) + (if (outOfRange.asKnown().isPresent) 1 else 0) class List @@ -1168,21 +1166,21 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) + Objects.hash(list, references, limitExceeded, outOfRange, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt index 4c7d47c..906127c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt @@ -301,34 +301,28 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val outOfRange: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("outOfRange") @ExcludeMissing outOfRange: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, outOfRange, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + ) : this(list, references, limitExceeded, outOfRange, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -346,17 +340,13 @@ private constructor( * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") /** * Returns the raw JSON value of [list]. @@ -376,6 +366,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + /** * Returns the raw JSON value of [outOfRange]. * @@ -404,7 +404,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -415,34 +414,21 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var outOfRange: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded outOfRange = data.outOfRange additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -481,6 +467,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) /** @@ -518,7 +517,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -527,9 +525,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, outOfRange, additionalProperties.toMutableMap(), ) @@ -542,9 +540,9 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } references().validate() + limitExceeded() outOfRange() validated = true } @@ -565,9 +563,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) + (if (outOfRange.asKnown().isPresent) 1 else 0) class List @@ -1172,21 +1170,21 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) + Objects.hash(list, references, limitExceeded, outOfRange, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt index 362f002..252afb4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt @@ -301,36 +301,28 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val outOfRange: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("outOfRange") @ExcludeMissing outOfRange: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, outOfRange, mutableMapOf()) - - /** - * Indicates if the limit of trips has been exceeded - * - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + ) : this(list, references, limitExceeded, outOfRange, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -345,22 +337,20 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Indicates if the search location is out of range + * Indicates if the limit of trips has been exceeded * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** - * Returns the raw JSON value of [limitExceeded]. + * Indicates if the search location is out of range * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun outOfRange(): Optional = outOfRange.getOptional("outOfRange") /** * Returns the raw JSON value of [list]. @@ -380,6 +370,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + /** * Returns the raw JSON value of [outOfRange]. * @@ -408,7 +408,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -419,35 +418,21 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var outOfRange: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded outOfRange = data.outOfRange additionalProperties = data.additionalProperties.toMutableMap() } - /** Indicates if the limit of trips has been exceeded */ - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -486,6 +471,20 @@ private constructor( this.references = references } + /** Indicates if the limit of trips has been exceeded */ + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + /** Indicates if the search location is out of range */ fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) @@ -524,7 +523,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -533,9 +531,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, outOfRange, additionalProperties.toMutableMap(), ) @@ -548,9 +546,9 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } references().validate() + limitExceeded() outOfRange() validated = true } @@ -571,9 +569,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) + (if (outOfRange.asKnown().isPresent) 1 else 0) class List @@ -3511,21 +3509,21 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) + Objects.hash(list, references, limitExceeded, outOfRange, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt index 7c44f7d..d3c3929 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt @@ -301,30 +301,24 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -339,14 +333,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -366,6 +356,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -385,7 +385,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -396,32 +395,19 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -460,6 +446,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -486,7 +485,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -495,9 +493,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -509,9 +507,9 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } references().validate() + limitExceeded() validated = true } @@ -531,9 +529,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) class List @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -3470,20 +3468,20 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, additionalProperties) + Objects.hash(list, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt index 6e5e903..c49e829 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -302,30 +302,24 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val limitExceeded: JsonField, private val list: JsonField>, private val references: JsonField, + private val limitExceeded: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), - ) : this(limitExceeded, list, references, mutableMapOf()) - - /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + ) : this(list, references, limitExceeded, mutableMapOf()) /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -340,14 +334,10 @@ private constructor( fun references(): References = references.getRequired("references") /** - * Returns the raw JSON value of [limitExceeded]. - * - * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded + fun limitExceeded(): Optional = limitExceeded.getOptional("limitExceeded") /** * Returns the raw JSON value of [list]. @@ -367,6 +357,16 @@ private constructor( @ExcludeMissing fun _references(): JsonField = references + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -386,7 +386,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -397,32 +396,19 @@ private constructor( /** A builder for [Data]. */ class Builder internal constructor() { - private var limitExceeded: JsonField? = null private var list: JsonField>? = null private var references: JsonField? = null + private var limitExceeded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded list = data.list.map { it.toMutableList() } references = data.references + limitExceeded = data.limitExceeded additionalProperties = data.additionalProperties.toMutableMap() } - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** - * Sets [Builder.limitExceeded] to an arbitrary JSON value. - * - * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** @@ -461,6 +447,19 @@ private constructor( this.references = references } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -487,7 +486,6 @@ private constructor( * * The following fields are required: * ```java - * .limitExceeded() * .list() * .references() * ``` @@ -496,9 +494,9 @@ private constructor( */ fun build(): Data = Data( - checkRequired("limitExceeded", limitExceeded), checkRequired("list", list).map { it.toImmutable() }, checkRequired("references", references), + limitExceeded, additionalProperties.toMutableMap(), ) } @@ -510,9 +508,9 @@ private constructor( return@apply } - limitExceeded() list().forEach { it.validate() } references().validate() + limitExceeded() validated = true } @@ -532,9 +530,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (limitExceeded.asKnown().isPresent) 1 else 0) + - (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (references.asKnown().getOrNull()?.validity() ?: 0) + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) class List @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -3110,20 +3108,20 @@ private constructor( } return other is Data && - limitExceeded == other.limitExceeded && list == other.list && references == other.references && + limitExceeded == other.limitExceeded && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(limitExceeded, list, references, additionalProperties) + Objects.hash(list, references, limitExceeded, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + "Data{list=$list, references=$references, limitExceeded=$limitExceeded, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt index f237544..c5907fd 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt @@ -87,7 +87,7 @@ internal class ReferencesTest { .addPublicationWindow( References.Situation.PublicationWindow.builder().from(0L).to(0L).build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -217,7 +217,7 @@ internal class ReferencesTest { .addPublicationWindow( References.Situation.PublicationWindow.builder().from(0L).to(0L).build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder().lang("lang").value("value").build() @@ -349,7 +349,7 @@ internal class ReferencesTest { .addPublicationWindow( References.Situation.PublicationWindow.builder().from(0L).to(0L).build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponseTest.kt index db34d4f..767df9a 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponseTest.kt @@ -20,7 +20,6 @@ internal class AgenciesWithCoverageListResponseTest { .version(0L) .data( AgenciesWithCoverageListResponse.Data.builder() - .limitExceeded(true) .addList( AgenciesWithCoverageListResponse.Data.List.builder() .agencyId("agencyId") @@ -115,7 +114,7 @@ internal class AgenciesWithCoverageListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -173,6 +172,7 @@ internal class AgenciesWithCoverageListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -184,7 +184,6 @@ internal class AgenciesWithCoverageListResponseTest { assertThat(agenciesWithCoverageListResponse.data()) .isEqualTo( AgenciesWithCoverageListResponse.Data.builder() - .limitExceeded(true) .addList( AgenciesWithCoverageListResponse.Data.List.builder() .agencyId("agencyId") @@ -278,7 +277,7 @@ internal class AgenciesWithCoverageListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -336,6 +335,7 @@ internal class AgenciesWithCoverageListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -351,7 +351,6 @@ internal class AgenciesWithCoverageListResponseTest { .version(0L) .data( AgenciesWithCoverageListResponse.Data.builder() - .limitExceeded(true) .addList( AgenciesWithCoverageListResponse.Data.List.builder() .agencyId("agencyId") @@ -446,7 +445,7 @@ internal class AgenciesWithCoverageListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -504,6 +503,7 @@ internal class AgenciesWithCoverageListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt index 16fb9ac..71919b5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt @@ -34,7 +34,6 @@ internal class AgencyRetrieveResponseTest { .privateService(true) .build() ) - .limitExceeded(true) .references( References.builder() .addAgency( @@ -120,7 +119,7 @@ internal class AgencyRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -203,7 +202,6 @@ internal class AgencyRetrieveResponseTest { .privateService(true) .build() ) - .limitExceeded(true) .references( References.builder() .addAgency( @@ -288,7 +286,7 @@ internal class AgencyRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -375,7 +373,6 @@ internal class AgencyRetrieveResponseTest { .privateService(true) .build() ) - .limitExceeded(true) .references( References.builder() .addAgency( @@ -461,7 +458,7 @@ internal class AgencyRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponseTest.kt index eaf1315..f466bc7 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponseTest.kt @@ -199,7 +199,7 @@ internal class ArrivalAndDepartureListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -446,7 +446,7 @@ internal class ArrivalAndDepartureListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -698,7 +698,7 @@ internal class ArrivalAndDepartureListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponseTest.kt index 381b6e4..b6d8959 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponseTest.kt @@ -190,7 +190,7 @@ internal class ArrivalAndDepartureRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -425,7 +425,7 @@ internal class ArrivalAndDepartureRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -668,7 +668,7 @@ internal class ArrivalAndDepartureRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt index c905c86..cc066ad 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt @@ -148,7 +148,7 @@ internal class BlockRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -343,7 +343,7 @@ internal class BlockRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -544,7 +544,7 @@ internal class BlockRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveResponseTest.kt index db41d44..68293e5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveResponseTest.kt @@ -137,7 +137,7 @@ internal class ConfigRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -322,7 +322,7 @@ internal class ConfigRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -512,7 +512,7 @@ internal class ConfigRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponseTest.kt index f3aaf22..e6c7945 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponseTest.kt @@ -111,7 +111,7 @@ internal class CurrentTimeRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -270,7 +270,7 @@ internal class CurrentTimeRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -434,7 +434,7 @@ internal class CurrentTimeRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt index 46f764f..54992b2 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt @@ -119,7 +119,7 @@ internal class RouteRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -286,7 +286,7 @@ internal class RouteRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -458,7 +458,7 @@ internal class RouteRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt index 09d6987..c6fc0af 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt @@ -20,7 +20,6 @@ internal class RouteIdsForAgencyListResponseTest { .version(0L) .data( RouteIdsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList("string") .references( References.builder() @@ -107,7 +106,7 @@ internal class RouteIdsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -165,6 +164,7 @@ internal class RouteIdsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -176,7 +176,6 @@ internal class RouteIdsForAgencyListResponseTest { assertThat(routeIdsForAgencyListResponse.data()) .isEqualTo( RouteIdsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList("string") .references( References.builder() @@ -262,7 +261,7 @@ internal class RouteIdsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -320,6 +319,7 @@ internal class RouteIdsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -335,7 +335,6 @@ internal class RouteIdsForAgencyListResponseTest { .version(0L) .data( RouteIdsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList("string") .references( References.builder() @@ -422,7 +421,7 @@ internal class RouteIdsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -480,6 +479,7 @@ internal class RouteIdsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponseTest.kt index 0792a24..accbe46 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponseTest.kt @@ -20,7 +20,6 @@ internal class RoutesForAgencyListResponseTest { .version(0L) .data( RoutesForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( RoutesForAgencyListResponse.Data.List.builder() .id("id") @@ -120,7 +119,7 @@ internal class RoutesForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -178,6 +177,7 @@ internal class RoutesForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -189,7 +189,6 @@ internal class RoutesForAgencyListResponseTest { assertThat(routesForAgencyListResponse.data()) .isEqualTo( RoutesForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( RoutesForAgencyListResponse.Data.List.builder() .id("id") @@ -288,7 +287,7 @@ internal class RoutesForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -346,6 +345,7 @@ internal class RoutesForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -361,7 +361,6 @@ internal class RoutesForAgencyListResponseTest { .version(0L) .data( RoutesForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( RoutesForAgencyListResponse.Data.List.builder() .id("id") @@ -461,7 +460,7 @@ internal class RoutesForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -519,6 +518,7 @@ internal class RoutesForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponseTest.kt index bcb6de2..c54d9ee 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponseTest.kt @@ -20,7 +20,6 @@ internal class RoutesForLocationListResponseTest { .version(0L) .data( RoutesForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( RoutesForLocationListResponse.Data.List.builder() .id("id") @@ -121,7 +120,7 @@ internal class RoutesForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -179,6 +178,7 @@ internal class RoutesForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -190,7 +190,6 @@ internal class RoutesForLocationListResponseTest { assertThat(routesForLocationListResponse.data()) .isEqualTo( RoutesForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( RoutesForLocationListResponse.Data.List.builder() .id("id") @@ -290,7 +289,7 @@ internal class RoutesForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -348,6 +347,7 @@ internal class RoutesForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -363,7 +363,6 @@ internal class RoutesForLocationListResponseTest { .version(0L) .data( RoutesForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( RoutesForLocationListResponse.Data.List.builder() .id("id") @@ -464,7 +463,7 @@ internal class RoutesForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -522,6 +521,7 @@ internal class RoutesForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt index 6a1cef0..7f6f3e2 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt @@ -154,7 +154,7 @@ internal class ScheduleForStopRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -355,7 +355,7 @@ internal class ScheduleForStopRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -562,7 +562,7 @@ internal class ScheduleForStopRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponseTest.kt index 81b4649..05026cf 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponseTest.kt @@ -20,7 +20,6 @@ internal class SearchForRouteListResponseTest { .version(0L) .data( SearchForRouteListResponse.Data.builder() - .limitExceeded(true) .addList( SearchForRouteListResponse.Data.List.builder() .id("id") @@ -121,7 +120,7 @@ internal class SearchForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -179,6 +178,7 @@ internal class SearchForRouteListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -190,7 +190,6 @@ internal class SearchForRouteListResponseTest { assertThat(searchForRouteListResponse.data()) .contains( SearchForRouteListResponse.Data.builder() - .limitExceeded(true) .addList( SearchForRouteListResponse.Data.List.builder() .id("id") @@ -290,7 +289,7 @@ internal class SearchForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -348,6 +347,7 @@ internal class SearchForRouteListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -363,7 +363,6 @@ internal class SearchForRouteListResponseTest { .version(0L) .data( SearchForRouteListResponse.Data.builder() - .limitExceeded(true) .addList( SearchForRouteListResponse.Data.List.builder() .id("id") @@ -464,7 +463,7 @@ internal class SearchForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -522,6 +521,7 @@ internal class SearchForRouteListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponseTest.kt index 0efc4a6..aa242f2 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponseTest.kt @@ -20,7 +20,6 @@ internal class SearchForStopListResponseTest { .version(0L) .data( SearchForStopListResponse.Data.builder() - .limitExceeded(true) .addList( SearchForStopListResponse.Data.List.builder() .id("id") @@ -122,7 +121,7 @@ internal class SearchForStopListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -180,6 +179,7 @@ internal class SearchForStopListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -191,7 +191,6 @@ internal class SearchForStopListResponseTest { assertThat(searchForStopListResponse.data()) .contains( SearchForStopListResponse.Data.builder() - .limitExceeded(true) .addList( SearchForStopListResponse.Data.List.builder() .id("id") @@ -292,7 +291,7 @@ internal class SearchForStopListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -350,6 +349,7 @@ internal class SearchForStopListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -365,7 +365,6 @@ internal class SearchForStopListResponseTest { .version(0L) .data( SearchForStopListResponse.Data.builder() - .limitExceeded(true) .addList( SearchForStopListResponse.Data.List.builder() .id("id") @@ -467,7 +466,7 @@ internal class SearchForStopListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -525,6 +524,7 @@ internal class SearchForStopListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt index cbd2651..e86774e 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt @@ -112,7 +112,7 @@ internal class ShapeRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -272,7 +272,7 @@ internal class ShapeRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -437,7 +437,7 @@ internal class ShapeRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt index 9120c5f..e29a484 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt @@ -120,7 +120,7 @@ internal class StopRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -288,7 +288,7 @@ internal class StopRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -461,7 +461,7 @@ internal class StopRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt index f11d550..bd52323 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt @@ -20,7 +20,6 @@ internal class StopIdsForAgencyListResponseTest { .version(0L) .data( StopIdsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList("string") .references( References.builder() @@ -107,7 +106,7 @@ internal class StopIdsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -165,6 +164,7 @@ internal class StopIdsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -176,7 +176,6 @@ internal class StopIdsForAgencyListResponseTest { assertThat(stopIdsForAgencyListResponse.data()) .isEqualTo( StopIdsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList("string") .references( References.builder() @@ -262,7 +261,7 @@ internal class StopIdsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -320,6 +319,7 @@ internal class StopIdsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -335,7 +335,6 @@ internal class StopIdsForAgencyListResponseTest { .version(0L) .data( StopIdsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList("string") .references( References.builder() @@ -422,7 +421,7 @@ internal class StopIdsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -480,6 +479,7 @@ internal class StopIdsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt index 6530d77..afda4db 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt @@ -20,7 +20,6 @@ internal class StopsForAgencyListResponseTest { .version(0L) .data( StopsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( StopsForAgencyListResponse.Data.List.builder() .id("id") @@ -121,7 +120,7 @@ internal class StopsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -179,6 +178,7 @@ internal class StopsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) @@ -191,7 +191,6 @@ internal class StopsForAgencyListResponseTest { assertThat(stopsForAgencyListResponse.data()) .isEqualTo( StopsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( StopsForAgencyListResponse.Data.List.builder() .id("id") @@ -291,7 +290,7 @@ internal class StopsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -349,6 +348,7 @@ internal class StopsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) @@ -365,7 +365,6 @@ internal class StopsForAgencyListResponseTest { .version(0L) .data( StopsForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( StopsForAgencyListResponse.Data.List.builder() .id("id") @@ -466,7 +465,7 @@ internal class StopsForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -524,6 +523,7 @@ internal class StopsForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponseTest.kt index f0d41a0..77eb789 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponseTest.kt @@ -20,7 +20,6 @@ internal class StopsForLocationListResponseTest { .version(0L) .data( StopsForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( StopsForLocationListResponse.Data.List.builder() .id("id") @@ -121,7 +120,7 @@ internal class StopsForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -179,6 +178,7 @@ internal class StopsForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) @@ -191,7 +191,6 @@ internal class StopsForLocationListResponseTest { assertThat(stopsForLocationListResponse.data()) .isEqualTo( StopsForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( StopsForLocationListResponse.Data.List.builder() .id("id") @@ -291,7 +290,7 @@ internal class StopsForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -349,6 +348,7 @@ internal class StopsForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) @@ -365,7 +365,6 @@ internal class StopsForLocationListResponseTest { .version(0L) .data( StopsForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( StopsForLocationListResponse.Data.List.builder() .id("id") @@ -466,7 +465,7 @@ internal class StopsForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -524,6 +523,7 @@ internal class StopsForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt index 7e35cf7..e222299 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt @@ -141,7 +141,7 @@ internal class StopsForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -329,7 +329,7 @@ internal class StopsForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -523,7 +523,7 @@ internal class StopsForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt index 0886e40..43e2e8e 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt @@ -120,7 +120,7 @@ internal class TripRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -288,7 +288,7 @@ internal class TripRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -461,7 +461,7 @@ internal class TripRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponseTest.kt index 494b05a..3ab29bf 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponseTest.kt @@ -176,7 +176,7 @@ internal class TripDetailRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -400,7 +400,7 @@ internal class TripDetailRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -629,7 +629,7 @@ internal class TripDetailRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponseTest.kt index a6b673c..14f9add 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponseTest.kt @@ -178,7 +178,7 @@ internal class TripForVehicleRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -402,7 +402,7 @@ internal class TripForVehicleRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -633,7 +633,7 @@ internal class TripForVehicleRetrieveResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponseTest.kt index 06f3ecd..351afc9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponseTest.kt @@ -20,7 +20,6 @@ internal class TripsForLocationListResponseTest { .version(0L) .data( TripsForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( TripsForLocationListResponse.Data.List.builder() .schedule( @@ -177,7 +176,7 @@ internal class TripsForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -235,6 +234,7 @@ internal class TripsForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) @@ -247,7 +247,6 @@ internal class TripsForLocationListResponseTest { assertThat(tripsForLocationListResponse.data()) .isEqualTo( TripsForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( TripsForLocationListResponse.Data.List.builder() .schedule( @@ -403,7 +402,7 @@ internal class TripsForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -461,6 +460,7 @@ internal class TripsForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) @@ -477,7 +477,6 @@ internal class TripsForLocationListResponseTest { .version(0L) .data( TripsForLocationListResponse.Data.builder() - .limitExceeded(true) .addList( TripsForLocationListResponse.Data.List.builder() .schedule( @@ -634,7 +633,7 @@ internal class TripsForLocationListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -692,6 +691,7 @@ internal class TripsForLocationListResponseTest { ) .build() ) + .limitExceeded(true) .outOfRange(true) .build() ) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponseTest.kt index 28c9587..0e18ac4 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponseTest.kt @@ -20,7 +20,6 @@ internal class TripsForRouteListResponseTest { .version(0L) .data( TripsForRouteListResponse.Data.builder() - .limitExceeded(true) .addList( TripsForRouteListResponse.Data.List.builder() .schedule( @@ -177,7 +176,7 @@ internal class TripsForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -235,6 +234,7 @@ internal class TripsForRouteListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -246,7 +246,6 @@ internal class TripsForRouteListResponseTest { assertThat(tripsForRouteListResponse.data()) .isEqualTo( TripsForRouteListResponse.Data.builder() - .limitExceeded(true) .addList( TripsForRouteListResponse.Data.List.builder() .schedule( @@ -401,7 +400,7 @@ internal class TripsForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -459,6 +458,7 @@ internal class TripsForRouteListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -474,7 +474,6 @@ internal class TripsForRouteListResponseTest { .version(0L) .data( TripsForRouteListResponse.Data.builder() - .limitExceeded(true) .addList( TripsForRouteListResponse.Data.List.builder() .schedule( @@ -631,7 +630,7 @@ internal class TripsForRouteListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -689,6 +688,7 @@ internal class TripsForRouteListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt index 48feaa0..e033d75 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt @@ -20,7 +20,6 @@ internal class VehiclesForAgencyListResponseTest { .version(0L) .data( VehiclesForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( VehiclesForAgencyListResponse.Data.List.builder() .lastLocationUpdateTime(0L) @@ -170,7 +169,7 @@ internal class VehiclesForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -228,6 +227,7 @@ internal class VehiclesForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() @@ -239,7 +239,6 @@ internal class VehiclesForAgencyListResponseTest { assertThat(vehiclesForAgencyListResponse.data()) .isEqualTo( VehiclesForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( VehiclesForAgencyListResponse.Data.List.builder() .lastLocationUpdateTime(0L) @@ -387,7 +386,7 @@ internal class VehiclesForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -445,6 +444,7 @@ internal class VehiclesForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) } @@ -460,7 +460,6 @@ internal class VehiclesForAgencyListResponseTest { .version(0L) .data( VehiclesForAgencyListResponse.Data.builder() - .limitExceeded(true) .addList( VehiclesForAgencyListResponse.Data.List.builder() .lastLocationUpdateTime(0L) @@ -610,7 +609,7 @@ internal class VehiclesForAgencyListResponseTest { .to(0L) .build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() @@ -668,6 +667,7 @@ internal class VehiclesForAgencyListResponseTest { ) .build() ) + .limitExceeded(true) .build() ) .build() diff --git a/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt b/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt index 385085c..9380915 100644 --- a/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt +++ b/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt @@ -158,7 +158,7 @@ internal class ProGuardCompatibilityTest { .addPublicationWindow( References.Situation.PublicationWindow.builder().from(0L).to(0L).build() ) - .reason(References.Situation.Reason.EQUIPMENT_REASON) + .reason("reason") .severity("severity") .summary( References.Situation.Summary.builder() From ee33acffec6143677ceae8a1e155c31736c0e4e0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2026 05:55:51 +0000 Subject: [PATCH 04/38] fix(client): incorrect `Retry-After` parsing --- .../core/http/RetryingHttpClient.kt | 2 +- .../core/http/RetryingHttpClientTest.kt | 224 +++++++++++++++--- 2 files changed, 192 insertions(+), 34 deletions(-) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt index 1be8cfe..6023d2e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt @@ -201,7 +201,7 @@ private constructor( ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { - ChronoUnit.MILLIS.between( + ChronoUnit.NANOS.between( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt index ee02de6..e6b88fb 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt @@ -16,7 +16,11 @@ import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario import java.io.InputStream +import java.time.Clock import java.time.Duration +import java.time.OffsetDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -36,6 +40,21 @@ internal class RetryingHttpClientTest { private lateinit var baseUrl: String private lateinit var httpClient: HttpClient + private class RecordingSleeper : Sleeper { + val durations = mutableListOf() + + override fun sleep(duration: Duration) { + durations.add(duration) + } + + override fun sleepAsync(duration: Duration): CompletableFuture { + durations.add(duration) + return CompletableFuture.completedFuture(null) + } + + override fun close() {} + } + @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { baseUrl = wmRuntimeInfo.httpBaseUrl @@ -86,7 +105,8 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = retryingHttpClientBuilder().build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).build() val response = retryingClient.execute( @@ -100,6 +120,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @@ -111,8 +132,12 @@ internal class RetryingHttpClientTest { .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) .willReturn(ok()) ) + val sleeper = RecordingSleeper() val retryingClient = - retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + retryingHttpClientBuilder(sleeper) + .maxRetries(2) + .idempotencyHeader("X-Some-Header") + .build() val response = retryingClient.execute( @@ -126,20 +151,20 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withRetryAfterHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) // First we fail with a retry after header given as a date .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -158,7 +183,13 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + // Fix the clock to 5 seconds before the Retry-After date so the date-based backoff is + // deterministic. + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -186,19 +217,20 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")), ) + assertThat(sleeper.durations) + .containsExactly(Duration.ofSeconds(5), Duration.ofMillis(1234)) assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -208,7 +240,11 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -227,6 +263,7 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")), ) + assertThat(sleeper.durations).containsExactly(Duration.ofSeconds(5)) assertNoResponseLeaks() } @@ -247,7 +284,8 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() val response = retryingClient.execute( @@ -261,6 +299,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(10)) assertNoResponseLeaks() } @@ -301,21 +340,12 @@ internal class RetryingHttpClientTest { override fun close() = httpClient.close() } + val sleeper = RecordingSleeper() val retryingClient = RetryingHttpClient.builder() .httpClient(failingHttpClient) .maxRetries(2) - .sleeper( - object : Sleeper { - - override fun sleep(duration: Duration) {} - - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) - - override fun close() {} - } - ) + .sleeper(sleeper) .build() val response = @@ -339,25 +369,153 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("0")), ) + // Exponential backoff with jitter: 0.5s * jitter where jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) assertNoResponseLeaks() } - private fun retryingHttpClientBuilder() = - RetryingHttpClient.builder() - .httpClient(httpClient) - // Use a no-op `Sleeper` to make the test fast. - .sleeper( - object : Sleeper { + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoff(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(3).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) - override fun sleep(duration: Duration) {} + // All retries exhausted; the last 503 response is returned. + assertThat(response.statusCode()).isEqualTo(503) + verify(4, postRequestedFor(urlPathEqualTo("/something"))) + // Exponential backoff with jitter: backoff = min(0.5 * 2^(retries-1), 8) * jitter where + // jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(3) + // retries=1: 0.5s * [0.75, 1.0] + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + // retries=2: 1.0s * [0.75, 1.0] + assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) + // retries=3: 2.0s * [0.75, 1.0] + assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) + assertNoResponseLeaks() + } - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoffCap(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(6).build() - override fun close() {} - } + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, ) + assertThat(response.statusCode()).isEqualTo(503) + verify(7, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).hasSize(6) + // retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0] + assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + // retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped) + assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsPriorityOverRetryAfter(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable() + .withHeader("Retry-After-Ms", "50") + .withHeader("Retry-After", "2") + ) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Retry-After-Ms (50ms) takes priority over Retry-After (2s). + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(50)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterUnparseable(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After", "not-a-date-or-number")) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Unparseable Retry-After falls through to exponential backoff. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder( + sleeper: RecordingSleeper, + clock: Clock = Clock.systemUTC(), + ) = RetryingHttpClient.builder().httpClient(httpClient).sleeper(sleeper).clock(clock) + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = if (async) executeAsync(request).get() else execute(request) From fbaadd8e2395cc74e3748f486fb17513a211bc1b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 14 Mar 2026 03:21:36 +0000 Subject: [PATCH 05/38] feat(api): api update --- .stats.yml | 4 ++-- .../ArrivalAndDepartureListResponse.kt | 17 ++++++++++++----- .../ArrivalAndDepartureRetrieveResponse.kt | 17 ++++++++++++----- .../tripdetails/TripDetailRetrieveResponse.kt | 17 ++++++++++++----- .../TripForVehicleRetrieveResponse.kt | 17 ++++++++++++----- .../TripsForLocationListResponse.kt | 17 ++++++++++++----- .../tripsforroute/TripsForRouteListResponse.kt | 17 ++++++++++++----- .../VehiclesForAgencyListResponse.kt | 17 ++++++++++++----- 8 files changed, 86 insertions(+), 37 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1594ba1..1266cd8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-0c305d11543f8fc11bd55586c4dc4a724b10de1898cab0fe11364b4db6455752.yml -openapi_spec_hash: 6d10c2ac411cd65f30d200f298577b32 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-30baad9d29b0909d180aae300750a0cd8425b52d7a60ba365b6aa4e5f8da6fab.yml +openapi_spec_hash: 218466af34966d9b08728f107cb3b3b0 config_hash: 3871f5d21bb38ddd334ec04721dea64d diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt index 0102ccf..2f4dc9c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt @@ -2636,7 +2636,7 @@ private constructor( fun frequency(): Optional = frequency.getOptional("frequency") /** - * Last known location of the transit vehicle. + * Last known location of the transit vehicle (optional). * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -3379,9 +3379,16 @@ private constructor( this.frequency = frequency } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) + /** Last known location of the transit vehicle (optional). */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation?) = + lastKnownLocation(JsonField.ofNullable(lastKnownLocation)) + + /** + * Alias for calling [Builder.lastKnownLocation] with + * `lastKnownLocation.orElse(null)`. + */ + fun lastKnownLocation(lastKnownLocation: Optional) = + lastKnownLocation(lastKnownLocation.getOrNull()) /** * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. @@ -3702,7 +3709,7 @@ private constructor( (situationIds.asKnown().getOrNull()?.size ?: 0) + (if (vehicleId.asKnown().isPresent) 1 else 0) - /** Last known location of the transit vehicle. */ + /** Last known location of the transit vehicle (optional). */ class LastKnownLocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt index d06b629..eea2098 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt @@ -2437,7 +2437,7 @@ private constructor( fun frequency(): Optional = frequency.getOptional("frequency") /** - * Last known location of the transit vehicle. + * Last known location of the transit vehicle (optional). * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -3164,9 +3164,16 @@ private constructor( this.frequency = frequency } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) + /** Last known location of the transit vehicle (optional). */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation?) = + lastKnownLocation(JsonField.ofNullable(lastKnownLocation)) + + /** + * Alias for calling [Builder.lastKnownLocation] with + * `lastKnownLocation.orElse(null)`. + */ + fun lastKnownLocation(lastKnownLocation: Optional) = + lastKnownLocation(lastKnownLocation.getOrNull()) /** * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. @@ -3475,7 +3482,7 @@ private constructor( (situationIds.asKnown().getOrNull()?.size ?: 0) + (if (vehicleId.asKnown().isPresent) 1 else 0) - /** Last known location of the transit vehicle. */ + /** Last known location of the transit vehicle (optional). */ class LastKnownLocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt index 383c4d6..526340c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt @@ -1862,7 +1862,7 @@ private constructor( fun frequency(): Optional = frequency.getOptional("frequency") /** - * Last known location of the transit vehicle. + * Last known location of the transit vehicle (optional). * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -2589,9 +2589,16 @@ private constructor( this.frequency = frequency } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) + /** Last known location of the transit vehicle (optional). */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation?) = + lastKnownLocation(JsonField.ofNullable(lastKnownLocation)) + + /** + * Alias for calling [Builder.lastKnownLocation] with + * `lastKnownLocation.orElse(null)`. + */ + fun lastKnownLocation(lastKnownLocation: Optional) = + lastKnownLocation(lastKnownLocation.getOrNull()) /** * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. @@ -2900,7 +2907,7 @@ private constructor( (situationIds.asKnown().getOrNull()?.size ?: 0) + (if (vehicleId.asKnown().isPresent) 1 else 0) - /** Last known location of the transit vehicle. */ + /** Last known location of the transit vehicle (optional). */ class LastKnownLocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt index 7264e50..cee36d5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt @@ -1864,7 +1864,7 @@ private constructor( fun frequency(): Optional = frequency.getOptional("frequency") /** - * Last known location of the transit vehicle. + * Last known location of the transit vehicle (optional). * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -2591,9 +2591,16 @@ private constructor( this.frequency = frequency } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) + /** Last known location of the transit vehicle (optional). */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation?) = + lastKnownLocation(JsonField.ofNullable(lastKnownLocation)) + + /** + * Alias for calling [Builder.lastKnownLocation] with + * `lastKnownLocation.orElse(null)`. + */ + fun lastKnownLocation(lastKnownLocation: Optional) = + lastKnownLocation(lastKnownLocation.getOrNull()) /** * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. @@ -2902,7 +2909,7 @@ private constructor( (situationIds.asKnown().getOrNull()?.size ?: 0) + (if (vehicleId.asKnown().isPresent) 1 else 0) - /** Last known location of the transit vehicle. */ + /** Last known location of the transit vehicle (optional). */ class LastKnownLocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt index 252afb4..679536d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt @@ -1970,7 +1970,7 @@ private constructor( fun frequency(): Optional = frequency.getOptional("frequency") /** - * Last known location of the transit vehicle. + * Last known location of the transit vehicle (optional). * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -2697,9 +2697,16 @@ private constructor( this.frequency = frequency } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) + /** Last known location of the transit vehicle (optional). */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation?) = + lastKnownLocation(JsonField.ofNullable(lastKnownLocation)) + + /** + * Alias for calling [Builder.lastKnownLocation] with + * `lastKnownLocation.orElse(null)`. + */ + fun lastKnownLocation(lastKnownLocation: Optional) = + lastKnownLocation(lastKnownLocation.getOrNull()) /** * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. @@ -3009,7 +3016,7 @@ private constructor( (situationIds.asKnown().getOrNull()?.size ?: 0) + (if (vehicleId.asKnown().isPresent) 1 else 0) - /** Last known location of the transit vehicle. */ + /** Last known location of the transit vehicle (optional). */ class LastKnownLocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt index d3c3929..29a210c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt @@ -1929,7 +1929,7 @@ private constructor( fun frequency(): Optional = frequency.getOptional("frequency") /** - * Last known location of the transit vehicle. + * Last known location of the transit vehicle (optional). * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -2656,9 +2656,16 @@ private constructor( this.frequency = frequency } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) + /** Last known location of the transit vehicle (optional). */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation?) = + lastKnownLocation(JsonField.ofNullable(lastKnownLocation)) + + /** + * Alias for calling [Builder.lastKnownLocation] with + * `lastKnownLocation.orElse(null)`. + */ + fun lastKnownLocation(lastKnownLocation: Optional) = + lastKnownLocation(lastKnownLocation.getOrNull()) /** * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. @@ -2968,7 +2975,7 @@ private constructor( (situationIds.asKnown().getOrNull()?.size ?: 0) + (if (vehicleId.asKnown().isPresent) 1 else 0) - /** Last known location of the transit vehicle. */ + /** Last known location of the transit vehicle (optional). */ class LastKnownLocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt index c49e829..078a607 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -1559,7 +1559,7 @@ private constructor( fun frequency(): Optional = frequency.getOptional("frequency") /** - * Last known location of the transit vehicle. + * Last known location of the transit vehicle (optional). * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -2286,9 +2286,16 @@ private constructor( this.frequency = frequency } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) + /** Last known location of the transit vehicle (optional). */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation?) = + lastKnownLocation(JsonField.ofNullable(lastKnownLocation)) + + /** + * Alias for calling [Builder.lastKnownLocation] with + * `lastKnownLocation.orElse(null)`. + */ + fun lastKnownLocation(lastKnownLocation: Optional) = + lastKnownLocation(lastKnownLocation.getOrNull()) /** * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. @@ -2598,7 +2605,7 @@ private constructor( (situationIds.asKnown().getOrNull()?.size ?: 0) + (if (vehicleId.asKnown().isPresent) 1 else 0) - /** Last known location of the transit vehicle. */ + /** Last known location of the transit vehicle (optional). */ class LastKnownLocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( From 165398b0c6f820ec29093b1122837a990b2ae587 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 08:58:02 +0000 Subject: [PATCH 06/38] chore(internal): tweak CI branches --- .github/workflows/ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f93c384..03dba3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' From 56092cf073f68b0631750dda62089acb0496affc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Mar 2026 07:54:33 +0000 Subject: [PATCH 07/38] chore(internal): update retry delay tests --- .../org/onebusaway/core/http/RetryingHttpClientTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt index e6b88fb..0647e63 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt @@ -400,9 +400,9 @@ internal class RetryingHttpClientTest { assertThat(sleeper.durations).hasSize(3) // retries=1: 0.5s * [0.75, 1.0] assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) - // retries=2: 1.0s * [0.75, 1.0] + // retries=2: 1s * [0.75, 1.0] assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) - // retries=3: 2.0s * [0.75, 1.0] + // retries=3: 2s * [0.75, 1.0] assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) assertNoResponseLeaks() } @@ -427,9 +427,9 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(503) verify(7, postRequestedFor(urlPathEqualTo("/something"))) assertThat(sleeper.durations).hasSize(6) - // retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0] + // retries=5: backoff hits the 8s cap * [0.75, 1.0] assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) - // retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped) + // retries=6: still capped at 8s * [0.75, 1.0] assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) assertNoResponseLeaks() } From 3964864f1cb0ebea7318a6e0fd68ea12e6705b24 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Mar 2026 08:04:13 +0000 Subject: [PATCH 08/38] fix(client): allow updating header/query affecting fields in `toBuilder()` --- .../main/kotlin/org/onebusaway/core/ClientOptions.kt | 7 ++++--- .../kotlin/org/onebusaway/core/ClientOptionsTest.kt | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt index d5383fc..ece86b0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt @@ -403,13 +403,14 @@ private constructor( headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) + // We replace after all the default headers to allow end-users to overwrite them. + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) apiKey.let { if (!it.isEmpty()) { - queryParams.put("key", it) + queryParams.replace("key", it) } } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) return ClientOptions( httpClient, diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt index 356afe7..303c0cd 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt @@ -16,6 +16,18 @@ internal class ClientOptionsTest { private val httpClient = mock() + @Test + fun putHeader_canOverwriteDefaultHeader() { + val clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .putHeader("User-Agent", "My User Agent") + .apiKey("My API Key") + .build() + + assertThat(clientOptions.headers.values("User-Agent")).containsExactly("My User Agent") + } + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { var clientOptions = From 77efbfa7675a8d7d8335e445ea0caac680017e57 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Mar 2026 03:11:41 +0000 Subject: [PATCH 09/38] refactor(tests): switch from prism to steady --- scripts/mock | 26 +++++++++++++------------- scripts/test | 16 ++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/scripts/mock b/scripts/mock index bcf3b39..00b490b 100755 --- a/scripts/mock +++ b/scripts/mock @@ -19,34 +19,34 @@ fi echo "==> Starting mock server with URL ${URL}" -# Run prism mock on the given spec +# Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stdy/cli@0.19.3 -- steady --version - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-query-object-format=brackets "$URL" &> .stdy.log & - # Wait for server to come online (max 30s) + # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" attempts=0 - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do + if ! kill -0 $! 2>/dev/null; then + echo + cat .stdy.log + exit 1 + fi attempts=$((attempts + 1)) if [ "$attempts" -ge 300 ]; then echo - echo "Timed out waiting for Prism server to start" - cat .prism.log + echo "Timed out waiting for Steady server to start" + cat .stdy.log exit 1 fi echo -n "." sleep 0.1 done - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - echo else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" + npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 047bc1d..3576476 100755 --- a/scripts/test +++ b/scripts/test @@ -9,8 +9,8 @@ GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 +function steady_is_running() { + curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1 } kill_server_on_port() { @@ -25,7 +25,7 @@ function is_overriding_api_base_url() { [ -n "$TEST_API_BASE_URL" ] } -if ! is_overriding_api_base_url && ! prism_is_running ; then +if ! is_overriding_api_base_url && ! steady_is_running ; then # When we exit this script, make sure to kill the background mock server process trap 'kill_server_on_port 4010' EXIT @@ -36,19 +36,19 @@ fi if is_overriding_api_base_url ; then echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" +elif ! steady_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server" echo -e "running against your OpenAPI spec." echo echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" + echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.3 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-query-object-format=brackets${NC}" echo exit 1 else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}" echo fi From ffd9a1b7d321a1a0d89f5d00184ba94341db23aa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Mar 2026 03:12:32 +0000 Subject: [PATCH 10/38] chore(internal): bump ktfmt --- buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts | 2 +- scripts/fast-format | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts index fbd8fe3..f42bdbc 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts @@ -40,7 +40,7 @@ tasks.withType().configureEach { val ktfmt by configurations.creating dependencies { - ktfmt("com.facebook:ktfmt:0.56") + ktfmt("com.facebook:ktfmt:0.61") } fun registerKtfmt( diff --git a/scripts/fast-format b/scripts/fast-format index 1b3bc47..35a1dee 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -24,8 +24,8 @@ if [ ! -f "$FILE_LIST" ]; then exit 1 fi -if ! command -v ktfmt-fast-format &> /dev/null; then - echo "Error: ktfmt-fast-format not found" +if ! command -v ktfmt &> /dev/null; then + echo "Error: ktfmt not found" exit 1 fi @@ -36,7 +36,7 @@ echo "==> Done looking for Kotlin files" if [[ -n "$kt_files" ]]; then echo "==> will format Kotlin files" - echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt --kotlinlang-style "$@" else echo "No Kotlin files to format -- expected outcome during incremental formatting" fi From 633a61ab965ff86afd6466106c9c1325ace48187 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 21 Mar 2026 03:54:28 +0000 Subject: [PATCH 11/38] chore(tests): bump steady to v0.19.4 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 00b490b..f310477 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.3 -- steady --version + npm exec --package=@stdy/cli@0.19.4 -- steady --version - npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.4 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.4 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 3576476..5d5d9ea 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.3 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.4 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From 22f82dae778becca20f549b8410a7c1d2c954655 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 21 Mar 2026 03:58:10 +0000 Subject: [PATCH 12/38] chore(tests): bump steady to v0.19.5 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index f310477..54fc791 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.4 -- steady --version + npm exec --package=@stdy/cli@0.19.5 -- steady --version - npm exec --package=@stdy/cli@0.19.4 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.4 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 5d5d9ea..d3b9fba 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.4 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.5 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From 2976e04d3381ba91ed619eac4cdb9a001fbf46e8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 04:00:02 +0000 Subject: [PATCH 13/38] chore(internal): update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b1346e6..90b85e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log .gradle .idea .kotlin From e334755a99bdf8f096d8247ffd40e416471db36b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 04:04:26 +0000 Subject: [PATCH 14/38] chore(tests): bump steady to v0.19.6 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 54fc791..0f82c95 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.5 -- steady --version + npm exec --package=@stdy/cli@0.19.6 -- steady --version - npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index d3b9fba..fd558ea 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.5 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.6 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From e23b04511c261dd1b68e84e7302361cae57f8a0c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 02:56:22 +0000 Subject: [PATCH 15/38] chore(ci): skip lint on metadata-only changes Note that we still want to run tests, as these depend on the metadata. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03dba3f..9ea8820 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -46,7 +46,7 @@ jobs: contents: read id-token: write runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 From ef0587c47711d53a97a7982fbf352de7c3f17333 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 02:56:53 +0000 Subject: [PATCH 16/38] chore(tests): bump steady to v0.19.7 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 0f82c95..3732f8e 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.6 -- steady --version + npm exec --package=@stdy/cli@0.19.7 -- steady --version - npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index fd558ea..0722b44 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.6 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From 7208a3c4f47fc1070808d19e78f3d86c6daa9307 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Mar 2026 05:11:11 +0000 Subject: [PATCH 17/38] chore(internal): update multipart form array serialization --- scripts/mock | 4 ++-- scripts/test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mock b/scripts/mock index 3732f8e..58e4628 100755 --- a/scripts/mock +++ b/scripts/mock @@ -24,7 +24,7 @@ if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout npm exec --package=@stdy/cli@0.19.7 -- steady --version - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 0722b44..3e49f36 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From 6b55911920235024bc07b4bdfd44768a70df1d48 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 29 Mar 2026 18:19:37 +0000 Subject: [PATCH 18/38] feat(api): api update --- .stats.yml | 8 +- .../onebusaway/client/OnebusawaySdkClient.kt | 6 + .../client/OnebusawaySdkClientAsync.kt | 6 + .../client/OnebusawaySdkClientAsyncImpl.kt | 19 + .../client/OnebusawaySdkClientImpl.kt | 18 + ...ivalsAndDeparturesForLocationListParams.kt | 451 ++ ...alsAndDeparturesForLocationListResponse.kt | 4740 +++++++++++++++++ ...alsAndDeparturesForLocationServiceAsync.kt | 75 + ...ndDeparturesForLocationServiceAsyncImpl.kt | 91 + ...ArrivalsAndDeparturesForLocationService.kt | 76 + ...valsAndDeparturesForLocationServiceImpl.kt | 86 + ...sAndDeparturesForLocationListParamsTest.kt | 74 + ...ndDeparturesForLocationListResponseTest.kt | 817 +++ ...ndDeparturesForLocationServiceAsyncTest.kt | 43 + ...valsAndDeparturesForLocationServiceTest.kt | 42 + .../proguard/ProGuardCompatibilityTest.kt | 1 + 16 files changed, 6549 insertions(+), 4 deletions(-) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListParams.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsync.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsyncImpl.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationService.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationServiceImpl.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListParamsTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponseTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 1266cd8..fa222e3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-30baad9d29b0909d180aae300750a0cd8425b52d7a60ba365b6aa4e5f8da6fab.yml -openapi_spec_hash: 218466af34966d9b08728f107cb3b3b0 -config_hash: 3871f5d21bb38ddd334ec04721dea64d +configured_endpoints: 30 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-a30b0967ffed17b866dc65b5528148a06a42cce7c3c6d8f740ae2f6079963e7d.yml +openapi_spec_hash: 9bf1e5bf00ef9936a9181ebd0956d5b8 +config_hash: c28ddf5b7754155603d9fd1c5fcaeeff diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt index 5706000..76e894f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt @@ -7,6 +7,7 @@ import org.onebusaway.core.ClientOptions import org.onebusaway.services.blocking.AgenciesWithCoverageService import org.onebusaway.services.blocking.AgencyService import org.onebusaway.services.blocking.ArrivalAndDepartureService +import org.onebusaway.services.blocking.ArrivalsAndDeparturesForLocationService import org.onebusaway.services.blocking.BlockService import org.onebusaway.services.blocking.ConfigService import org.onebusaway.services.blocking.CurrentTimeService @@ -101,6 +102,8 @@ interface OnebusawaySdkClient { fun scheduleForRoute(): ScheduleForRouteService + fun arrivalsAndDeparturesForLocation(): ArrivalsAndDeparturesForLocationService + fun arrivalAndDeparture(): ArrivalAndDepartureService fun trip(): TripService @@ -184,6 +187,9 @@ interface OnebusawaySdkClient { fun scheduleForRoute(): ScheduleForRouteService.WithRawResponse + fun arrivalsAndDeparturesForLocation(): + ArrivalsAndDeparturesForLocationService.WithRawResponse + fun arrivalAndDeparture(): ArrivalAndDepartureService.WithRawResponse fun trip(): TripService.WithRawResponse diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt index ddd6cf9..4dbe860 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt @@ -7,6 +7,7 @@ import org.onebusaway.core.ClientOptions import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync import org.onebusaway.services.async.AgencyServiceAsync import org.onebusaway.services.async.ArrivalAndDepartureServiceAsync +import org.onebusaway.services.async.ArrivalsAndDeparturesForLocationServiceAsync import org.onebusaway.services.async.BlockServiceAsync import org.onebusaway.services.async.ConfigServiceAsync import org.onebusaway.services.async.CurrentTimeServiceAsync @@ -101,6 +102,8 @@ interface OnebusawaySdkClientAsync { fun scheduleForRoute(): ScheduleForRouteServiceAsync + fun arrivalsAndDeparturesForLocation(): ArrivalsAndDeparturesForLocationServiceAsync + fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync fun trip(): TripServiceAsync @@ -185,6 +188,9 @@ interface OnebusawaySdkClientAsync { fun scheduleForRoute(): ScheduleForRouteServiceAsync.WithRawResponse + fun arrivalsAndDeparturesForLocation(): + ArrivalsAndDeparturesForLocationServiceAsync.WithRawResponse + fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync.WithRawResponse fun trip(): TripServiceAsync.WithRawResponse diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt index 78327e2..b7916bb 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt @@ -11,6 +11,8 @@ import org.onebusaway.services.async.AgencyServiceAsync import org.onebusaway.services.async.AgencyServiceAsyncImpl import org.onebusaway.services.async.ArrivalAndDepartureServiceAsync import org.onebusaway.services.async.ArrivalAndDepartureServiceAsyncImpl +import org.onebusaway.services.async.ArrivalsAndDeparturesForLocationServiceAsync +import org.onebusaway.services.async.ArrivalsAndDeparturesForLocationServiceAsyncImpl import org.onebusaway.services.async.BlockServiceAsync import org.onebusaway.services.async.BlockServiceAsyncImpl import org.onebusaway.services.async.ConfigServiceAsync @@ -142,6 +144,11 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) : ScheduleForRouteServiceAsyncImpl(clientOptionsWithUserAgent) } + private val arrivalsAndDeparturesForLocation: + ArrivalsAndDeparturesForLocationServiceAsync by lazy { + ArrivalsAndDeparturesForLocationServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val arrivalAndDeparture: ArrivalAndDepartureServiceAsync by lazy { ArrivalAndDepartureServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -227,6 +234,9 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) : override fun scheduleForRoute(): ScheduleForRouteServiceAsync = scheduleForRoute + override fun arrivalsAndDeparturesForLocation(): ArrivalsAndDeparturesForLocationServiceAsync = + arrivalsAndDeparturesForLocation + override fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync = arrivalAndDeparture override fun trip(): TripServiceAsync = trip @@ -320,6 +330,11 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) : ScheduleForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val arrivalsAndDeparturesForLocation: + ArrivalsAndDeparturesForLocationServiceAsync.WithRawResponse by lazy { + ArrivalsAndDeparturesForLocationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val arrivalAndDeparture: ArrivalAndDepartureServiceAsync.WithRawResponse by lazy { ArrivalAndDepartureServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -418,6 +433,10 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) : override fun scheduleForRoute(): ScheduleForRouteServiceAsync.WithRawResponse = scheduleForRoute + override fun arrivalsAndDeparturesForLocation(): + ArrivalsAndDeparturesForLocationServiceAsync.WithRawResponse = + arrivalsAndDeparturesForLocation + override fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync.WithRawResponse = arrivalAndDeparture diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt index d4e4146..dca7735 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt @@ -11,6 +11,8 @@ import org.onebusaway.services.blocking.AgencyService import org.onebusaway.services.blocking.AgencyServiceImpl import org.onebusaway.services.blocking.ArrivalAndDepartureService import org.onebusaway.services.blocking.ArrivalAndDepartureServiceImpl +import org.onebusaway.services.blocking.ArrivalsAndDeparturesForLocationService +import org.onebusaway.services.blocking.ArrivalsAndDeparturesForLocationServiceImpl import org.onebusaway.services.blocking.BlockService import org.onebusaway.services.blocking.BlockServiceImpl import org.onebusaway.services.blocking.ConfigService @@ -137,6 +139,10 @@ class OnebusawaySdkClientImpl(private val clientOptions: ClientOptions) : Onebus ScheduleForRouteServiceImpl(clientOptionsWithUserAgent) } + private val arrivalsAndDeparturesForLocation: ArrivalsAndDeparturesForLocationService by lazy { + ArrivalsAndDeparturesForLocationServiceImpl(clientOptionsWithUserAgent) + } + private val arrivalAndDeparture: ArrivalAndDepartureService by lazy { ArrivalAndDepartureServiceImpl(clientOptionsWithUserAgent) } @@ -218,6 +224,9 @@ class OnebusawaySdkClientImpl(private val clientOptions: ClientOptions) : Onebus override fun scheduleForRoute(): ScheduleForRouteService = scheduleForRoute + override fun arrivalsAndDeparturesForLocation(): ArrivalsAndDeparturesForLocationService = + arrivalsAndDeparturesForLocation + override fun arrivalAndDeparture(): ArrivalAndDepartureService = arrivalAndDeparture override fun trip(): TripService = trip @@ -311,6 +320,11 @@ class OnebusawaySdkClientImpl(private val clientOptions: ClientOptions) : Onebus ScheduleForRouteServiceImpl.WithRawResponseImpl(clientOptions) } + private val arrivalsAndDeparturesForLocation: + ArrivalsAndDeparturesForLocationService.WithRawResponse by lazy { + ArrivalsAndDeparturesForLocationServiceImpl.WithRawResponseImpl(clientOptions) + } + private val arrivalAndDeparture: ArrivalAndDepartureService.WithRawResponse by lazy { ArrivalAndDepartureServiceImpl.WithRawResponseImpl(clientOptions) } @@ -402,6 +416,10 @@ class OnebusawaySdkClientImpl(private val clientOptions: ClientOptions) : Onebus override fun scheduleForRoute(): ScheduleForRouteService.WithRawResponse = scheduleForRoute + override fun arrivalsAndDeparturesForLocation(): + ArrivalsAndDeparturesForLocationService.WithRawResponse = + arrivalsAndDeparturesForLocation + override fun arrivalAndDeparture(): ArrivalAndDepartureService.WithRawResponse = arrivalAndDeparture diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListParams.kt new file mode 100644 index 0000000..1d76ebc --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListParams.kt @@ -0,0 +1,451 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalsanddeparturesforlocation + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** + * Returns real-time arrival and departure data for stops within a bounding box or radius centered + * on a specific location. + */ +class ArrivalsAndDeparturesForLocationListParams +private constructor( + private val lat: Double, + private val lon: Double, + private val emptyReturnsNotFound: Boolean?, + private val latSpan: Double?, + private val lonSpan: Double?, + private val maxCount: Long?, + private val minutesAfter: Long?, + private val minutesBefore: Long?, + private val radius: Double?, + private val routeType: String?, + private val time: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The latitude coordinate of the search center. */ + fun lat(): Double = lat + + /** The longitude coordinate of the search center. */ + fun lon(): Double = lon + + /** If true, returns a 404 Not Found error instead of an empty result. */ + fun emptyReturnsNotFound(): Optional = Optional.ofNullable(emptyReturnsNotFound) + + /** Sets the latitude limits of the search bounding box. */ + fun latSpan(): Optional = Optional.ofNullable(latSpan) + + /** Sets the longitude limits of the search bounding box. */ + fun lonSpan(): Optional = Optional.ofNullable(lonSpan) + + /** + * The max size of the list of nearby stops and arrivals to return. Defaults to 250, max 1000. + */ + fun maxCount(): Optional = Optional.ofNullable(maxCount) + + /** Include arrivals and departures this many minutes after the query time. */ + fun minutesAfter(): Optional = Optional.ofNullable(minutesAfter) + + /** Include arrivals and departures this many minutes before the query time. */ + fun minutesBefore(): Optional = Optional.ofNullable(minutesBefore) + + /** The search radius in meters. */ + fun radius(): Optional = Optional.ofNullable(radius) + + /** Optional list of GTFS routeTypes to filter by (comma delimited) e.g. "1,2,3". */ + fun routeType(): Optional = Optional.ofNullable(routeType) + + /** + * By default, returns the status right now. Can be queried at a specific time (milliseconds + * since epoch) for testing. + */ + fun time(): Optional = Optional.ofNullable(time) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalsAndDeparturesForLocationListParams]. + * + * The following fields are required: + * ```java + * .lat() + * .lon() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalsAndDeparturesForLocationListParams]. */ + class Builder internal constructor() { + + private var lat: Double? = null + private var lon: Double? = null + private var emptyReturnsNotFound: Boolean? = null + private var latSpan: Double? = null + private var lonSpan: Double? = null + private var maxCount: Long? = null + private var minutesAfter: Long? = null + private var minutesBefore: Long? = null + private var radius: Double? = null + private var routeType: String? = null + private var time: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + arrivalsAndDeparturesForLocationListParams: ArrivalsAndDeparturesForLocationListParams + ) = apply { + lat = arrivalsAndDeparturesForLocationListParams.lat + lon = arrivalsAndDeparturesForLocationListParams.lon + emptyReturnsNotFound = arrivalsAndDeparturesForLocationListParams.emptyReturnsNotFound + latSpan = arrivalsAndDeparturesForLocationListParams.latSpan + lonSpan = arrivalsAndDeparturesForLocationListParams.lonSpan + maxCount = arrivalsAndDeparturesForLocationListParams.maxCount + minutesAfter = arrivalsAndDeparturesForLocationListParams.minutesAfter + minutesBefore = arrivalsAndDeparturesForLocationListParams.minutesBefore + radius = arrivalsAndDeparturesForLocationListParams.radius + routeType = arrivalsAndDeparturesForLocationListParams.routeType + time = arrivalsAndDeparturesForLocationListParams.time + additionalHeaders = + arrivalsAndDeparturesForLocationListParams.additionalHeaders.toBuilder() + additionalQueryParams = + arrivalsAndDeparturesForLocationListParams.additionalQueryParams.toBuilder() + } + + /** The latitude coordinate of the search center. */ + fun lat(lat: Double) = apply { this.lat = lat } + + /** The longitude coordinate of the search center. */ + fun lon(lon: Double) = apply { this.lon = lon } + + /** If true, returns a 404 Not Found error instead of an empty result. */ + fun emptyReturnsNotFound(emptyReturnsNotFound: Boolean?) = apply { + this.emptyReturnsNotFound = emptyReturnsNotFound + } + + /** + * Alias for [Builder.emptyReturnsNotFound]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun emptyReturnsNotFound(emptyReturnsNotFound: Boolean) = + emptyReturnsNotFound(emptyReturnsNotFound as Boolean?) + + /** + * Alias for calling [Builder.emptyReturnsNotFound] with + * `emptyReturnsNotFound.orElse(null)`. + */ + fun emptyReturnsNotFound(emptyReturnsNotFound: Optional) = + emptyReturnsNotFound(emptyReturnsNotFound.getOrNull()) + + /** Sets the latitude limits of the search bounding box. */ + fun latSpan(latSpan: Double?) = apply { this.latSpan = latSpan } + + /** + * Alias for [Builder.latSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latSpan(latSpan: Double) = latSpan(latSpan as Double?) + + /** Alias for calling [Builder.latSpan] with `latSpan.orElse(null)`. */ + fun latSpan(latSpan: Optional) = latSpan(latSpan.getOrNull()) + + /** Sets the longitude limits of the search bounding box. */ + fun lonSpan(lonSpan: Double?) = apply { this.lonSpan = lonSpan } + + /** + * Alias for [Builder.lonSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun lonSpan(lonSpan: Double) = lonSpan(lonSpan as Double?) + + /** Alias for calling [Builder.lonSpan] with `lonSpan.orElse(null)`. */ + fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.getOrNull()) + + /** + * The max size of the list of nearby stops and arrivals to return. Defaults to 250, + * max 1000. + */ + fun maxCount(maxCount: Long?) = apply { this.maxCount = maxCount } + + /** + * Alias for [Builder.maxCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxCount(maxCount: Long) = maxCount(maxCount as Long?) + + /** Alias for calling [Builder.maxCount] with `maxCount.orElse(null)`. */ + fun maxCount(maxCount: Optional) = maxCount(maxCount.getOrNull()) + + /** Include arrivals and departures this many minutes after the query time. */ + fun minutesAfter(minutesAfter: Long?) = apply { this.minutesAfter = minutesAfter } + + /** + * Alias for [Builder.minutesAfter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun minutesAfter(minutesAfter: Long) = minutesAfter(minutesAfter as Long?) + + /** Alias for calling [Builder.minutesAfter] with `minutesAfter.orElse(null)`. */ + fun minutesAfter(minutesAfter: Optional) = minutesAfter(minutesAfter.getOrNull()) + + /** Include arrivals and departures this many minutes before the query time. */ + fun minutesBefore(minutesBefore: Long?) = apply { this.minutesBefore = minutesBefore } + + /** + * Alias for [Builder.minutesBefore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun minutesBefore(minutesBefore: Long) = minutesBefore(minutesBefore as Long?) + + /** Alias for calling [Builder.minutesBefore] with `minutesBefore.orElse(null)`. */ + fun minutesBefore(minutesBefore: Optional) = minutesBefore(minutesBefore.getOrNull()) + + /** The search radius in meters. */ + fun radius(radius: Double?) = apply { this.radius = radius } + + /** + * Alias for [Builder.radius]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun radius(radius: Double) = radius(radius as Double?) + + /** Alias for calling [Builder.radius] with `radius.orElse(null)`. */ + fun radius(radius: Optional) = radius(radius.getOrNull()) + + /** Optional list of GTFS routeTypes to filter by (comma delimited) e.g. "1,2,3". */ + fun routeType(routeType: String?) = apply { this.routeType = routeType } + + /** Alias for calling [Builder.routeType] with `routeType.orElse(null)`. */ + fun routeType(routeType: Optional) = routeType(routeType.getOrNull()) + + /** + * By default, returns the status right now. Can be queried at a specific time (milliseconds + * since epoch) for testing. + */ + fun time(time: Long?) = apply { this.time = time } + + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun time(time: Long) = time(time as Long?) + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ArrivalsAndDeparturesForLocationListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .lat() + * .lon() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArrivalsAndDeparturesForLocationListParams = + ArrivalsAndDeparturesForLocationListParams( + checkRequired("lat", lat), + checkRequired("lon", lon), + emptyReturnsNotFound, + latSpan, + lonSpan, + maxCount, + minutesAfter, + minutesBefore, + radius, + routeType, + time, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("lat", lat.toString()) + put("lon", lon.toString()) + emptyReturnsNotFound?.let { put("emptyReturnsNotFound", it.toString()) } + latSpan?.let { put("latSpan", it.toString()) } + lonSpan?.let { put("lonSpan", it.toString()) } + maxCount?.let { put("maxCount", it.toString()) } + minutesAfter?.let { put("minutesAfter", it.toString()) } + minutesBefore?.let { put("minutesBefore", it.toString()) } + radius?.let { put("radius", it.toString()) } + routeType?.let { put("routeType", it) } + time?.let { put("time", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ArrivalsAndDeparturesForLocationListParams && + lat == other.lat && + lon == other.lon && + emptyReturnsNotFound == other.emptyReturnsNotFound && + latSpan == other.latSpan && + lonSpan == other.lonSpan && + maxCount == other.maxCount && + minutesAfter == other.minutesAfter && + minutesBefore == other.minutesBefore && + radius == other.radius && + routeType == other.routeType && + time == other.time && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + lat, + lon, + emptyReturnsNotFound, + latSpan, + lonSpan, + maxCount, + minutesAfter, + minutesBefore, + radius, + routeType, + time, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ArrivalsAndDeparturesForLocationListParams{lat=$lat, lon=$lon, emptyReturnsNotFound=$emptyReturnsNotFound, latSpan=$latSpan, lonSpan=$lonSpan, maxCount=$maxCount, minutesAfter=$minutesAfter, minutesBefore=$minutesBefore, radius=$radius, routeType=$routeType, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt new file mode 100644 index 0000000..7da06b2 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt @@ -0,0 +1,4740 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalsanddeparturesforlocation + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ExcludeMissing +import org.onebusaway.core.JsonField +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class ArrivalsAndDeparturesForLocationListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalsAndDeparturesForLocationListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalsAndDeparturesForLocationListResponse]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + arrivalsAndDeparturesForLocationListResponse: + ArrivalsAndDeparturesForLocationListResponse + ) = apply { + code = arrivalsAndDeparturesForLocationListResponse.code + currentTime = arrivalsAndDeparturesForLocationListResponse.currentTime + text = arrivalsAndDeparturesForLocationListResponse.text + version = arrivalsAndDeparturesForLocationListResponse.version + data = arrivalsAndDeparturesForLocationListResponse.data + additionalProperties = + arrivalsAndDeparturesForLocationListResponse.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) + + /** + * Sets [Builder.currentTime] to an arbitrary JSON value. + * + * You should usually call [Builder.currentTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } + + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ArrivalsAndDeparturesForLocationListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArrivalsAndDeparturesForLocationListResponse = + ArrivalsAndDeparturesForLocationListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ArrivalsAndDeparturesForLocationListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (currentTime.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arrivalsAndDepartures: JsonField>, + private val limitExceeded: JsonField, + private val nearbyStopIds: JsonField>, + private val stopIds: JsonField>, + private val situationIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalsAndDepartures") + @ExcludeMissing + arrivalsAndDepartures: JsonField> = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("nearbyStopIds") + @ExcludeMissing + nearbyStopIds: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + stopIds: JsonField> = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + ) : this( + arrivalsAndDepartures, + limitExceeded, + nearbyStopIds, + stopIds, + situationIds, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun arrivalsAndDepartures(): List = + arrivalsAndDepartures.getRequired("arrivalsAndDepartures") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun nearbyStopIds(): List = nearbyStopIds.getRequired("nearbyStopIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun stopIds(): List = stopIds.getRequired("stopIds") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = situationIds.getOptional("situationIds") + + /** + * Returns the raw JSON value of [arrivalsAndDepartures]. + * + * Unlike [arrivalsAndDepartures], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalsAndDepartures") + @ExcludeMissing + fun _arrivalsAndDepartures(): JsonField> = + arrivalsAndDepartures + + /** + * Returns the raw JSON value of [limitExceeded]. + * + * Unlike [limitExceeded], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + /** + * Returns the raw JSON value of [nearbyStopIds]. + * + * Unlike [nearbyStopIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nearbyStopIds") + @ExcludeMissing + fun _nearbyStopIds(): JsonField> = nearbyStopIds + + /** + * Returns the raw JSON value of [stopIds]. + * + * Unlike [stopIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Entry]. + * + * The following fields are required: + * ```java + * .arrivalsAndDepartures() + * .limitExceeded() + * .nearbyStopIds() + * .stopIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var arrivalsAndDepartures: JsonField>? = + null + private var limitExceeded: JsonField? = null + private var nearbyStopIds: JsonField>? = null + private var stopIds: JsonField>? = null + private var situationIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + arrivalsAndDepartures = entry.arrivalsAndDepartures.map { it.toMutableList() } + limitExceeded = entry.limitExceeded + nearbyStopIds = entry.nearbyStopIds.map { it.toMutableList() } + stopIds = entry.stopIds.map { it.toMutableList() } + situationIds = entry.situationIds.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun arrivalsAndDepartures(arrivalsAndDepartures: List) = + arrivalsAndDepartures(JsonField.of(arrivalsAndDepartures)) + + /** + * Sets [Builder.arrivalsAndDepartures] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalsAndDepartures] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun arrivalsAndDepartures( + arrivalsAndDepartures: JsonField> + ) = apply { + this.arrivalsAndDepartures = arrivalsAndDepartures.map { it.toMutableList() } + } + + /** + * Adds a single [ArrivalsAndDeparture] to [arrivalsAndDepartures]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArrivalsAndDeparture(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { + arrivalsAndDepartures = + (arrivalsAndDepartures ?: JsonField.of(mutableListOf())).also { + checkKnown("arrivalsAndDepartures", it).add(arrivalsAndDeparture) + } + } + + fun limitExceeded(limitExceeded: Boolean) = + limitExceeded(JsonField.of(limitExceeded)) + + /** + * Sets [Builder.limitExceeded] to an arbitrary JSON value. + * + * You should usually call [Builder.limitExceeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun limitExceeded(limitExceeded: JsonField) = apply { + this.limitExceeded = limitExceeded + } + + fun nearbyStopIds(nearbyStopIds: List) = + nearbyStopIds(JsonField.of(nearbyStopIds)) + + /** + * Sets [Builder.nearbyStopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.nearbyStopIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun nearbyStopIds(nearbyStopIds: JsonField>) = apply { + this.nearbyStopIds = nearbyStopIds.map { it.toMutableList() } + } + + /** + * Adds a single [NearbyStopId] to [nearbyStopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNearbyStopId(nearbyStopId: NearbyStopId) = apply { + nearbyStopIds = + (nearbyStopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("nearbyStopIds", it).add(nearbyStopId) + } + } + + fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) + + /** + * Sets [Builder.stopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.stopIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [stopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("stopIds", it).add(stopId) + } + } + + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Entry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .arrivalsAndDepartures() + * .limitExceeded() + * .nearbyStopIds() + * .stopIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("arrivalsAndDepartures", arrivalsAndDepartures).map { + it.toImmutable() + }, + checkRequired("limitExceeded", limitExceeded), + checkRequired("nearbyStopIds", nearbyStopIds).map { it.toImmutable() }, + checkRequired("stopIds", stopIds).map { it.toImmutable() }, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + arrivalsAndDepartures().forEach { it.validate() } + limitExceeded() + nearbyStopIds().forEach { it.validate() } + stopIds() + situationIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (arrivalsAndDepartures.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (nearbyStopIds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stopIds.asKnown().getOrNull()?.size ?: 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + class ArrivalsAndDeparture + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arrivalEnabled: JsonField, + private val blockTripSequence: JsonField, + private val departureEnabled: JsonField, + private val numberOfStopsAway: JsonField, + private val predictedArrivalTime: JsonField, + private val predictedDepartureTime: JsonField, + private val routeId: JsonField, + private val scheduledArrivalTime: JsonField, + private val scheduledDepartureTime: JsonField, + private val serviceDate: JsonField, + private val stopId: JsonField, + private val stopSequence: JsonField, + private val totalStopsInTrip: JsonField, + private val tripHeadsign: JsonField, + private val tripId: JsonField, + private val vehicleId: JsonField, + private val actualTrack: JsonField, + private val distanceFromStop: JsonField, + private val frequency: JsonField, + private val historicalOccupancy: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyStatus: JsonField, + private val predicted: JsonField, + private val predictedArrivalInterval: JsonField, + private val predictedDepartureInterval: JsonField, + private val predictedOccupancy: JsonField, + private val routeLongName: JsonField, + private val routeShortName: JsonField, + private val scheduledArrivalInterval: JsonField, + private val scheduledDepartureInterval: JsonField, + private val scheduledTrack: JsonField, + private val situationIds: JsonField>, + private val status: JsonField, + private val tripStatus: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalEnabled") + @ExcludeMissing + arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + numberOfStopsAway: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + predictedArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + predictedDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + scheduledArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + scheduledDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopSequence") + @ExcludeMissing + stopSequence: JsonField = JsonMissing.of(), + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + totalStopsInTrip: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("actualTrack") + @ExcludeMissing + actualTrack: JsonField = JsonMissing.of(), + @JsonProperty("distanceFromStop") + @ExcludeMissing + distanceFromStop: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + predictedArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + predictedDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedOccupancy") + @ExcludeMissing + predictedOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("routeLongName") + @ExcludeMissing + routeLongName: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + scheduledArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + scheduledDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledTrack") + @ExcludeMissing + scheduledTrack: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + tripStatus: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + blockTripSequence, + departureEnabled, + numberOfStopsAway, + predictedArrivalTime, + predictedDepartureTime, + routeId, + scheduledArrivalTime, + scheduledDepartureTime, + serviceDate, + stopId, + stopSequence, + totalStopsInTrip, + tripHeadsign, + tripId, + vehicleId, + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + situationIds, + status, + tripStatus, + mutableMapOf(), + ) + + /** + * Indicates if riders can arrive on this transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") + + /** + * Index of this arrival’s trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * Indicates if riders can depart from this transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time + * available). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predictedArrivalTime(): Long = + predictedArrivalTime.getRequired("predictedArrivalTime") + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time + * available). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predictedDepartureTime(): Long = + predictedDepartureTime.getRequired("predictedDepartureTime") + + /** + * The ID of the route for the arriving vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * Scheduled arrival time, in milliseconds since Unix epoch. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduledArrivalTime(): Long = + scheduledArrivalTime.getRequired("scheduledArrivalTime") + + /** + * Scheduled departure time, in milliseconds since Unix epoch. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduledDepartureTime(): Long = + scheduledDepartureTime.getRequired("scheduledDepartureTime") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * The ID of the stop the vehicle is arriving at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopSequence(): Long = stopSequence.getRequired("stopSequence") + + /** + * Total number of stops visited on the trip for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") + + /** + * The ID of the trip for the arriving vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * ID of the transit vehicle serving this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun vehicleId(): String = vehicleId.getRequired("vehicleId") + + /** + * The actual track information of the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun actualTrack(): Optional = actualTrack.getOptional("actualTrack") + + /** + * Distance of the arriving transit vehicle from the stop, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceFromStop(): Optional = + distanceFromStop.getOptional("distanceFromStop") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Historical occupancy information of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun historicalOccupancy(): Optional = + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * Timestamp of the last update time for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastUpdateTime(): Optional = lastUpdateTime.getOptional("lastUpdateTime") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun occupancyStatus(): Optional = + occupancyStatus.getOptional("occupancyStatus") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predicted(): Optional = predicted.getOptional("predicted") + + /** + * Interval for predicted arrival time, if available. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedArrivalInterval(): Optional = + predictedArrivalInterval.getOptional("predictedArrivalInterval") + + /** + * Interval for predicted departure time, if available. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedDepartureInterval(): Optional = + predictedDepartureInterval.getOptional("predictedDepartureInterval") + + /** + * Predicted occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedOccupancy(): Optional = + predictedOccupancy.getOptional("predictedOccupancy") + + /** + * Optional route long name that potentially overrides the route long name in the + * referenced route element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun routeLongName(): Optional = routeLongName.getOptional("routeLongName") + + /** + * Optional route short name that potentially overrides the route short name in the + * referenced route element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun routeShortName(): Optional = + routeShortName.getOptional("routeShortName") + + /** + * Interval for scheduled arrival time. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledArrivalInterval(): Optional = + scheduledArrivalInterval.getOptional("scheduledArrivalInterval") + + /** + * Interval for scheduled departure time. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDepartureInterval(): Optional = + scheduledDepartureInterval.getOptional("scheduledDepartureInterval") + + /** + * Scheduled track information of the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledTrack(): Optional = + scheduledTrack.getOptional("scheduledTrack") + + /** + * References to situation elements (if any) applicable to this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * Current status of the arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Trip-specific status for the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tripStatus(): Optional = tripStatus.getOptional("tripStatus") + + /** + * Returns the raw JSON value of [arrivalEnabled]. + * + * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [departureEnabled]. + * + * Unlike [departureEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("departureEnabled") + @ExcludeMissing + fun _departureEnabled(): JsonField = departureEnabled + + /** + * Returns the raw JSON value of [numberOfStopsAway]. + * + * Unlike [numberOfStopsAway], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + fun _numberOfStopsAway(): JsonField = numberOfStopsAway + + /** + * Returns the raw JSON value of [predictedArrivalTime]. + * + * Unlike [predictedArrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + fun _predictedArrivalTime(): JsonField = predictedArrivalTime + + /** + * Returns the raw JSON value of [predictedDepartureTime]. + * + * Unlike [predictedDepartureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + fun _predictedDepartureTime(): JsonField = predictedDepartureTime + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [scheduledArrivalTime]. + * + * Unlike [scheduledArrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + fun _scheduledArrivalTime(): JsonField = scheduledArrivalTime + + /** + * Returns the raw JSON value of [scheduledDepartureTime]. + * + * Unlike [scheduledDepartureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + fun _scheduledDepartureTime(): JsonField = scheduledDepartureTime + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId + + /** + * Returns the raw JSON value of [stopSequence]. + * + * Unlike [stopSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopSequence") + @ExcludeMissing + fun _stopSequence(): JsonField = stopSequence + + /** + * Returns the raw JSON value of [totalStopsInTrip]. + * + * Unlike [totalStopsInTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + fun _totalStopsInTrip(): JsonField = totalStopsInTrip + + /** + * Returns the raw JSON value of [tripHeadsign]. + * + * Unlike [tripHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + /** + * Returns the raw JSON value of [actualTrack]. + * + * Unlike [actualTrack], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("actualTrack") + @ExcludeMissing + fun _actualTrack(): JsonField = actualTrack + + /** + * Returns the raw JSON value of [distanceFromStop]. + * + * Unlike [distanceFromStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceFromStop") + @ExcludeMissing + fun _distanceFromStop(): JsonField = distanceFromStop + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [historicalOccupancy]. + * + * Unlike [historicalOccupancy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [predictedArrivalInterval]. + * + * Unlike [predictedArrivalInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + fun _predictedArrivalInterval(): JsonField = predictedArrivalInterval + + /** + * Returns the raw JSON value of [predictedDepartureInterval]. + * + * Unlike [predictedDepartureInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + fun _predictedDepartureInterval(): JsonField = predictedDepartureInterval + + /** + * Returns the raw JSON value of [predictedOccupancy]. + * + * Unlike [predictedOccupancy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedOccupancy") + @ExcludeMissing + fun _predictedOccupancy(): JsonField = predictedOccupancy + + /** + * Returns the raw JSON value of [routeLongName]. + * + * Unlike [routeLongName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeLongName") + @ExcludeMissing + fun _routeLongName(): JsonField = routeLongName + + /** + * Returns the raw JSON value of [routeShortName]. + * + * Unlike [routeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName + + /** + * Returns the raw JSON value of [scheduledArrivalInterval]. + * + * Unlike [scheduledArrivalInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + fun _scheduledArrivalInterval(): JsonField = scheduledArrivalInterval + + /** + * Returns the raw JSON value of [scheduledDepartureInterval]. + * + * Unlike [scheduledDepartureInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + fun _scheduledDepartureInterval(): JsonField = scheduledDepartureInterval + + /** + * Returns the raw JSON value of [scheduledTrack]. + * + * Unlike [scheduledTrack], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledTrack") + @ExcludeMissing + fun _scheduledTrack(): JsonField = scheduledTrack + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [tripStatus]. + * + * Unlike [tripStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalsAndDeparture]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .blockTripSequence() + * .departureEnabled() + * .numberOfStopsAway() + * .predictedArrivalTime() + * .predictedDepartureTime() + * .routeId() + * .scheduledArrivalTime() + * .scheduledDepartureTime() + * .serviceDate() + * .stopId() + * .stopSequence() + * .totalStopsInTrip() + * .tripHeadsign() + * .tripId() + * .vehicleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalsAndDeparture]. */ + class Builder internal constructor() { + + private var arrivalEnabled: JsonField? = null + private var blockTripSequence: JsonField? = null + private var departureEnabled: JsonField? = null + private var numberOfStopsAway: JsonField? = null + private var predictedArrivalTime: JsonField? = null + private var predictedDepartureTime: JsonField? = null + private var routeId: JsonField? = null + private var scheduledArrivalTime: JsonField? = null + private var scheduledDepartureTime: JsonField? = null + private var serviceDate: JsonField? = null + private var stopId: JsonField? = null + private var stopSequence: JsonField? = null + private var totalStopsInTrip: JsonField? = null + private var tripHeadsign: JsonField? = null + private var tripId: JsonField? = null + private var vehicleId: JsonField? = null + private var actualTrack: JsonField = JsonMissing.of() + private var distanceFromStop: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var lastUpdateTime: JsonField = JsonMissing.of() + private var occupancyStatus: JsonField = JsonMissing.of() + private var predicted: JsonField = JsonMissing.of() + private var predictedArrivalInterval: JsonField = JsonMissing.of() + private var predictedDepartureInterval: JsonField = JsonMissing.of() + private var predictedOccupancy: JsonField = JsonMissing.of() + private var routeLongName: JsonField = JsonMissing.of() + private var routeShortName: JsonField = JsonMissing.of() + private var scheduledArrivalInterval: JsonField = JsonMissing.of() + private var scheduledDepartureInterval: JsonField = JsonMissing.of() + private var scheduledTrack: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var tripStatus: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { + arrivalEnabled = arrivalsAndDeparture.arrivalEnabled + blockTripSequence = arrivalsAndDeparture.blockTripSequence + departureEnabled = arrivalsAndDeparture.departureEnabled + numberOfStopsAway = arrivalsAndDeparture.numberOfStopsAway + predictedArrivalTime = arrivalsAndDeparture.predictedArrivalTime + predictedDepartureTime = arrivalsAndDeparture.predictedDepartureTime + routeId = arrivalsAndDeparture.routeId + scheduledArrivalTime = arrivalsAndDeparture.scheduledArrivalTime + scheduledDepartureTime = arrivalsAndDeparture.scheduledDepartureTime + serviceDate = arrivalsAndDeparture.serviceDate + stopId = arrivalsAndDeparture.stopId + stopSequence = arrivalsAndDeparture.stopSequence + totalStopsInTrip = arrivalsAndDeparture.totalStopsInTrip + tripHeadsign = arrivalsAndDeparture.tripHeadsign + tripId = arrivalsAndDeparture.tripId + vehicleId = arrivalsAndDeparture.vehicleId + actualTrack = arrivalsAndDeparture.actualTrack + distanceFromStop = arrivalsAndDeparture.distanceFromStop + frequency = arrivalsAndDeparture.frequency + historicalOccupancy = arrivalsAndDeparture.historicalOccupancy + lastUpdateTime = arrivalsAndDeparture.lastUpdateTime + occupancyStatus = arrivalsAndDeparture.occupancyStatus + predicted = arrivalsAndDeparture.predicted + predictedArrivalInterval = arrivalsAndDeparture.predictedArrivalInterval + predictedDepartureInterval = arrivalsAndDeparture.predictedDepartureInterval + predictedOccupancy = arrivalsAndDeparture.predictedOccupancy + routeLongName = arrivalsAndDeparture.routeLongName + routeShortName = arrivalsAndDeparture.routeShortName + scheduledArrivalInterval = arrivalsAndDeparture.scheduledArrivalInterval + scheduledDepartureInterval = arrivalsAndDeparture.scheduledDepartureInterval + scheduledTrack = arrivalsAndDeparture.scheduledTrack + situationIds = arrivalsAndDeparture.situationIds.map { it.toMutableList() } + status = arrivalsAndDeparture.status + tripStatus = arrivalsAndDeparture.tripStatus + additionalProperties = + arrivalsAndDeparture.additionalProperties.toMutableMap() + } + + /** Indicates if riders can arrive on this transit vehicle. */ + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) + + /** + * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arrivalEnabled(arrivalEnabled: JsonField) = apply { + this.arrivalEnabled = arrivalEnabled + } + + /** + * Index of this arrival’s trip into the sequence of trips for the active block. + */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** Indicates if riders can depart from this transit vehicle. */ + fun departureEnabled(departureEnabled: Boolean) = + departureEnabled(JsonField.of(departureEnabled)) + + /** + * Sets [Builder.departureEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.departureEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun departureEnabled(departureEnabled: JsonField) = apply { + this.departureEnabled = departureEnabled + } + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + */ + fun numberOfStopsAway(numberOfStopsAway: Long) = + numberOfStopsAway(JsonField.of(numberOfStopsAway)) + + /** + * Sets [Builder.numberOfStopsAway] to an arbitrary JSON value. + * + * You should usually call [Builder.numberOfStopsAway] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { + this.numberOfStopsAway = numberOfStopsAway + } + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no + * real-time available). + */ + fun predictedArrivalTime(predictedArrivalTime: Long) = + predictedArrivalTime(JsonField.of(predictedArrivalTime)) + + /** + * Sets [Builder.predictedArrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedArrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { + this.predictedArrivalTime = predictedArrivalTime + } + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no + * real-time available). + */ + fun predictedDepartureTime(predictedDepartureTime: Long) = + predictedDepartureTime(JsonField.of(predictedDepartureTime)) + + /** + * Sets [Builder.predictedDepartureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedDepartureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { + this.predictedDepartureTime = predictedDepartureTime + } + + /** The ID of the route for the arriving vehicle. */ + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(scheduledArrivalTime: Long) = + scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) + + /** + * Sets [Builder.scheduledArrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledArrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { + this.scheduledArrivalTime = scheduledArrivalTime + } + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + fun scheduledDepartureTime(scheduledDepartureTime: Long) = + scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) + + /** + * Sets [Builder.scheduledDepartureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDepartureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { + this.scheduledDepartureTime = scheduledDepartureTime + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** The ID of the stop the vehicle is arriving at. */ + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + */ + fun stopSequence(stopSequence: Long) = stopSequence(JsonField.of(stopSequence)) + + /** + * Sets [Builder.stopSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.stopSequence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun stopSequence(stopSequence: JsonField) = apply { + this.stopSequence = stopSequence + } + + /** Total number of stops visited on the trip for this arrival. */ + fun totalStopsInTrip(totalStopsInTrip: Long) = + totalStopsInTrip(JsonField.of(totalStopsInTrip)) + + /** + * Sets [Builder.totalStopsInTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalStopsInTrip] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { + this.totalStopsInTrip = totalStopsInTrip + } + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + */ + fun tripHeadsign(tripHeadsign: String) = + tripHeadsign(JsonField.of(tripHeadsign)) + + /** + * Sets [Builder.tripHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.tripHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripHeadsign(tripHeadsign: JsonField) = apply { + this.tripHeadsign = tripHeadsign + } + + /** The ID of the trip for the arriving vehicle. */ + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + /** ID of the transit vehicle serving this trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + /** The actual track information of the arriving transit vehicle. */ + fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) + + /** + * Sets [Builder.actualTrack] to an arbitrary JSON value. + * + * You should usually call [Builder.actualTrack] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun actualTrack(actualTrack: JsonField) = apply { + this.actualTrack = actualTrack + } + + /** Distance of the arriving transit vehicle from the stop, in meters. */ + fun distanceFromStop(distanceFromStop: Double) = + distanceFromStop(JsonField.of(distanceFromStop)) + + /** + * Sets [Builder.distanceFromStop] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceFromStop] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceFromStop(distanceFromStop: JsonField) = apply { + this.distanceFromStop = distanceFromStop + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Historical occupancy information of the transit vehicle. */ + fun historicalOccupancy(historicalOccupancy: String) = + historicalOccupancy(JsonField.of(historicalOccupancy)) + + /** + * Sets [Builder.historicalOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.historicalOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun historicalOccupancy(historicalOccupancy: JsonField) = apply { + this.historicalOccupancy = historicalOccupancy + } + + /** Timestamp of the last update time for this arrival. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** Interval for predicted arrival time, if available. */ + fun predictedArrivalInterval(predictedArrivalInterval: String) = + predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) + + /** + * Sets [Builder.predictedArrivalInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedArrivalInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = + apply { + this.predictedArrivalInterval = predictedArrivalInterval + } + + /** Interval for predicted departure time, if available. */ + fun predictedDepartureInterval(predictedDepartureInterval: String) = + predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) + + /** + * Sets [Builder.predictedDepartureInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedDepartureInterval] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = + apply { + this.predictedDepartureInterval = predictedDepartureInterval + } + + /** Predicted occupancy status of the transit vehicle. */ + fun predictedOccupancy(predictedOccupancy: String) = + predictedOccupancy(JsonField.of(predictedOccupancy)) + + /** + * Sets [Builder.predictedOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedOccupancy(predictedOccupancy: JsonField) = apply { + this.predictedOccupancy = predictedOccupancy + } + + /** + * Optional route long name that potentially overrides the route long name in + * the referenced route element. + */ + fun routeLongName(routeLongName: String) = + routeLongName(JsonField.of(routeLongName)) + + /** + * Sets [Builder.routeLongName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeLongName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun routeLongName(routeLongName: JsonField) = apply { + this.routeLongName = routeLongName + } + + /** + * Optional route short name that potentially overrides the route short name in + * the referenced route element. + */ + fun routeShortName(routeShortName: String) = + routeShortName(JsonField.of(routeShortName)) + + /** + * Sets [Builder.routeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun routeShortName(routeShortName: JsonField) = apply { + this.routeShortName = routeShortName + } + + /** Interval for scheduled arrival time. */ + fun scheduledArrivalInterval(scheduledArrivalInterval: String) = + scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) + + /** + * Sets [Builder.scheduledArrivalInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledArrivalInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = + apply { + this.scheduledArrivalInterval = scheduledArrivalInterval + } + + /** Interval for scheduled departure time. */ + fun scheduledDepartureInterval(scheduledDepartureInterval: String) = + scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) + + /** + * Sets [Builder.scheduledDepartureInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDepartureInterval] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = + apply { + this.scheduledDepartureInterval = scheduledDepartureInterval + } + + /** Scheduled track information of the arriving transit vehicle. */ + fun scheduledTrack(scheduledTrack: String) = + scheduledTrack(JsonField.of(scheduledTrack)) + + /** + * Sets [Builder.scheduledTrack] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledTrack] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledTrack(scheduledTrack: JsonField) = apply { + this.scheduledTrack = scheduledTrack + } + + /** References to situation elements (if any) applicable to this arrival. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** Current status of the arrival. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Trip-specific status for the arriving transit vehicle. */ + fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) + + /** + * Sets [Builder.tripStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.tripStatus] with a well-typed [TripStatus] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripStatus(tripStatus: JsonField) = apply { + this.tripStatus = tripStatus + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ArrivalsAndDeparture]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .blockTripSequence() + * .departureEnabled() + * .numberOfStopsAway() + * .predictedArrivalTime() + * .predictedDepartureTime() + * .routeId() + * .scheduledArrivalTime() + * .scheduledDepartureTime() + * .serviceDate() + * .stopId() + * .stopSequence() + * .totalStopsInTrip() + * .tripHeadsign() + * .tripId() + * .vehicleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArrivalsAndDeparture = + ArrivalsAndDeparture( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("departureEnabled", departureEnabled), + checkRequired("numberOfStopsAway", numberOfStopsAway), + checkRequired("predictedArrivalTime", predictedArrivalTime), + checkRequired("predictedDepartureTime", predictedDepartureTime), + checkRequired("routeId", routeId), + checkRequired("scheduledArrivalTime", scheduledArrivalTime), + checkRequired("scheduledDepartureTime", scheduledDepartureTime), + checkRequired("serviceDate", serviceDate), + checkRequired("stopId", stopId), + checkRequired("stopSequence", stopSequence), + checkRequired("totalStopsInTrip", totalStopsInTrip), + checkRequired("tripHeadsign", tripHeadsign), + checkRequired("tripId", tripId), + checkRequired("vehicleId", vehicleId), + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + status, + tripStatus, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ArrivalsAndDeparture = apply { + if (validated) { + return@apply + } + + arrivalEnabled() + blockTripSequence() + departureEnabled() + numberOfStopsAway() + predictedArrivalTime() + predictedDepartureTime() + routeId() + scheduledArrivalTime() + scheduledDepartureTime() + serviceDate() + stopId() + stopSequence() + totalStopsInTrip() + tripHeadsign() + tripId() + vehicleId() + actualTrack() + distanceFromStop() + frequency() + historicalOccupancy() + lastUpdateTime() + occupancyStatus() + predicted() + predictedArrivalInterval() + predictedDepartureInterval() + predictedOccupancy() + routeLongName() + routeShortName() + scheduledArrivalInterval() + scheduledDepartureInterval() + scheduledTrack() + situationIds() + status() + tripStatus().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (departureEnabled.asKnown().isPresent) 1 else 0) + + (if (numberOfStopsAway.asKnown().isPresent) 1 else 0) + + (if (predictedArrivalTime.asKnown().isPresent) 1 else 0) + + (if (predictedDepartureTime.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (scheduledArrivalTime.asKnown().isPresent) 1 else 0) + + (if (scheduledDepartureTime.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (stopSequence.asKnown().isPresent) 1 else 0) + + (if (totalStopsInTrip.asKnown().isPresent) 1 else 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + (if (actualTrack.asKnown().isPresent) 1 else 0) + + (if (distanceFromStop.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (predictedArrivalInterval.asKnown().isPresent) 1 else 0) + + (if (predictedDepartureInterval.asKnown().isPresent) 1 else 0) + + (if (predictedOccupancy.asKnown().isPresent) 1 else 0) + + (if (routeLongName.asKnown().isPresent) 1 else 0) + + (if (routeShortName.asKnown().isPresent) 1 else 0) + + (if (scheduledArrivalInterval.asKnown().isPresent) 1 else 0) + + (if (scheduledDepartureInterval.asKnown().isPresent) 1 else 0) + + (if (scheduledTrack.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (tripStatus.asKnown().getOrNull()?.validity() ?: 0) + + /** Trip-specific status for the arriving transit vehicle. */ + class TripStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun blockTripSequence(): Long = + blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun distanceAlongTrip(): Double = + distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyCapacity(): Long = + occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scheduleDeviation(): Long = + scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle (optional). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownLocation(): Optional = + lastKnownLocation.getOptional("lastKnownLocation") + + /** + * Last known orientation value received in real-time from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastKnownOrientation(): Optional = + lastKnownOrientation.getOptional("lastKnownOrientation") + + /** + * ID of the next stop the transit vehicle is scheduled to arrive at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStop(): Optional = nextStop.getOptional("nextStop") + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun nextStopTimeOffset(): Optional = + nextStopTimeOffset.getOptional("nextStopTimeOffset") + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("orientation") + + /** + * Current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDistanceAlongTrip(): Optional = + scheduledDistanceAlongTrip.getOptional("scheduledDistanceAlongTrip") + + /** + * References to situation elements (if any) applicable to this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * ID of the transit vehicle currently serving the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vehicleId(): Optional = vehicleId.getOptional("vehicleId") + + /** + * Returns the raw JSON value of [activeTripId]. + * + * Unlike [activeTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [closestStop]. + * + * Unlike [closestStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop + + /** + * Returns the raw JSON value of [distanceAlongTrip]. + * + * Unlike [distanceAlongTrip], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Returns the raw JSON value of [lastKnownDistanceAlongTrip]. + * + * Unlike [lastKnownDistanceAlongTrip], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = + lastKnownDistanceAlongTrip + + /** + * Returns the raw JSON value of [lastLocationUpdateTime]. + * + * Unlike [lastLocationUpdateTime], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyCapacity]. + * + * Unlike [occupancyCapacity], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity + + /** + * Returns the raw JSON value of [occupancyCount]. + * + * Unlike [occupancyCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [phase]. + * + * Unlike [phase], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [scheduleDeviation]. + * + * Unlike [scheduleDeviation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduleDeviation") + @ExcludeMissing + fun _scheduleDeviation(): JsonField = scheduleDeviation + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [totalDistanceAlongTrip]. + * + * Unlike [totalDistanceAlongTrip], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Returns the raw JSON value of [closestStopTimeOffset]. + * + * Unlike [closestStopTimeOffset], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [lastKnownLocation]. + * + * Unlike [lastKnownLocation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Returns the raw JSON value of [lastKnownOrientation]. + * + * Unlike [lastKnownOrientation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** + * Returns the raw JSON value of [nextStop]. + * + * Unlike [nextStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Returns the raw JSON value of [nextStopTimeOffset]. + * + * Unlike [nextStopTimeOffset], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [scheduledDistanceAlongTrip]. + * + * Unlike [scheduledDistanceAlongTrip], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = + scheduledDistanceAlongTrip + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripStatus]. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripStatus]. */ + class Builder internal constructor() { + + private var activeTripId: JsonField? = null + private var blockTripSequence: JsonField? = null + private var closestStop: JsonField? = null + private var distanceAlongTrip: JsonField? = null + private var lastKnownDistanceAlongTrip: JsonField? = null + private var lastLocationUpdateTime: JsonField? = null + private var lastUpdateTime: JsonField? = null + private var occupancyCapacity: JsonField? = null + private var occupancyCount: JsonField? = null + private var occupancyStatus: JsonField? = null + private var phase: JsonField? = null + private var predicted: JsonField? = null + private var scheduleDeviation: JsonField? = null + private var serviceDate: JsonField? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null + private var closestStopTimeOffset: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var lastKnownLocation: JsonField = + JsonMissing.of() + private var lastKnownOrientation: JsonField = JsonMissing.of() + private var nextStop: JsonField = JsonMissing.of() + private var nextStopTimeOffset: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var vehicleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tripStatus: TripStatus) = apply { + activeTripId = tripStatus.activeTripId + blockTripSequence = tripStatus.blockTripSequence + closestStop = tripStatus.closestStop + distanceAlongTrip = tripStatus.distanceAlongTrip + lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip + lastLocationUpdateTime = tripStatus.lastLocationUpdateTime + lastUpdateTime = tripStatus.lastUpdateTime + occupancyCapacity = tripStatus.occupancyCapacity + occupancyCount = tripStatus.occupancyCount + occupancyStatus = tripStatus.occupancyStatus + phase = tripStatus.phase + predicted = tripStatus.predicted + scheduleDeviation = tripStatus.scheduleDeviation + serviceDate = tripStatus.serviceDate + status = tripStatus.status + totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip + closestStopTimeOffset = tripStatus.closestStopTimeOffset + frequency = tripStatus.frequency + lastKnownLocation = tripStatus.lastKnownLocation + lastKnownOrientation = tripStatus.lastKnownOrientation + nextStop = tripStatus.nextStop + nextStopTimeOffset = tripStatus.nextStopTimeOffset + orientation = tripStatus.orientation + position = tripStatus.position + scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip + situationIds = tripStatus.situationIds.map { it.toMutableList() } + vehicleId = tripStatus.vehicleId + additionalProperties = tripStatus.additionalProperties.toMutableMap() + } + + /** Trip ID of the trip the vehicle is actively serving. */ + fun activeTripId(activeTripId: String) = + activeTripId(JsonField.of(activeTripId)) + + /** + * Sets [Builder.activeTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.activeTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun activeTripId(activeTripId: JsonField) = apply { + this.activeTripId = activeTripId + } + + /** + * Index of the active trip into the sequence of trips for the active block. + */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** + * ID of the closest stop to the current location of the transit vehicle. + */ + fun closestStop(closestStop: String) = + closestStop(JsonField.of(closestStop)) + + /** + * Sets [Builder.closestStop] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun closestStop(closestStop: JsonField) = apply { + this.closestStop = closestStop + } + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + */ + fun distanceAlongTrip(distanceAlongTrip: Double) = + distanceAlongTrip(JsonField.of(distanceAlongTrip)) + + /** + * Sets [Builder.distanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongTrip] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { + this.distanceAlongTrip = distanceAlongTrip + } + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: Double) = + lastKnownDistanceAlongTrip(JsonField.of(lastKnownDistanceAlongTrip)) + + /** + * Sets [Builder.lastKnownDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun lastKnownDistanceAlongTrip( + lastKnownDistanceAlongTrip: JsonField + ) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) + + /** + * Sets [Builder.lastLocationUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastLocationUpdateTime] with a + * well-typed [Long] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = + apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } + + /** + * Timestamp of the last known real-time update from the transit vehicle. + */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Capacity of the transit vehicle in terms of occupancy. */ + fun occupancyCapacity(occupancyCapacity: Long) = + occupancyCapacity(JsonField.of(occupancyCapacity)) + + /** + * Sets [Builder.occupancyCapacity] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCapacity] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun occupancyCapacity(occupancyCapacity: JsonField) = apply { + this.occupancyCapacity = occupancyCapacity + } + + /** Current count of occupants in the transit vehicle. */ + fun occupancyCount(occupancyCount: Long) = + occupancyCount(JsonField.of(occupancyCount)) + + /** + * Sets [Builder.occupancyCount] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyCount(occupancyCount: JsonField) = apply { + this.occupancyCount = occupancyCount + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Current journey phase of the trip. */ + fun phase(phase: String) = phase(JsonField.of(phase)) + + /** + * Sets [Builder.phase] to an arbitrary JSON value. + * + * You should usually call [Builder.phase] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun phase(phase: JsonField) = apply { this.phase = phase } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + */ + fun scheduleDeviation(scheduleDeviation: Long) = + scheduleDeviation(JsonField.of(scheduleDeviation)) + + /** + * Sets [Builder.scheduleDeviation] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDeviation] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun scheduleDeviation(scheduleDeviation: JsonField) = apply { + this.scheduleDeviation = scheduleDeviation + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of + * the service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** Current status modifiers for the trip. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Total length of the trip, in meters. */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = + totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) + + /** + * Sets [Builder.totalDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = + apply { + this.totalDistanceAlongTrip = totalDistanceAlongTrip + } + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(closestStopTimeOffset: Long) = + closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) + + /** + * Sets [Builder.closestStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.closestStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { + this.closestStopTimeOffset = closestStopTimeOffset + } + + /** + * Information about frequency-based scheduling, if applicable to the trip. + */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Last known location of the transit vehicle (optional). */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation?) = + lastKnownLocation(JsonField.ofNullable(lastKnownLocation)) + + /** + * Alias for calling [Builder.lastKnownLocation] with + * `lastKnownLocation.orElse(null)`. + */ + fun lastKnownLocation(lastKnownLocation: Optional) = + lastKnownLocation(lastKnownLocation.getOrNull()) + + /** + * Sets [Builder.lastKnownLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownLocation] with a well-typed + * [LastKnownLocation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun lastKnownLocation(lastKnownLocation: JsonField) = + apply { + this.lastKnownLocation = lastKnownLocation + } + + /** + * Last known orientation value received in real-time from the transit + * vehicle. + */ + fun lastKnownOrientation(lastKnownOrientation: Double) = + lastKnownOrientation(JsonField.of(lastKnownOrientation)) + + /** + * Sets [Builder.lastKnownOrientation] to an arbitrary JSON value. + * + * You should usually call [Builder.lastKnownOrientation] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { + this.lastKnownOrientation = lastKnownOrientation + } + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) + + /** + * Sets [Builder.nextStop] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStop] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nextStop(nextStop: JsonField) = apply { + this.nextStop = nextStop + } + + /** + * Time offset from the next stop to the current position of the transit + * vehicle (in seconds). + */ + fun nextStopTimeOffset(nextStopTimeOffset: Long) = + nextStopTimeOffset(JsonField.of(nextStopTimeOffset)) + + /** + * Sets [Builder.nextStopTimeOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStopTimeOffset] with a well-typed + * [Long] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { + this.nextStopTimeOffset = nextStopTimeOffset + } + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + */ + fun orientation(orientation: Double) = + orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun position(position: JsonField) = apply { + this.position = position + } + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = + scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) + + /** + * Sets [Builder.scheduledDistanceAlongTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDistanceAlongTrip] with a + * well-typed [Double] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scheduledDistanceAlongTrip( + scheduledDistanceAlongTrip: JsonField + ) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TripStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeTripId() + * .blockTripSequence() + * .closestStop() + * .distanceAlongTrip() + * .lastKnownDistanceAlongTrip() + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .occupancyCapacity() + * .occupancyCount() + * .occupancyStatus() + * .phase() + * .predicted() + * .scheduleDeviation() + * .serviceDate() + * .status() + * .totalDistanceAlongTrip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TripStatus = + TripStatus( + checkRequired("activeTripId", activeTripId), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("closestStop", closestStop), + checkRequired("distanceAlongTrip", distanceAlongTrip), + checkRequired( + "lastKnownDistanceAlongTrip", + lastKnownDistanceAlongTrip, + ), + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("occupancyCapacity", occupancyCapacity), + checkRequired("occupancyCount", occupancyCount), + checkRequired("occupancyStatus", occupancyStatus), + checkRequired("phase", phase), + checkRequired("predicted", predicted), + checkRequired("scheduleDeviation", scheduleDeviation), + checkRequired("serviceDate", serviceDate), + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + vehicleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripStatus = apply { + if (validated) { + return@apply + } + + activeTripId() + blockTripSequence() + closestStop() + distanceAlongTrip() + lastKnownDistanceAlongTrip() + lastLocationUpdateTime() + lastUpdateTime() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + predicted() + scheduleDeviation() + serviceDate() + status() + totalDistanceAlongTrip() + closestStopTimeOffset() + frequency() + lastKnownLocation().ifPresent { it.validate() } + lastKnownOrientation() + nextStop() + nextStopTimeOffset() + orientation() + position().ifPresent { it.validate() } + scheduledDistanceAlongTrip() + situationIds() + vehicleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (activeTripId.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (closestStop.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastKnownDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (lastLocationUpdateTime.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyCapacity.asKnown().isPresent) 1 else 0) + + (if (occupancyCount.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (phase.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (scheduleDeviation.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (totalDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (closestStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (lastKnownLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastKnownOrientation.asKnown().isPresent) 1 else 0) + + (if (nextStop.asKnown().isPresent) 1 else 0) + + (if (nextStopTimeOffset.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + + (if (scheduledDistanceAlongTrip.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + /** Last known location of the transit vehicle (optional). */ + class LastKnownLocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastKnownLocation && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Position]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripStatus && + activeTripId == other.activeTripId && + blockTripSequence == other.blockTripSequence && + closestStop == other.closestStop && + distanceAlongTrip == other.distanceAlongTrip && + lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && + lastLocationUpdateTime == other.lastLocationUpdateTime && + lastUpdateTime == other.lastUpdateTime && + occupancyCapacity == other.occupancyCapacity && + occupancyCount == other.occupancyCount && + occupancyStatus == other.occupancyStatus && + phase == other.phase && + predicted == other.predicted && + scheduleDeviation == other.scheduleDeviation && + serviceDate == other.serviceDate && + status == other.status && + totalDistanceAlongTrip == other.totalDistanceAlongTrip && + closestStopTimeOffset == other.closestStopTimeOffset && + frequency == other.frequency && + lastKnownLocation == other.lastKnownLocation && + lastKnownOrientation == other.lastKnownOrientation && + nextStop == other.nextStop && + nextStopTimeOffset == other.nextStopTimeOffset && + orientation == other.orientation && + position == other.position && + scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && + situationIds == other.situationIds && + vehicleId == other.vehicleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ArrivalsAndDeparture && + arrivalEnabled == other.arrivalEnabled && + blockTripSequence == other.blockTripSequence && + departureEnabled == other.departureEnabled && + numberOfStopsAway == other.numberOfStopsAway && + predictedArrivalTime == other.predictedArrivalTime && + predictedDepartureTime == other.predictedDepartureTime && + routeId == other.routeId && + scheduledArrivalTime == other.scheduledArrivalTime && + scheduledDepartureTime == other.scheduledDepartureTime && + serviceDate == other.serviceDate && + stopId == other.stopId && + stopSequence == other.stopSequence && + totalStopsInTrip == other.totalStopsInTrip && + tripHeadsign == other.tripHeadsign && + tripId == other.tripId && + vehicleId == other.vehicleId && + actualTrack == other.actualTrack && + distanceFromStop == other.distanceFromStop && + frequency == other.frequency && + historicalOccupancy == other.historicalOccupancy && + lastUpdateTime == other.lastUpdateTime && + occupancyStatus == other.occupancyStatus && + predicted == other.predicted && + predictedArrivalInterval == other.predictedArrivalInterval && + predictedDepartureInterval == other.predictedDepartureInterval && + predictedOccupancy == other.predictedOccupancy && + routeLongName == other.routeLongName && + routeShortName == other.routeShortName && + scheduledArrivalInterval == other.scheduledArrivalInterval && + scheduledDepartureInterval == other.scheduledDepartureInterval && + scheduledTrack == other.scheduledTrack && + situationIds == other.situationIds && + status == other.status && + tripStatus == other.tripStatus && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalEnabled, + blockTripSequence, + departureEnabled, + numberOfStopsAway, + predictedArrivalTime, + predictedDepartureTime, + routeId, + scheduledArrivalTime, + scheduledDepartureTime, + serviceDate, + stopId, + stopSequence, + totalStopsInTrip, + tripHeadsign, + tripId, + vehicleId, + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + situationIds, + status, + tripStatus, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ArrivalsAndDeparture{arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, numberOfStopsAway=$numberOfStopsAway, predictedArrivalTime=$predictedArrivalTime, predictedDepartureTime=$predictedDepartureTime, routeId=$routeId, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureTime=$scheduledDepartureTime, serviceDate=$serviceDate, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, vehicleId=$vehicleId, actualTrack=$actualTrack, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedDepartureInterval=$predictedDepartureInterval, predictedOccupancy=$predictedOccupancy, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledTrack=$scheduledTrack, situationIds=$situationIds, status=$status, tripStatus=$tripStatus, additionalProperties=$additionalProperties}" + } + + class NearbyStopId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val distanceFromQuery: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("distanceFromQuery") + @ExcludeMissing + distanceFromQuery: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this(distanceFromQuery, stopId, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceFromQuery(): Optional = + distanceFromQuery.getOptional("distanceFromQuery") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun stopId(): Optional = stopId.getOptional("stopId") + + /** + * Returns the raw JSON value of [distanceFromQuery]. + * + * Unlike [distanceFromQuery], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceFromQuery") + @ExcludeMissing + fun _distanceFromQuery(): JsonField = distanceFromQuery + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [NearbyStopId]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NearbyStopId]. */ + class Builder internal constructor() { + + private var distanceFromQuery: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(nearbyStopId: NearbyStopId) = apply { + distanceFromQuery = nearbyStopId.distanceFromQuery + stopId = nearbyStopId.stopId + additionalProperties = nearbyStopId.additionalProperties.toMutableMap() + } + + fun distanceFromQuery(distanceFromQuery: Double) = + distanceFromQuery(JsonField.of(distanceFromQuery)) + + /** + * Sets [Builder.distanceFromQuery] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceFromQuery] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceFromQuery(distanceFromQuery: JsonField) = apply { + this.distanceFromQuery = distanceFromQuery + } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NearbyStopId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NearbyStopId = + NearbyStopId(distanceFromQuery, stopId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): NearbyStopId = apply { + if (validated) { + return@apply + } + + distanceFromQuery() + stopId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (distanceFromQuery.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NearbyStopId && + distanceFromQuery == other.distanceFromQuery && + stopId == other.stopId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(distanceFromQuery, stopId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NearbyStopId{distanceFromQuery=$distanceFromQuery, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entry && + arrivalsAndDepartures == other.arrivalsAndDepartures && + limitExceeded == other.limitExceeded && + nearbyStopIds == other.nearbyStopIds && + stopIds == other.stopIds && + situationIds == other.situationIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalsAndDepartures, + limitExceeded, + nearbyStopIds, + stopIds, + situationIds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{arrivalsAndDepartures=$arrivalsAndDepartures, limitExceeded=$limitExceeded, nearbyStopIds=$nearbyStopIds, stopIds=$stopIds, situationIds=$situationIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ArrivalsAndDeparturesForLocationListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ArrivalsAndDeparturesForLocationListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsync.kt new file mode 100644 index 0000000..86ee8fc --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsync.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListParams +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListResponse + +interface ArrivalsAndDeparturesForLocationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ArrivalsAndDeparturesForLocationServiceAsync + + /** + * Returns real-time arrival and departure data for stops within a bounding box or radius + * centered on a specific location. + */ + fun list( + params: ArrivalsAndDeparturesForLocationListParams + ): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ArrivalsAndDeparturesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [ArrivalsAndDeparturesForLocationServiceAsync] that provides access to raw HTTP + * responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ArrivalsAndDeparturesForLocationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/where/arrivals-and-departures-for-location.json`, but is otherwise the same as + * [ArrivalsAndDeparturesForLocationServiceAsync.list]. + */ + fun list( + params: ArrivalsAndDeparturesForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ArrivalsAndDeparturesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsyncImpl.kt new file mode 100644 index 0000000..bef5229 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsyncImpl.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListParams +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListResponse + +class ArrivalsAndDeparturesForLocationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : + ArrivalsAndDeparturesForLocationServiceAsync { + + private val withRawResponse: + ArrivalsAndDeparturesForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ArrivalsAndDeparturesForLocationServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): ArrivalsAndDeparturesForLocationServiceAsync = + ArrivalsAndDeparturesForLocationServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun list( + params: ArrivalsAndDeparturesForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/arrivals-and-departures-for-location.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ArrivalsAndDeparturesForLocationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ArrivalsAndDeparturesForLocationServiceAsync.WithRawResponse = + ArrivalsAndDeparturesForLocationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: ArrivalsAndDeparturesForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "where", "arrivals-and-departures-for-location.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationService.kt new file mode 100644 index 0000000..9495e7b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationService.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListParams +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListResponse + +interface ArrivalsAndDeparturesForLocationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ArrivalsAndDeparturesForLocationService + + /** + * Returns real-time arrival and departure data for stops within a bounding box or radius + * centered on a specific location. + */ + fun list( + params: ArrivalsAndDeparturesForLocationListParams + ): ArrivalsAndDeparturesForLocationListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ArrivalsAndDeparturesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ArrivalsAndDeparturesForLocationListResponse + + /** + * A view of [ArrivalsAndDeparturesForLocationService] that provides access to raw HTTP + * responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ArrivalsAndDeparturesForLocationService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/where/arrivals-and-departures-for-location.json`, but is otherwise the same as + * [ArrivalsAndDeparturesForLocationService.list]. + */ + @MustBeClosed + fun list( + params: ArrivalsAndDeparturesForLocationListParams + ): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ArrivalsAndDeparturesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationServiceImpl.kt new file mode 100644 index 0000000..6b12394 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationServiceImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListParams +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListResponse + +class ArrivalsAndDeparturesForLocationServiceImpl +internal constructor(private val clientOptions: ClientOptions) : + ArrivalsAndDeparturesForLocationService { + + private val withRawResponse: ArrivalsAndDeparturesForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ArrivalsAndDeparturesForLocationService.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): ArrivalsAndDeparturesForLocationService = + ArrivalsAndDeparturesForLocationServiceImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun list( + params: ArrivalsAndDeparturesForLocationListParams, + requestOptions: RequestOptions, + ): ArrivalsAndDeparturesForLocationListResponse = + // get /api/where/arrivals-and-departures-for-location.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ArrivalsAndDeparturesForLocationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ArrivalsAndDeparturesForLocationService.WithRawResponse = + ArrivalsAndDeparturesForLocationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: ArrivalsAndDeparturesForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "where", "arrivals-and-departures-for-location.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListParamsTest.kt new file mode 100644 index 0000000..81f7576 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListParamsTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalsanddeparturesforlocation + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class ArrivalsAndDeparturesForLocationListParamsTest { + + @Test + fun create() { + ArrivalsAndDeparturesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .emptyReturnsNotFound(true) + .latSpan(0.0) + .lonSpan(0.0) + .maxCount(1000L) + .minutesAfter(0L) + .minutesBefore(0L) + .radius(0.0) + .routeType("routeType") + .time(0L) + .build() + } + + @Test + fun queryParams() { + val params = + ArrivalsAndDeparturesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .emptyReturnsNotFound(true) + .latSpan(0.0) + .lonSpan(0.0) + .maxCount(1000L) + .minutesAfter(0L) + .minutesBefore(0L) + .radius(0.0) + .routeType("routeType") + .time(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("lat", "0.0") + .put("lon", "0.0") + .put("emptyReturnsNotFound", "true") + .put("latSpan", "0.0") + .put("lonSpan", "0.0") + .put("maxCount", "1000") + .put("minutesAfter", "0") + .put("minutesBefore", "0") + .put("radius", "0.0") + .put("routeType", "routeType") + .put("time", "0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ArrivalsAndDeparturesForLocationListParams.builder().lat(0.0).lon(0.0).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("lat", "0.0").put("lon", "0.0").build()) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponseTest.kt new file mode 100644 index 0000000..d198655 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponseTest.kt @@ -0,0 +1,817 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalsanddeparturesforlocation + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class ArrivalsAndDeparturesForLocationListResponseTest { + + @Test + fun create() { + val arrivalsAndDeparturesForLocationListResponse = + ArrivalsAndDeparturesForLocationListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ArrivalsAndDeparturesForLocationListResponse.Data.builder() + .entry( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry.builder() + .addArrivalsAndDeparture( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry + .ArrivalsAndDeparture + .builder() + .arrivalEnabled(true) + .blockTripSequence(0L) + .departureEnabled(true) + .numberOfStopsAway(0L) + .predictedArrivalTime(0L) + .predictedDepartureTime(0L) + .routeId("routeId") + .scheduledArrivalTime(0L) + .scheduledDepartureTime(0L) + .serviceDate(0L) + .stopId("stopId") + .stopSequence(0L) + .totalStopsInTrip(0L) + .tripHeadsign("tripHeadsign") + .tripId("tripId") + .vehicleId("vehicleId") + .actualTrack("actualTrack") + .distanceFromStop(0.0) + .frequency("frequency") + .historicalOccupancy("historicalOccupancy") + .lastUpdateTime(0L) + .occupancyStatus("occupancyStatus") + .predicted(true) + .predictedArrivalInterval("predictedArrivalInterval") + .predictedDepartureInterval("predictedDepartureInterval") + .predictedOccupancy("predictedOccupancy") + .routeLongName("routeLongName") + .routeShortName("routeShortName") + .scheduledArrivalInterval("scheduledArrivalInterval") + .scheduledDepartureInterval("scheduledDepartureInterval") + .scheduledTrack("scheduledTrack") + .addSituationId("string") + .status("status") + .tripStatus( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .builder() + .activeTripId("activeTripId") + .blockTripSequence(0L) + .closestStop("closestStop") + .distanceAlongTrip(0.0) + .lastKnownDistanceAlongTrip(0.0) + .lastLocationUpdateTime(0L) + .lastUpdateTime(0L) + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .predicted(true) + .scheduleDeviation(0L) + .serviceDate(0L) + .status("status") + .totalDistanceAlongTrip(0.0) + .closestStopTimeOffset(0L) + .frequency("frequency") + .lastKnownLocation( + ArrivalsAndDeparturesForLocationListResponse + .Data + .Entry + .ArrivalsAndDeparture + .TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalsAndDeparturesForLocationListResponse + .Data + .Entry + .ArrivalsAndDeparture + .TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .build() + ) + .limitExceeded(true) + .addNearbyStopId( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry + .NearbyStopId + .builder() + .distanceFromQuery(0.0) + .stopId("stopId") + .build() + ) + .addStopId("string") + .addSituationId("string") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason("reason") + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(arrivalsAndDeparturesForLocationListResponse.code()).isEqualTo(0L) + assertThat(arrivalsAndDeparturesForLocationListResponse.currentTime()).isEqualTo(0L) + assertThat(arrivalsAndDeparturesForLocationListResponse.text()).isEqualTo("text") + assertThat(arrivalsAndDeparturesForLocationListResponse.version()).isEqualTo(0L) + assertThat(arrivalsAndDeparturesForLocationListResponse.data()) + .isEqualTo( + ArrivalsAndDeparturesForLocationListResponse.Data.builder() + .entry( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry.builder() + .addArrivalsAndDeparture( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry + .ArrivalsAndDeparture + .builder() + .arrivalEnabled(true) + .blockTripSequence(0L) + .departureEnabled(true) + .numberOfStopsAway(0L) + .predictedArrivalTime(0L) + .predictedDepartureTime(0L) + .routeId("routeId") + .scheduledArrivalTime(0L) + .scheduledDepartureTime(0L) + .serviceDate(0L) + .stopId("stopId") + .stopSequence(0L) + .totalStopsInTrip(0L) + .tripHeadsign("tripHeadsign") + .tripId("tripId") + .vehicleId("vehicleId") + .actualTrack("actualTrack") + .distanceFromStop(0.0) + .frequency("frequency") + .historicalOccupancy("historicalOccupancy") + .lastUpdateTime(0L) + .occupancyStatus("occupancyStatus") + .predicted(true) + .predictedArrivalInterval("predictedArrivalInterval") + .predictedDepartureInterval("predictedDepartureInterval") + .predictedOccupancy("predictedOccupancy") + .routeLongName("routeLongName") + .routeShortName("routeShortName") + .scheduledArrivalInterval("scheduledArrivalInterval") + .scheduledDepartureInterval("scheduledDepartureInterval") + .scheduledTrack("scheduledTrack") + .addSituationId("string") + .status("status") + .tripStatus( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .builder() + .activeTripId("activeTripId") + .blockTripSequence(0L) + .closestStop("closestStop") + .distanceAlongTrip(0.0) + .lastKnownDistanceAlongTrip(0.0) + .lastLocationUpdateTime(0L) + .lastUpdateTime(0L) + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .predicted(true) + .scheduleDeviation(0L) + .serviceDate(0L) + .status("status") + .totalDistanceAlongTrip(0.0) + .closestStopTimeOffset(0L) + .frequency("frequency") + .lastKnownLocation( + ArrivalsAndDeparturesForLocationListResponse.Data + .Entry + .ArrivalsAndDeparture + .TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalsAndDeparturesForLocationListResponse.Data + .Entry + .ArrivalsAndDeparture + .TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .build() + ) + .limitExceeded(true) + .addNearbyStopId( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry.NearbyStopId + .builder() + .distanceFromQuery(0.0) + .stopId("stopId") + .build() + ) + .addStopId("string") + .addSituationId("string") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence.ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason("reason") + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val arrivalsAndDeparturesForLocationListResponse = + ArrivalsAndDeparturesForLocationListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ArrivalsAndDeparturesForLocationListResponse.Data.builder() + .entry( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry.builder() + .addArrivalsAndDeparture( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry + .ArrivalsAndDeparture + .builder() + .arrivalEnabled(true) + .blockTripSequence(0L) + .departureEnabled(true) + .numberOfStopsAway(0L) + .predictedArrivalTime(0L) + .predictedDepartureTime(0L) + .routeId("routeId") + .scheduledArrivalTime(0L) + .scheduledDepartureTime(0L) + .serviceDate(0L) + .stopId("stopId") + .stopSequence(0L) + .totalStopsInTrip(0L) + .tripHeadsign("tripHeadsign") + .tripId("tripId") + .vehicleId("vehicleId") + .actualTrack("actualTrack") + .distanceFromStop(0.0) + .frequency("frequency") + .historicalOccupancy("historicalOccupancy") + .lastUpdateTime(0L) + .occupancyStatus("occupancyStatus") + .predicted(true) + .predictedArrivalInterval("predictedArrivalInterval") + .predictedDepartureInterval("predictedDepartureInterval") + .predictedOccupancy("predictedOccupancy") + .routeLongName("routeLongName") + .routeShortName("routeShortName") + .scheduledArrivalInterval("scheduledArrivalInterval") + .scheduledDepartureInterval("scheduledDepartureInterval") + .scheduledTrack("scheduledTrack") + .addSituationId("string") + .status("status") + .tripStatus( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .builder() + .activeTripId("activeTripId") + .blockTripSequence(0L) + .closestStop("closestStop") + .distanceAlongTrip(0.0) + .lastKnownDistanceAlongTrip(0.0) + .lastLocationUpdateTime(0L) + .lastUpdateTime(0L) + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .predicted(true) + .scheduleDeviation(0L) + .serviceDate(0L) + .status("status") + .totalDistanceAlongTrip(0.0) + .closestStopTimeOffset(0L) + .frequency("frequency") + .lastKnownLocation( + ArrivalsAndDeparturesForLocationListResponse + .Data + .Entry + .ArrivalsAndDeparture + .TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalsAndDeparturesForLocationListResponse + .Data + .Entry + .ArrivalsAndDeparture + .TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .build() + ) + .limitExceeded(true) + .addNearbyStopId( + ArrivalsAndDeparturesForLocationListResponse.Data.Entry + .NearbyStopId + .builder() + .distanceFromQuery(0.0) + .stopId("stopId") + .build() + ) + .addStopId("string") + .addSituationId("string") + .build() + ) + .references( + References.builder() + .addAgency( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .addRoute( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .addSituation( + References.Situation.builder() + .id("id") + .creationTime(0L) + .addActiveWindow( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + .consequenceMessage("consequenceMessage") + .addConsequence( + References.Situation.Consequence.builder() + .condition("condition") + .conditionDetails( + References.Situation.Consequence + .ConditionDetails + .builder() + .diversionPath( + References.Situation.Consequence + .ConditionDetails + .DiversionPath + .builder() + .length(0L) + .levels("levels") + .points("points") + .build() + ) + .addDiversionStopId("string") + .build() + ) + .build() + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder() + .from(0L) + .to(0L) + .build() + ) + .reason("reason") + .severity("severity") + .summary( + References.Situation.Summary.builder() + .lang("lang") + .value("value") + .build() + ) + .url( + References.Situation.Url.builder() + .lang("lang") + .value("value") + .build() + ) + .build() + ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .locationType(0L) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .addTrip( + References.Trip.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedArrivalsAndDeparturesForLocationListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(arrivalsAndDeparturesForLocationListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedArrivalsAndDeparturesForLocationListResponse) + .isEqualTo(arrivalsAndDeparturesForLocationListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsyncTest.kt new file mode 100644 index 0000000..e73bbb6 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalsAndDeparturesForLocationServiceAsyncTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class ArrivalsAndDeparturesForLocationServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val arrivalsAndDeparturesForLocationServiceAsync = client.arrivalsAndDeparturesForLocation() + + val arrivalsAndDeparturesForLocationsFuture = + arrivalsAndDeparturesForLocationServiceAsync.list( + ArrivalsAndDeparturesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .emptyReturnsNotFound(true) + .latSpan(0.0) + .lonSpan(0.0) + .maxCount(1000L) + .minutesAfter(0L) + .minutesBefore(0L) + .radius(0.0) + .routeType("routeType") + .time(0L) + .build() + ) + + val arrivalsAndDeparturesForLocations = arrivalsAndDeparturesForLocationsFuture.get() + arrivalsAndDeparturesForLocations.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationServiceTest.kt new file mode 100644 index 0000000..33485b0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalsAndDeparturesForLocationServiceTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.arrivalsanddeparturesforlocation.ArrivalsAndDeparturesForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class ArrivalsAndDeparturesForLocationServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val arrivalsAndDeparturesForLocationService = client.arrivalsAndDeparturesForLocation() + + val arrivalsAndDeparturesForLocations = + arrivalsAndDeparturesForLocationService.list( + ArrivalsAndDeparturesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .emptyReturnsNotFound(true) + .latSpan(0.0) + .lonSpan(0.0) + .maxCount(1000L) + .minutesAfter(0L) + .minutesBefore(0L) + .radius(0.0) + .routeType("routeType") + .time(0L) + .build() + ) + + arrivalsAndDeparturesForLocations.validate() + } +} diff --git a/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt b/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt index 9380915..02b1f42 100644 --- a/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt +++ b/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt @@ -65,6 +65,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.routesForLocation()).isNotNull() assertThat(client.routesForAgency()).isNotNull() assertThat(client.scheduleForRoute()).isNotNull() + assertThat(client.arrivalsAndDeparturesForLocation()).isNotNull() assertThat(client.arrivalAndDeparture()).isNotNull() assertThat(client.trip()).isNotNull() assertThat(client.tripsForLocation()).isNotNull() From f74e874bd26003286fbf031c340bf1ae25e1de63 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 06:43:24 +0000 Subject: [PATCH 19/38] chore(tests): bump steady to v0.20.1 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 58e4628..5ea72a2 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.7 -- steady --version + npm exec --package=@stdy/cli@0.20.1 -- steady --version - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 3e49f36..1208b44 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From 7e86c4531e42593b1f50806efd88afaa2f46bdd1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 06:46:03 +0000 Subject: [PATCH 20/38] chore(tests): bump steady to v0.20.2 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 5ea72a2..7c58865 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.20.1 -- steady --version + npm exec --package=@stdy/cli@0.20.2 -- steady --version - npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 1208b44..689f562 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From 344888d82e5616e2f6e6400c270b8e9e89072bbf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 06:32:52 +0000 Subject: [PATCH 21/38] chore(tests): bump steady to v0.22.1 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 7c58865..9c7c439 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.20.2 -- steady --version + npm exec --package=@stdy/cli@0.22.1 -- steady --version - npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 689f562..36e976f 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From 58e75c3de82e535d8c8a1a69922edc71f231d149 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 Apr 2026 03:30:21 +0000 Subject: [PATCH 22/38] feat: support setting headers via env --- .../src/main/kotlin/org/onebusaway/core/ClientOptions.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt index ece86b0..cee2c83 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt @@ -373,6 +373,14 @@ private constructor( (System.getProperty("onebusawaysdk.onebusawayApiKey") ?: System.getenv("ONEBUSAWAY_API_KEY")) ?.let { apiKey(it) } + System.getenv("ONEBUSAWAY_SDK_CUSTOM_HEADERS")?.let { customHeadersEnv -> + for (line in customHeadersEnv.split("\n")) { + val colon = line.indexOf(':') + if (colon >= 0) { + putHeader(line.substring(0, colon).trim(), line.substring(colon + 1).trim()) + } + } + } } /** From dec3538e2d68535a0ede5f7c8f91056c4b41c3b0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 05:40:42 +0000 Subject: [PATCH 23/38] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fa222e3..7c53de2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-a30b0967ffed17b866dc65b5528148a06a42cce7c3c6d8f740ae2f6079963e7d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-a30b0967ffed17b866dc65b5528148a06a42cce7c3c6d8f740ae2f6079963e7d.yml openapi_spec_hash: 9bf1e5bf00ef9936a9181ebd0956d5b8 config_hash: c28ddf5b7754155603d9fd1c5fcaeeff From 417cab1f0884eead57fc7d605406120e2fbf6424 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 04:19:29 +0000 Subject: [PATCH 24/38] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7c53de2..6608e4d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-a30b0967ffed17b866dc65b5528148a06a42cce7c3c6d8f740ae2f6079963e7d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-b625345de7b9c51744ddc6c75b8c37a159a536204481404cca91d7d6a859149d.yml openapi_spec_hash: 9bf1e5bf00ef9936a9181ebd0956d5b8 config_hash: c28ddf5b7754155603d9fd1c5fcaeeff From ce30a3c1bdf6f81bcb3af3cb10470a68b9065b9b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 04:55:31 +0000 Subject: [PATCH 25/38] docs: clarify forwards compat behavior --- README.md | 4 +- .../okhttp/OnebusawaySdkOkHttpClient.kt | 3 + .../okhttp/OnebusawaySdkOkHttpClientAsync.kt | 3 + .../org/onebusaway/core/ClientOptions.kt | 6 + .../org/onebusaway/core/RequestOptions.kt | 9 ++ .../org/onebusaway/models/References.kt | 152 ++++++++++++++++++ .../org/onebusaway/models/ResponseWrapper.kt | 8 + .../AgenciesWithCoverageListResponse.kt | 27 ++++ .../models/agency/AgencyRetrieveResponse.kt | 27 ++++ .../ArrivalAndDepartureListResponse.kt | 67 ++++++++ .../ArrivalAndDepartureRetrieveResponse.kt | 57 +++++++ ...alsAndDeparturesForLocationListResponse.kt | 77 +++++++++ .../models/block/BlockRetrieveResponse.kt | 67 ++++++++ .../models/config/ConfigRetrieveResponse.kt | 37 +++++ .../CurrentTimeRetrieveResponse.kt | 27 ++++ .../ReportProblemWithStopRetrieveParams.kt | 9 ++ .../ReportProblemWithTripRetrieveParams.kt | 9 ++ .../models/route/RouteRetrieveResponse.kt | 27 ++++ .../RouteIdsForAgencyListResponse.kt | 17 ++ .../RoutesForAgencyListResponse.kt | 27 ++++ .../RoutesForLocationListResponse.kt | 27 ++++ .../ScheduleForRouteRetrieveResponse.kt | 57 +++++++ .../ScheduleForStopRetrieveResponse.kt | 67 ++++++++ .../SearchForRouteListResponse.kt | 27 ++++ .../SearchForStopListResponse.kt | 27 ++++ .../models/shape/ShapeRetrieveResponse.kt | 27 ++++ .../models/stop/StopRetrieveResponse.kt | 27 ++++ .../StopIdsForAgencyListResponse.kt | 17 ++ .../StopsForAgencyListResponse.kt | 27 ++++ .../StopsForLocationListResponse.kt | 27 ++++ .../StopsForRouteListResponse.kt | 67 ++++++++ .../models/trip/TripRetrieveResponse.kt | 27 ++++ .../tripdetails/TripDetailRetrieveResponse.kt | 77 +++++++++ .../TripForVehicleRetrieveResponse.kt | 77 +++++++++ .../TripsForLocationListResponse.kt | 77 +++++++++ .../TripsForRouteListResponse.kt | 77 +++++++++ .../VehiclesForAgencyListResponse.kt | 67 ++++++++ 37 files changed, 1458 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ff51c49..e9ae0b3 100644 --- a/README.md +++ b/README.md @@ -553,7 +553,9 @@ In rare cases, the API may return a response that doesn't match the expected typ By default, the SDK will not throw an exception in this case. It will throw [`OnebusawaySdkInvalidDataException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkInvalidDataException.kt) only if you directly access the property. -If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: +Validating the response is _not_ forwards compatible with new types from the API for existing fields. + +If you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt index 3f28f91..f34b7ee 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt @@ -217,6 +217,9 @@ class OnebusawaySdkOkHttpClient private constructor() { /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt index d4260af..9749e4b 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt @@ -217,6 +217,9 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt index cee2c83..817495e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt @@ -66,6 +66,9 @@ private constructor( /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for existing + * fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -229,6 +232,9 @@ private constructor( /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/RequestOptions.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/RequestOptions.kt index 0967032..e70f47d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/RequestOptions.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/RequestOptions.kt @@ -33,6 +33,15 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t private var responseValidation: Boolean? = null private var timeout: Timeout? = null + /** + * Whether to call `validate` on the response before returning it. + * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt index 7469078..dc89050 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt @@ -377,6 +377,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): References = apply { if (validated) { return@apply @@ -819,6 +827,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Agency = apply { if (validated) { return@apply @@ -1318,6 +1335,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Route = apply { if (validated) { return@apply @@ -1971,6 +1997,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Situation = apply { if (validated) { return@apply @@ -2153,6 +2188,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): ActiveWindow = apply { if (validated) { return@apply @@ -2487,6 +2532,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): AllAffect = apply { if (validated) { return@apply @@ -2701,6 +2756,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Consequence = apply { if (validated) { return@apply @@ -2894,6 +2959,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): ConditionDetails = apply { if (validated) { return@apply @@ -3109,6 +3184,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): DiversionPath = apply { if (validated) { return@apply @@ -3337,6 +3422,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Description = apply { if (validated) { return@apply @@ -3539,6 +3634,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PublicationWindow = apply { if (validated) { return@apply @@ -3718,6 +3823,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Summary = apply { if (validated) { return@apply @@ -3897,6 +4012,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Url = apply { if (validated) { return@apply @@ -4475,6 +4600,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Stop = apply { if (validated) { return@apply @@ -4853,6 +4987,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): StopTime = apply { if (validated) { return@apply @@ -5379,6 +5522,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Trip = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt index a646686..5269fef 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt @@ -220,6 +220,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ResponseWrapper = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt index 0c30497..6f7081f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt @@ -267,6 +267,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AgenciesWithCoverageListResponse = apply { if (validated) { return@apply @@ -505,6 +513,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -788,6 +805,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt index c22083c..b668b70 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt @@ -262,6 +262,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AgencyRetrieveResponse = apply { if (validated) { return@apply @@ -446,6 +454,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -894,6 +911,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt index 2f4dc9c..42f7a5f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt @@ -267,6 +267,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ArrivalAndDepartureListResponse = apply { if (validated) { return@apply @@ -451,6 +459,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -624,6 +641,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -2220,6 +2247,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): ArrivalsAndDeparture = apply { if (validated) { return@apply @@ -3630,6 +3667,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): TripStatus = apply { if (validated) { return@apply @@ -3857,6 +3904,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): LastKnownLocation = apply { if (validated) { return@apply @@ -4053,6 +4110,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): Position = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt index eea2098..e5bc6ce 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt @@ -268,6 +268,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ArrivalAndDepartureRetrieveResponse = apply { if (validated) { return@apply @@ -452,6 +460,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -2028,6 +2045,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -3403,6 +3430,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): TripStatus = apply { if (validated) { return@apply @@ -3627,6 +3664,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): LastKnownLocation = apply { if (validated) { return@apply @@ -3818,6 +3865,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Position = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt index 7da06b2..1b8c611 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt @@ -269,6 +269,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ArrivalsAndDeparturesForLocationListResponse = apply { if (validated) { return@apply @@ -453,6 +461,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -824,6 +841,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -2429,6 +2456,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): ArrivalsAndDeparture = apply { if (validated) { return@apply @@ -3839,6 +3876,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): TripStatus = apply { if (validated) { return@apply @@ -4066,6 +4113,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): LastKnownLocation = apply { if (validated) { return@apply @@ -4262,6 +4319,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): Position = apply { if (validated) { return@apply @@ -4615,6 +4682,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): NearbyStopId = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt index 45310ae..267d60b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BlockRetrieveResponse = apply { if (validated) { return@apply @@ -448,6 +456,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -646,6 +663,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -915,6 +942,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Configuration = apply { if (validated) { return@apply @@ -1213,6 +1250,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Trip = apply { if (validated) { return@apply @@ -1504,6 +1551,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): BlockStopTime = apply { if (validated) { return@apply @@ -1830,6 +1887,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): StopTime = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt index 36b882a..d1b5c28 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt @@ -262,6 +262,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ConfigRetrieveResponse = apply { if (validated) { return@apply @@ -446,6 +454,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -718,6 +735,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -1597,6 +1624,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): GitProperties = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt index 7bccd50..e2dd547 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt @@ -262,6 +262,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CurrentTimeRetrieveResponse = apply { if (validated) { return@apply @@ -446,6 +454,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -608,6 +625,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt index e312c7c..a8c4b18 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt @@ -396,6 +396,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Code = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt index 8ced8bf..170c256 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt @@ -490,6 +490,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Code = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt index 652816e..a8a6170 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt @@ -262,6 +262,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): RouteRetrieveResponse = apply { if (validated) { return@apply @@ -446,6 +454,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -903,6 +920,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt index afff93d..52c3844 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt @@ -265,6 +265,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): RouteIdsForAgencyListResponse = apply { if (validated) { return@apply @@ -499,6 +507,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt index 1668fe3..3fa3a52 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): RoutesForAgencyListResponse = apply { if (validated) { return@apply @@ -502,6 +510,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -961,6 +978,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt index 4996e7c..8a70d5c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt @@ -265,6 +265,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): RoutesForLocationListResponse = apply { if (validated) { return@apply @@ -538,6 +546,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -999,6 +1016,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt index b9c6972..30fbb19 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt @@ -266,6 +266,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScheduleForRouteRetrieveResponse = apply { if (validated) { return@apply @@ -410,6 +418,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -700,6 +717,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -1071,6 +1098,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): StopTripGrouping = apply { if (validated) { return@apply @@ -1285,6 +1322,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): TripsWithStopTime = apply { if (validated) { return@apply @@ -1722,6 +1769,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): StopTime = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt index 829a377..14378e7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt @@ -267,6 +267,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScheduleForStopRetrieveResponse = apply { if (validated) { return@apply @@ -451,6 +459,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -687,6 +704,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -910,6 +937,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): StopRouteSchedule = apply { if (validated) { return@apply @@ -1192,6 +1229,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): StopRouteDirectionSchedule = apply { if (validated) { return@apply @@ -1600,6 +1647,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): ScheduleStopTime = apply { if (validated) { return@apply @@ -2000,6 +2057,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this + * object doesn't match its expected type. + */ fun validate(): ScheduleFrequency = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt index 9afba19..5f3c848 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt @@ -262,6 +262,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): SearchForRouteListResponse = apply { if (validated) { return@apply @@ -535,6 +543,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -996,6 +1013,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt index d10d023..f77dea2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt @@ -262,6 +262,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): SearchForStopListResponse = apply { if (validated) { return@apply @@ -535,6 +543,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1074,6 +1091,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt index d7ac834..d47e2ca 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt @@ -262,6 +262,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ShapeRetrieveResponse = apply { if (validated) { return@apply @@ -446,6 +454,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -658,6 +675,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt index 757e36b..2930fd0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StopRetrieveResponse = apply { if (validated) { return@apply @@ -448,6 +456,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -980,6 +997,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt index 3f99781..626aebd 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StopIdsForAgencyListResponse = apply { if (validated) { return@apply @@ -498,6 +506,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt index 3a14a75..b60f3a4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StopsForAgencyListResponse = apply { if (validated) { return@apply @@ -531,6 +539,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1070,6 +1087,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt index 906127c..a7df44e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StopsForLocationListResponse = apply { if (validated) { return@apply @@ -535,6 +543,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1074,6 +1091,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt index 4b154f5..6c7e48c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StopsForRouteListResponse = apply { if (validated) { return@apply @@ -448,6 +456,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -726,6 +743,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -923,6 +950,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Polyline = apply { if (validated) { return@apply @@ -1204,6 +1241,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): StopGrouping = apply { if (validated) { return@apply @@ -1424,6 +1471,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Name = apply { if (validated) { return@apply @@ -1646,6 +1703,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Polyline = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt index bafef25..b8b9b50 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt @@ -262,6 +262,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TripRetrieveResponse = apply { if (validated) { return@apply @@ -446,6 +454,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -952,6 +969,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt index 526340c..e76dff2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TripDetailRetrieveResponse = apply { if (validated) { return@apply @@ -448,6 +456,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -781,6 +798,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -1109,6 +1136,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Schedule = apply { if (validated) { return@apply @@ -1446,6 +1483,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): StopTime = apply { if (validated) { return@apply @@ -2828,6 +2875,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -3052,6 +3109,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): LastKnownLocation = apply { if (validated) { return@apply @@ -3243,6 +3310,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Position = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt index cee36d5..02901ad 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt @@ -266,6 +266,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TripForVehicleRetrieveResponse = apply { if (validated) { return@apply @@ -450,6 +458,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -783,6 +800,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Entry = apply { if (validated) { return@apply @@ -1111,6 +1138,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Schedule = apply { if (validated) { return@apply @@ -1448,6 +1485,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): StopTime = apply { if (validated) { return@apply @@ -2830,6 +2877,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -3054,6 +3111,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): LastKnownLocation = apply { if (validated) { return@apply @@ -3245,6 +3312,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Position = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt index 679536d..cb8b625 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TripsForLocationListResponse = apply { if (validated) { return@apply @@ -541,6 +549,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -887,6 +904,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply @@ -1217,6 +1244,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Schedule = apply { if (validated) { return@apply @@ -1554,6 +1591,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): StopTime = apply { if (validated) { return@apply @@ -2937,6 +2984,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -3161,6 +3218,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): LastKnownLocation = apply { if (validated) { return@apply @@ -3352,6 +3419,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Position = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt index 29a210c..feebad5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt @@ -264,6 +264,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TripsForRouteListResponse = apply { if (validated) { return@apply @@ -502,6 +510,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -846,6 +863,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply @@ -1176,6 +1203,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Schedule = apply { if (validated) { return@apply @@ -1513,6 +1550,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): StopTime = apply { if (validated) { return@apply @@ -2896,6 +2943,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -3120,6 +3177,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): LastKnownLocation = apply { if (validated) { return@apply @@ -3311,6 +3378,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Position = apply { if (validated) { return@apply diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt index 078a607..fdfb08e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -265,6 +265,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): VehiclesForAgencyListResponse = apply { if (validated) { return@apply @@ -503,6 +511,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1023,6 +1040,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): List = apply { if (validated) { return@apply @@ -1196,6 +1223,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Location = apply { if (validated) { return@apply @@ -2526,6 +2563,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): TripStatus = apply { if (validated) { return@apply @@ -2750,6 +2797,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): LastKnownLocation = apply { if (validated) { return@apply @@ -2941,6 +2998,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OnebusawaySdkInvalidDataException if any value type in this object + * doesn't match its expected type. + */ fun validate(): Position = apply { if (validated) { return@apply From 8c92200d5138d6ff8acad77742994445992d0c0a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 04:57:49 +0000 Subject: [PATCH 26/38] feat(client): more robust error parsing --- .../kotlin/org/onebusaway/errors/BadRequestException.kt | 6 +++++- .../org/onebusaway/errors/InternalServerException.kt | 7 ++++++- .../main/kotlin/org/onebusaway/errors/NotFoundException.kt | 6 +++++- .../org/onebusaway/errors/PermissionDeniedException.kt | 6 +++++- .../kotlin/org/onebusaway/errors/RateLimitException.kt | 6 +++++- .../kotlin/org/onebusaway/errors/UnauthorizedException.kt | 6 +++++- .../org/onebusaway/errors/UnexpectedStatusCodeException.kt | 7 ++++++- .../org/onebusaway/errors/UnprocessableEntityException.kt | 6 +++++- 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt index 2ed561f..c890a0e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt @@ -7,10 +7,14 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.JsonValue import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper class BadRequestException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OnebusawaySdkServiceException("400: $body", cause) { + OnebusawaySdkServiceException( + "400: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 400 diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt index feb6ec9..bcfc6e7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt @@ -7,6 +7,7 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.JsonValue import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper class InternalServerException private constructor( @@ -14,7 +15,11 @@ private constructor( private val headers: Headers, private val body: JsonValue, cause: Throwable?, -) : OnebusawaySdkServiceException("$statusCode: $body", cause) { +) : + OnebusawaySdkServiceException( + "$statusCode: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = statusCode diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt index d6aef12..6056958 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt @@ -7,10 +7,14 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.JsonValue import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper class NotFoundException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OnebusawaySdkServiceException("404: $body", cause) { + OnebusawaySdkServiceException( + "404: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 404 diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt index 28a3b5a..4fc127c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt @@ -7,10 +7,14 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.JsonValue import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper class PermissionDeniedException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OnebusawaySdkServiceException("403: $body", cause) { + OnebusawaySdkServiceException( + "403: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 403 diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt index 8e68c49..c2b481b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt @@ -7,10 +7,14 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.JsonValue import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper class RateLimitException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OnebusawaySdkServiceException("429: $body", cause) { + OnebusawaySdkServiceException( + "429: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 429 diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt index 79e2116..d347602 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt @@ -7,10 +7,14 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.JsonValue import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper class UnauthorizedException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OnebusawaySdkServiceException("401: $body", cause) { + OnebusawaySdkServiceException( + "401: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 401 diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt index f4aaa51..8183b81 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt @@ -7,6 +7,7 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.JsonValue import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper class UnexpectedStatusCodeException private constructor( @@ -14,7 +15,11 @@ private constructor( private val headers: Headers, private val body: JsonValue, cause: Throwable?, -) : OnebusawaySdkServiceException("$statusCode: $body", cause) { +) : + OnebusawaySdkServiceException( + "$statusCode: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = statusCode diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt index be66612..0c75ac2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt @@ -7,10 +7,14 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.JsonValue import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper class UnprocessableEntityException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OnebusawaySdkServiceException("422: $body", cause) { + OnebusawaySdkServiceException( + "422: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 422 From 88e7490658f71bbe6ae94b8727746b5f34722244 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 05:01:19 +0000 Subject: [PATCH 27/38] chore: remove duplicated dokka setup --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 22b120e..0b7dae3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,6 @@ subprojects { group = "Verification" description = "Verifies all source files are formatted." } - apply(plugin = "org.jetbrains.dokka") } subprojects { From 8157d7ecfa89ee3ccb179a57c2b8cd0665a1f5d1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 05:03:52 +0000 Subject: [PATCH 28/38] perf(client): create one json mapper --- .../src/main/kotlin/org/onebusaway/core/ObjectMappers.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt index ab3f530..f894da5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt @@ -29,7 +29,9 @@ import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField -fun jsonMapper(): JsonMapper = +fun jsonMapper(): JsonMapper = JSON_MAPPER + +private val JSON_MAPPER: JsonMapper = JsonMapper.builder() .addModule(kotlinModule()) .addModule(Jdk8Module()) From baeb731d323acdc19d58ec4a0134107203f45e18 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 15:24:57 +0000 Subject: [PATCH 29/38] feat(client): support proxy authentication --- README.md | 15 ++ .../onebusaway/client/okhttp/OkHttpClient.kt | 234 +++++++++++------- .../okhttp/OnebusawaySdkOkHttpClient.kt | 17 ++ .../okhttp/OnebusawaySdkOkHttpClientAsync.kt | 17 ++ .../core/http/ProxyAuthenticator.kt | 59 +++++ .../StopsForAgencyListResponse.kt | 14 +- 6 files changed, 264 insertions(+), 92 deletions(-) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/ProxyAuthenticator.kt diff --git a/README.md b/README.md index e9ae0b3..def4956 100644 --- a/README.md +++ b/README.md @@ -335,6 +335,21 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .build(); ``` +If the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; +import org.onebusaway.core.http.ProxyAuthenticator; + +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + .fromEnv() + .proxy(...) + // Or a custom implementation of `ProxyAuthenticator`. + .proxyAuthenticator(ProxyAuthenticator.basic("username", "password")) + .build(); +``` + ### Connection pooling To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt index 915d5da..fcae276 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt @@ -2,6 +2,7 @@ package org.onebusaway.client.okhttp import java.io.IOException import java.io.InputStream +import java.io.OutputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CancellationException @@ -11,10 +12,12 @@ import java.util.concurrent.TimeUnit import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull import okhttp3.Call import okhttp3.Callback import okhttp3.ConnectionPool import okhttp3.Dispatcher +import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.Interceptor import okhttp3.MediaType @@ -25,6 +28,8 @@ import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink +import okio.buffer +import okio.sink import org.onebusaway.core.RequestOptions import org.onebusaway.core.Timeout import org.onebusaway.core.http.Headers @@ -33,6 +38,7 @@ import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpRequestBody import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.ProxyAuthenticator import org.onebusaway.errors.OnebusawaySdkIoException class OkHttpClient @@ -42,7 +48,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie val call = newCall(request, requestOptions) return try { - call.execute().toResponse() + call.execute().toHttpResponse() } catch (e: IOException) { throw OnebusawaySdkIoException("Request failed", e) } finally { @@ -60,7 +66,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie call.enqueue( object : Callback { override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) + future.complete(response.toHttpResponse()) } override fun onFailure(call: Call, e: IOException) { @@ -113,89 +119,6 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie return client.newCall(request.toRequest(client)) } - private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { - var body: RequestBody? = body?.toRequestBody() - if (body == null && requiresBody(method)) { - body = "".toRequestBody() - } - - val builder = Request.Builder().url(toUrl()).method(method.name, body) - headers.names().forEach { name -> - headers.values(name).forEach { builder.addHeader(name, it) } - } - - if ( - !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 - ) { - builder.addHeader( - "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), - ) - } - if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { - builder.addHeader( - "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), - ) - } - - return builder.build() - } - - /** `OkHttpClient` always requires a request body for some methods. */ - private fun requiresBody(method: HttpMethod): Boolean = - when (method) { - HttpMethod.POST, - HttpMethod.PUT, - HttpMethod.PATCH -> true - else -> false - } - - private fun HttpRequest.toUrl(): String { - val builder = baseUrl.toHttpUrl().newBuilder() - pathSegments.forEach(builder::addPathSegment) - queryParams.keys().forEach { key -> - queryParams.values(key).forEach { builder.addQueryParameter(key, it) } - } - - return builder.toString() - } - - private fun HttpRequestBody.toRequestBody(): RequestBody { - val mediaType = contentType()?.toMediaType() - val length = contentLength() - - return object : RequestBody() { - override fun contentType(): MediaType? = mediaType - - override fun contentLength(): Long = length - - override fun isOneShot(): Boolean = !repeatable() - - override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) - } - } - - private fun Response.toResponse(): HttpResponse { - val headers = headers.toHeaders() - - return object : HttpResponse { - override fun statusCode(): Int = code - - override fun headers(): Headers = headers - - override fun body(): InputStream = body!!.byteStream() - - override fun close() = body!!.close() - } - } - - private fun okhttp3.Headers.toHeaders(): Headers { - val headersBuilder = Headers.builder() - forEach { (name, value) -> headersBuilder.put(name, value) } - return headersBuilder.build() - } - companion object { @JvmStatic fun builder() = Builder() } @@ -204,6 +127,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var dispatcherExecutorService: ExecutorService? = null @@ -217,6 +141,10 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + /** * Sets the maximum number of idle connections kept by the underlying [ConnectionPool]. * @@ -266,6 +194,19 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie .callTimeout(timeout.request()) .proxy(proxy) .apply { + proxyAuthenticator?.let { auth -> + proxyAuthenticator { route, response -> + auth + .authenticate( + route?.proxy ?: Proxy.NO_PROXY, + response.request.toHttpRequest(), + response.toHttpResponse(), + ) + .getOrNull() + ?.toRequest(client = null) + } + } + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } val maxIdleConnections = maxIdleConnections @@ -306,6 +247,129 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie } } +private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient?): Request { + var body: RequestBody? = body?.toRequestBody() + if (body == null && requiresBody(method)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.names().forEach { name -> headers.values(name).forEach { builder.addHeader(name, it) } } + + if (client != null) { + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.addHeader( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.addHeader( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + } + + return builder.build() +} + +/** `OkHttpClient` always requires a request body for some methods. */ +private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + +private fun HttpRequest.toUrl(): String { + val builder = baseUrl.toHttpUrl().newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } + + return builder.toString() +} + +private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? = mediaType + + override fun contentLength(): Long = length + + override fun isOneShot(): Boolean = !repeatable() + + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) + } +} + +private fun Request.toHttpRequest(): HttpRequest { + val builder = HttpRequest.builder().method(HttpMethod.valueOf(method)).baseUrl(url.toBaseUrl()) + url.pathSegments.forEach(builder::addPathSegment) + url.queryParameterNames.forEach { name -> + url.queryParameterValues(name).filterNotNull().forEach { builder.putQueryParam(name, it) } + } + headers.forEach { (name, value) -> builder.putHeader(name, value) } + body?.let { builder.body(it.toHttpRequestBody()) } + return builder.build() +} + +private fun HttpUrl.toBaseUrl(): String = buildString { + append(scheme).append("://").append(host) + if (port != HttpUrl.defaultPort(scheme)) { + append(":").append(port) + } +} + +private fun RequestBody.toHttpRequestBody(): HttpRequestBody { + val mediaType = contentType()?.toString() + val length = contentLength() + val isOneShot = isOneShot() + val source = this + return object : HttpRequestBody { + override fun contentType(): String? = mediaType + + override fun contentLength(): Long = length + + override fun repeatable(): Boolean = !isOneShot + + override fun writeTo(outputStream: OutputStream) { + val sink = outputStream.sink().buffer() + source.writeTo(sink) + sink.flush() + } + + override fun close() {} + } +} + +private fun Response.toHttpResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int = code + + override fun headers(): Headers = headers + + override fun body(): InputStream = body!!.byteStream() + + override fun close() = body!!.close() + } +} + +private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() +} + // --- ✅ New class added below --- class LoggingInterceptor : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt index f34b7ee..6788052 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt @@ -19,6 +19,7 @@ import org.onebusaway.core.Sleeper import org.onebusaway.core.Timeout import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient +import org.onebusaway.core.http.ProxyAuthenticator import org.onebusaway.core.http.QueryParams import org.onebusaway.core.jsonMapper @@ -47,6 +48,7 @@ class OnebusawaySdkOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null @@ -77,6 +79,20 @@ class OnebusawaySdkOkHttpClient private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication + * Required`. + */ + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`. + */ + fun proxyAuthenticator(proxyAuthenticator: Optional) = + proxyAuthenticator(proxyAuthenticator.getOrNull()) + /** * The maximum number of idle connections kept by the underlying OkHttp connection pool. * @@ -362,6 +378,7 @@ class OnebusawaySdkOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .proxyAuthenticator(proxyAuthenticator) .maxIdleConnections(maxIdleConnections) .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt index 9749e4b..a4c5415 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt @@ -19,6 +19,7 @@ import org.onebusaway.core.Sleeper import org.onebusaway.core.Timeout import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient +import org.onebusaway.core.http.ProxyAuthenticator import org.onebusaway.core.http.QueryParams import org.onebusaway.core.jsonMapper @@ -47,6 +48,7 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null @@ -77,6 +79,20 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication + * Required`. + */ + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`. + */ + fun proxyAuthenticator(proxyAuthenticator: Optional) = + proxyAuthenticator(proxyAuthenticator.getOrNull()) + /** * The maximum number of idle connections kept by the underlying OkHttp connection pool. * @@ -362,6 +378,7 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .proxyAuthenticator(proxyAuthenticator) .maxIdleConnections(maxIdleConnections) .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/ProxyAuthenticator.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/ProxyAuthenticator.kt new file mode 100644 index 0000000..a6559e9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/ProxyAuthenticator.kt @@ -0,0 +1,59 @@ +package org.onebusaway.core.http + +import java.net.Proxy +import java.nio.charset.Charset +import java.nio.charset.StandardCharsets +import java.util.Base64 +import java.util.Optional + +/** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication Required`. + * + * Implementations inspect the 407 [response] (typically its `Proxy-Authenticate` header) and return + * the request to retry with a `Proxy-Authorization` header set, or [Optional.empty] to abandon + * authentication and surface the 407 to the caller. + * + * Implementations must be thread-safe; they may be invoked concurrently from multiple HTTP calls. + */ +fun interface ProxyAuthenticator { + + /** + * @param proxy the proxy that produced the challenge, or [Proxy.NO_PROXY] if the route is not + * yet established + * @param request the request that produced [response] + * @param response the 407 challenge response + * @return the retry request to send (typically [request] with a `Proxy-Authorization` header + * added), or [Optional.empty] to abandon authentication + */ + fun authenticate( + proxy: Proxy, + request: HttpRequest, + response: HttpResponse, + ): Optional + + companion object { + + /** + * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the ISO-8859-1 + * charset. + */ + @JvmStatic + fun basic(username: String, password: String): ProxyAuthenticator = + basic(username, password, StandardCharsets.ISO_8859_1) + + /** + * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the given [charset]. + */ + @JvmStatic + fun basic(username: String, password: String, charset: Charset): ProxyAuthenticator { + val token = + Base64.getEncoder().encodeToString("$username:$password".toByteArray(charset)) + val headerValue = "Basic $token" + return ProxyAuthenticator { _, request, _ -> + Optional.of( + request.toBuilder().putHeader("Proxy-Authorization", headerValue).build() + ) + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt index b60f3a4..34efc3c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt @@ -309,7 +309,7 @@ private constructor( class Data @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val list: JsonField>, + private val list: JsonField>, private val references: JsonField, private val limitExceeded: JsonField, private val outOfRange: JsonField, @@ -318,7 +318,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), + @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), @@ -334,7 +334,7 @@ private constructor( * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun list(): List = list.getRequired("list") + fun list(): kotlin.collections.List = list.getRequired("list") /** * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is @@ -359,7 +359,7 @@ private constructor( * * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list + @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list /** * Returns the raw JSON value of [references]. @@ -433,16 +433,16 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } - fun list(list: List) = list(JsonField.of(list)) + fun list(list: kotlin.collections.List) = list(JsonField.of(list)) /** * Sets [Builder.list] to an arbitrary JSON value. * - * You should usually call [Builder.list] with a well-typed `List` value instead. + * You should usually call [Builder.list] with a well-typed `kotlin.collections.List` value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun list(list: JsonField>) = apply { + fun list(list: JsonField>) = apply { this.list = list.map { it.toMutableList() } } From 80d4a74241fa268e03504f2fc565df666da77400 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:06:13 +0000 Subject: [PATCH 30/38] feat(client): improve logging Logging is now: 1. Streaming 4. Configurable in-memory 5. Generally more robust 6. Usable with any underlying http client --- README.md | 15 +- .../build.gradle.kts | 1 - .../onebusaway/client/okhttp/OkHttpClient.kt | 12 - .../okhttp/OnebusawaySdkOkHttpClient.kt | 10 + .../okhttp/OnebusawaySdkOkHttpClientAsync.kt | 10 + .../org/onebusaway/core/ClientOptions.kt | 30 +- .../kotlin/org/onebusaway/core/LogLevel.kt | 33 + .../main/kotlin/org/onebusaway/core/Utils.kt | 6 + .../onebusaway/core/http/LoggingHttpClient.kt | 627 +++++++++++ .../core/http/LoggingHttpClientTest.kt | 999 ++++++++++++++++++ 10 files changed, 1727 insertions(+), 16 deletions(-) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/LogLevel.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/LoggingHttpClient.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/LoggingHttpClientTest.kt diff --git a/README.md b/README.md index def4956..1ea5fe7 100644 --- a/README.md +++ b/README.md @@ -229,8 +229,6 @@ The SDK throws custom unchecked exception types: ## Logging -The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). - Enable logging by setting the `ONEBUSAWAY_SDK_LOG` environment variable to `info`: ```sh @@ -243,6 +241,19 @@ Or to `debug` for more verbose logging: export ONEBUSAWAY_SDK_LOG=debug ``` +Or configure the client manually using the `logLevel` method: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; +import org.onebusaway.core.LogLevel; + +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + .fromEnv() + .logLevel(LogLevel.INFO) + .build(); +``` + ## ProGuard and R8 Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `onebusaway-sdk-java-core` is published with a [configuration file](onebusaway-sdk-java-core/src/main/resources/META-INF/proguard/onebusaway-sdk-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). diff --git a/onebusaway-sdk-java-client-okhttp/build.gradle.kts b/onebusaway-sdk-java-client-okhttp/build.gradle.kts index f77000f..b093235 100644 --- a/onebusaway-sdk-java-client-okhttp/build.gradle.kts +++ b/onebusaway-sdk-java-client-okhttp/build.gradle.kts @@ -7,7 +7,6 @@ dependencies { api(project(":onebusaway-sdk-java-core")) implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.27.7") diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt index fcae276..7a96a57 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt @@ -26,7 +26,6 @@ import okhttp3.Request import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response -import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink import okio.buffer import okio.sink @@ -96,17 +95,6 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie // Custom logging interceptor for URL logging clientBuilder.addNetworkInterceptor(LoggingInterceptor()) - - val logLevel = - when (System.getenv("ONEBUSAWAY_SDK_LOG")?.lowercase()) { - "info" -> HttpLoggingInterceptor.Level.BASIC - "debug" -> HttpLoggingInterceptor.Level.BODY - else -> null - } - if (logLevel != null) { - clientBuilder.addNetworkInterceptor(HttpLoggingInterceptor().setLevel(logLevel)) - } - requestOptions.timeout?.let { clientBuilder .connectTimeout(it.connect()) diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt index 6788052..8054ed9 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt @@ -15,6 +15,7 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.OnebusawaySdkClientImpl import org.onebusaway.core.ClientOptions +import org.onebusaway.core.LogLevel import org.onebusaway.core.Sleeper import org.onebusaway.core.Timeout import org.onebusaway.core.http.Headers @@ -277,6 +278,15 @@ class OnebusawaySdkOkHttpClient private constructor() { */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { clientOptions.logLevel(logLevel) } + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } fun headers(headers: Headers) = apply { clientOptions.headers(headers) } diff --git a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt index a4c5415..21d8fed 100644 --- a/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt @@ -15,6 +15,7 @@ import kotlin.jvm.optionals.getOrNull import org.onebusaway.client.OnebusawaySdkClientAsync import org.onebusaway.client.OnebusawaySdkClientAsyncImpl import org.onebusaway.core.ClientOptions +import org.onebusaway.core.LogLevel import org.onebusaway.core.Sleeper import org.onebusaway.core.Timeout import org.onebusaway.core.http.Headers @@ -277,6 +278,15 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { clientOptions.logLevel(logLevel) } + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } fun headers(headers: Headers) = apply { clientOptions.headers(headers) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt index 817495e..10331bb 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt @@ -9,6 +9,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient +import org.onebusaway.core.http.LoggingHttpClient import org.onebusaway.core.http.PhantomReachableClosingHttpClient import org.onebusaway.core.http.QueryParams import org.onebusaway.core.http.RetryingHttpClient @@ -96,6 +97,14 @@ private constructor( * Defaults to 2. */ @get:JvmName("maxRetries") val maxRetries: Int, + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + @get:JvmName("logLevel") val logLevel: LogLevel, @get:JvmName("apiKey") val apiKey: String, ) { @@ -151,6 +160,7 @@ private constructor( private var responseValidation: Boolean = false private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 + private var logLevel: LogLevel = LogLevel.fromEnv() private var apiKey: String? = null @JvmSynthetic @@ -166,6 +176,7 @@ private constructor( responseValidation = clientOptions.responseValidation timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries + logLevel = clientOptions.logLevel apiKey = clientOptions.apiKey } @@ -276,6 +287,15 @@ private constructor( */ fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { this.logLevel = logLevel } + fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } fun headers(headers: Headers) = apply { @@ -373,6 +393,7 @@ private constructor( * System properties take precedence over environment variables. */ fun fromEnv() = apply { + logLevel(LogLevel.fromEnv()) (System.getProperty("onebusawaysdk.baseUrl") ?: System.getenv("ONEBUSAWAY_SDK_BASE_URL")) ?.let { baseUrl(it) } @@ -429,7 +450,13 @@ private constructor( return ClientOptions( httpClient, RetryingHttpClient.builder() - .httpClient(httpClient) + .httpClient( + LoggingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .level(logLevel) + .build() + ) .sleeper(sleeper) .clock(clock) .maxRetries(maxRetries) @@ -444,6 +471,7 @@ private constructor( responseValidation, timeout, maxRetries, + logLevel, apiKey, ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/LogLevel.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/LogLevel.kt new file mode 100644 index 0000000..252dea3 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/LogLevel.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core + +/** The level at which to log request and response information. */ +enum class LogLevel { + /** No logging. */ + OFF, + /** Minimal request and response summary logs. No headers or bodies are logged. */ + INFO, + /** [INFO] logs plus details about request failures. */ + ERROR, + /** + * Full request and response logs. Sensitive headers are redacted, but sensitive data in request + * and response bodies may still be visible. + */ + DEBUG; + + /** Returns whether this level is at or higher than the given [level]. */ + fun shouldLog(level: LogLevel): Boolean = ordinal >= level.ordinal + + companion object { + + /** Returns a [LogLevel] based on the `ONEBUSAWAY_SDK_LOG` environment variable. */ + fun fromEnv() = + when (System.getenv("ONEBUSAWAY_SDK_LOG")?.lowercase()) { + "info" -> INFO + "error" -> ERROR + "debug" -> DEBUG + else -> OFF + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt index 36f3a92..5bf70b1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt @@ -4,6 +4,7 @@ package org.onebusaway.core import java.util.Collections import java.util.SortedMap +import java.util.SortedSet import java.util.concurrent.CompletableFuture import java.util.concurrent.locks.Lock import org.onebusaway.errors.OnebusawaySdkInvalidDataException @@ -16,6 +17,11 @@ internal fun T?.getOrThrow(name: String): T = internal fun List.toImmutable(): List = if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) +@JvmSynthetic +internal fun > SortedSet.toImmutable(): SortedSet = + if (isEmpty()) Collections.emptySortedSet() + else Collections.unmodifiableSortedSet(toSortedSet(comparator() ?: Comparator.naturalOrder())) + @JvmSynthetic internal fun Map.toImmutable(): Map = if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/LoggingHttpClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/LoggingHttpClient.kt new file mode 100644 index 0000000..f1079f0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/LoggingHttpClient.kt @@ -0,0 +1,627 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core.http + +import java.io.ByteArrayOutputStream +import java.io.InputStream +import java.io.OutputStream +import java.nio.ByteBuffer +import java.nio.charset.CharacterCodingException +import java.nio.charset.Charset +import java.nio.charset.CharsetDecoder +import java.nio.charset.CodingErrorAction +import java.nio.charset.StandardCharsets +import java.time.Clock +import java.time.Duration +import java.time.OffsetDateTime +import java.util.SortedSet +import java.util.concurrent.CompletableFuture +import java.util.concurrent.CompletionException +import kotlin.time.toKotlinDuration +import org.onebusaway.core.LogLevel +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable + +/** A wrapper [HttpClient] around [httpClient] that logs request and response information. */ +class LoggingHttpClient +private constructor( + /** The underlying [HttpClient] for making requests. */ + @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * Sensitive headers to redact from logs. + * + * Defaults to `Set.of()`. + */ + @get:JvmName("redactedHeaders") val redactedHeaders: SortedSet, + /** + * The clock to use for measuring request and response durations. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + @get:JvmName("clock") val clock: Clock, + /** + * The log level to use. + * + * Pass [LogLevel.fromEnv] to read from environment variables. + */ + @get:JvmName("level") val level: LogLevel, +) : HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val loggingRequest = logRequest(request) + + val before = OffsetDateTime.now(clock) + val response = + try { + httpClient.execute(loggingRequest, requestOptions) + } catch (e: Throwable) { + logFailure(e, Duration.between(before, OffsetDateTime.now(clock))) + throw e + } + + val took = Duration.between(before, OffsetDateTime.now(clock)) + return logResponse(response, took) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val loggingRequest = logRequest(request) + + val before = OffsetDateTime.now(clock) + val future = + try { + httpClient.executeAsync(loggingRequest, requestOptions) + } catch (e: Throwable) { + logFailure(e, Duration.between(before, OffsetDateTime.now(clock))) + throw e + } + return future.handle { response, error -> + val took = Duration.between(before, OffsetDateTime.now(clock)) + if (error != null) { + logFailure(unwrapCompletionException(error), took) + throw error + } + logResponse(response, took) + } + } + + private fun logRequest(request: HttpRequest): HttpRequest { + if (!level.shouldLog(LogLevel.INFO)) { + return request + } + + System.err.println( + buildString { + append("--> ${request.method} ${request.url()}") + request.body?.let { + val length = it.contentLength() + append(if (length >= 0) " ($length-byte body)" else " (unknown-length body)") + } + } + ) + + if (!level.shouldLog(LogLevel.DEBUG)) { + return request + } + + logHeaders(request.headers) + + if (request.body == null) { + System.err.println("--> END ${request.method}") + System.err.println() + return request + } + + return request + .toBuilder() + .body(LoggingHttpRequestBody(request.method, request.body)) + .build() + } + + private fun logResponse(response: HttpResponse, took: Duration): HttpResponse { + if (!level.shouldLog(LogLevel.INFO)) { + return response + } + + val contentLength = response.headers().values("Content-Length").firstOrNull()?.toIntOrNull() + System.err.println( + "<-- ${response.statusCode()} (${ + buildString { + append(took.format()) + contentLength?.let { append(", $contentLength-byte body") } + } + })" + ) + + if (!level.shouldLog(LogLevel.DEBUG)) { + return response + } + + logHeaders(response.headers()) + return LoggingHttpResponse(response) + } + + private fun logFailure(error: Throwable, took: Duration) { + if (!level.shouldLog(LogLevel.ERROR)) { + return + } + + System.err.println( + buildString { + append("<-- !! ${error.javaClass.simpleName}") + error.message?.let { append(": $it") } + append(" (${took.format()})") + } + ) + } + + private fun unwrapCompletionException(error: Throwable): Throwable = + if (error is CompletionException && error.cause != null) error.cause!! else error + + private fun logHeaders(headers: Headers) = + headers.names().forEach { name -> + headers.values(name).forEach { value -> + System.err.println("$name: ${if (redactedHeaders.contains(name)) "██" else value}") + } + } + + override fun close() = httpClient.close() + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LoggingHttpClient]. + * + * The following fields are required: + * ```java + * .httpClient() + * .level() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LoggingHttpClient]. */ + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var redactedHeaders: Set = setOf() + private var clock: Clock = Clock.systemUTC() + private var level: LogLevel? = null + + @JvmSynthetic + internal fun from(loggingHttpClient: LoggingHttpClient) = apply { + httpClient = loggingHttpClient.httpClient + redactedHeaders = loggingHttpClient.redactedHeaders + clock = loggingHttpClient.clock + level = loggingHttpClient.level + } + + /** The underlying [HttpClient] for making requests. */ + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + /** + * Sensitive headers to redact from logs. + * + * Defaults to `Set.of()`. + */ + fun redactedHeaders(redactedHeaders: Set) = apply { + this.redactedHeaders = redactedHeaders + } + + /** + * The clock to use for measuring request and response durations. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { this.clock = clock } + + /** + * The log level to use. + * + * Pass [LogLevel.fromEnv] to read from environment variables. + */ + fun level(level: LogLevel) = apply { this.level = level } + + /** + * Returns an immutable instance of [LoggingHttpClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * .level() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LoggingHttpClient = + LoggingHttpClient( + checkRequired("httpClient", httpClient), + redactedHeaders.toSortedSet(String.CASE_INSENSITIVE_ORDER).toImmutable(), + clock, + checkRequired("level", level), + ) + } +} + +/** + * An [HttpRequestBody] wrapper that delegates to [body] while also logging line by line as it's + * written. + * + * The logging occurs in a streaming manner with minimal buffering. + */ +private class LoggingHttpRequestBody( + private val method: HttpMethod, + private val body: HttpRequestBody, +) : HttpRequestBody { + + private val charset by lazy { parseCharset(body.contentType()) } + + override fun writeTo(outputStream: OutputStream) { + val loggingOutputStream = LoggingOutputStream(outputStream, charset) + body.writeTo(loggingOutputStream) + + loggingOutputStream.flush() + System.err.println("--> END $method (${loggingOutputStream.writeCount()}-byte body)") + System.err.println() + } + + override fun contentType(): String? = body.contentType() + + override fun contentLength(): Long = body.contentLength() + + override fun repeatable(): Boolean = body.repeatable() + + override fun close() = body.close() +} + +/** + * An [OutputStream] wrapper that delegates to [outputStream] while also logging bytes line by line + * as it's written to. + * + * The written content is assumed to be in the given [charset] and the logging occurs in a streaming + * manner with minimal buffering. + */ +private class LoggingOutputStream(private val outputStream: OutputStream, charset: Charset?) : + OutputStream() { + + private val buffer = LoggingBuffer(charset) + + fun writeCount() = buffer.writeCount() + + override fun write(b: Int) { + outputStream.write(b) + buffer.write(b) + } + + override fun write(b: ByteArray, off: Int, len: Int) { + outputStream.write(b, off, len) + for (i in off until off + len) { + buffer.write(b[i].toInt() and 0xFF) + } + } + + /** Prints any currently buffered content. */ + override fun flush() { + buffer.flush() + outputStream.flush() + } + + override fun close() = outputStream.close() +} + +/** + * An [HttpResponse] wrapper that delegates to [response] while also logging line-by-line as it's + * read. + * + * The logging occurs in a streaming manner with minimal buffering. + */ +private class LoggingHttpResponse(private val response: HttpResponse) : HttpResponse { + + private val loggingBody: Lazy = lazy { + LoggingInputStream( + response.body(), + parseCharset(response.headers().values("Content-Type").firstOrNull()), + ) + } + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = loggingBody.value + + override fun close() { + if (loggingBody.isInitialized()) { + loggingBody.value.close() + } + response.close() + } +} + +/** + * An [InputStream] wrapper that delegates to [inputStream] while also logging bytes line by line as + * it's read. + * + * The contents of [inputStream] are assumed to be in the given [charset] and the logging occurs in + * a streaming manner with minimal buffering. + */ +private class LoggingInputStream(private val inputStream: InputStream, charset: Charset?) : + InputStream() { + + private var isDone = false + private val buffer = LoggingBuffer(charset) + + override fun read(): Int { + if (isDone) { + return -1 + } + + val b = inputStream.read() + + if (b == -1) { + markDone() + return b + } + + buffer.write(b) + return b + } + + override fun read(b: ByteArray, off: Int, len: Int): Int { + if (isDone) { + return -1 + } + + val bytesRead = inputStream.read(b, off, len) + + if (bytesRead == -1) { + markDone() + return bytesRead + } + + for (i in off until off + bytesRead) { + buffer.write(b[i].toInt() and 0xFF) + } + return bytesRead + } + + override fun close() { + if (!isDone) { + markDone(closedEarly = true) + } + inputStream.close() + } + + private fun markDone(closedEarly: Boolean = false) { + isDone = true + buffer.flush() + val suffix = if (closedEarly) ", closed early" else "" + System.err.println("<-- END HTTP (${buffer.writeCount()}-byte body$suffix)") + System.err.println() + } +} + +/** + * A byte buffer that prints line by line, using the given [charset], as bytes are written to it. + * + * When [charset] is `null`, the buffer performs an upfront check to detect binary content. If + * non-whitespace ISO control characters are found in the first [PROBABLY_UTF8_CODE_POINT_LIMIT] + * code points, body logging is suppressed entirely. + */ +private class LoggingBuffer(charset: Charset?) { + + private val charset = charset ?: StandardCharsets.UTF_8 + + private val decoder: CharsetDecoder = + this.charset + .newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT) + private var writeCount = 0 + private val buffer = ByteArrayOutputStream(128) + + /** + * Whether logging has been suppressed because the content doesn't appear to be readable text. + * + * This is only set when [charset] is `null` and the content fails the [isProbablyUtf8] check. + */ + private var suppressed = false + + /** + * Bytes accumulated for the [isProbablyUtf8] check before any lines are printed. + * + * Once the check passes (or [charset] is non-null), this is set to `null` and bytes flow + * directly to [buffer]. + */ + private var prefetchBuffer: ByteArrayOutputStream? = + if (charset != null) null else ByteArrayOutputStream(128) + + fun writeCount() = writeCount + + fun write(b: Int) { + if (writeCount == 0) { + // Print a newline before we start printing anything to separate the printed content + // from previous content. + System.err.println() + } + + writeCount++ + + if (suppressed) { + return + } + + val prefetch = prefetchBuffer + if (prefetch != null) { + prefetch.write(b) + // Continue accumulating until we have enough bytes to decide. + if (prefetch.size() < PROBABLY_UTF8_BYTE_LIMIT && b != '\n'.code) { + return + } + // We have enough bytes. Check if the content is probably UTF-8. + prefetchBuffer = null + val bytes = prefetch.toByteArray() + if (!isProbablyUtf8(bytes)) { + suppressed = true + System.err.println("(binary body omitted)") + return + } + // Content looks like UTF-8. Feed the accumulated bytes into the normal buffer. + for (byte in bytes) { + writeToBuffer(byte.toInt() and 0xFF) + } + return + } + + writeToBuffer(b) + } + + private fun writeToBuffer(b: Int) { + if (b == '\n'.code) { + flush() + return + } + + buffer.write(b) + } + + /** Prints any currently buffered content. */ + fun flush() { + if (suppressed) { + return + } + + // If we still have a prefetch buffer when flush is called (body was shorter than the + // limit), run the check now. + val prefetch = prefetchBuffer + if (prefetch != null) { + prefetchBuffer = null + val bytes = prefetch.toByteArray() + if (bytes.isEmpty()) { + return + } + if (!isProbablyUtf8(bytes)) { + suppressed = true + System.err.println("(binary body omitted)") + return + } + for (byte in bytes) { + writeToBuffer(byte.toInt() and 0xFF) + } + } + + if (buffer.size() == 0) { + return + } + + val line = + try { + decoder.decode(ByteBuffer.wrap(buffer.toByteArray())) + } catch (e: CharacterCodingException) { + "(omitted line is not valid $charset)" + } + buffer.reset() + System.err.println(line) + } +} + +/** The maximum number of code points to sample when checking if content is probably UTF-8. */ +private const val PROBABLY_UTF8_CODE_POINT_LIMIT = 64 + +/** + * The maximum number of bytes to accumulate before running the [isProbablyUtf8] check. UTF-8 code + * points are at most 4 bytes, so this accommodates [PROBABLY_UTF8_CODE_POINT_LIMIT] code points. + */ +private const val PROBABLY_UTF8_BYTE_LIMIT = PROBABLY_UTF8_CODE_POINT_LIMIT * 4 + +/** + * Returns `true` if the given [bytes] probably contain human-readable UTF-8 text. + * + * Decodes up to [PROBABLY_UTF8_CODE_POINT_LIMIT] code points and returns `false` if any + * non-whitespace ISO control characters are found, or if the bytes are not valid UTF-8. + */ +private fun isProbablyUtf8(bytes: ByteArray): Boolean { + try { + val decoder = + StandardCharsets.UTF_8.newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT) + val charBuffer = decoder.decode(ByteBuffer.wrap(bytes)) + var codePointCount = 0 + var i = 0 + while (i < charBuffer.length && codePointCount < PROBABLY_UTF8_CODE_POINT_LIMIT) { + val codePoint = Character.codePointAt(charBuffer, i) + if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) { + return false + } + i += Character.charCount(codePoint) + codePointCount++ + } + return true + } catch (e: CharacterCodingException) { + return false + } +} + +/** Returns the [Charset] in the given [contentType] string, or `null` if unspecified. */ +private fun parseCharset(contentType: String?): Charset? = + contentType + ?.split(";") + ?.drop(1) + ?.map { it.trim() } + ?.firstOrNull { it.startsWith("charset=", ignoreCase = true) } + ?.substringAfter("=") + ?.trim() + ?.removeSurrounding("\"") + ?.let { runCatching { charset(it) }.getOrNull() } + +/** Formats the [Duration] into a string like "1m 40s 467ms". */ +private fun Duration.format(): String = + toKotlinDuration().toComponents { days, hours, minutes, seconds, nanoseconds -> + buildString { + val milliseconds = nanoseconds / 1_000_000 + if (days > 0) { + append("${days}d") + } + if (hours > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${hours}h") + } + if (minutes > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${minutes}m") + } + if (seconds > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${seconds}s") + } + if (milliseconds > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${milliseconds}ms") + } + + if (isEmpty()) { + append("0s") + } + } + } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/LoggingHttpClientTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/LoggingHttpClientTest.kt new file mode 100644 index 0000000..0498a77 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/LoggingHttpClientTest.kt @@ -0,0 +1,999 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core.http + +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.IOException +import java.io.InputStream +import java.io.OutputStream +import java.io.PrintStream +import java.nio.charset.StandardCharsets +import java.time.Clock +import java.time.Instant +import java.time.ZoneOffset +import java.util.concurrent.CompletableFuture +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource +import org.onebusaway.core.LogLevel +import org.onebusaway.core.RequestOptions + +@ResourceLock("stderr") +internal class LoggingHttpClientTest { + + private lateinit var originalErr: PrintStream + private lateinit var errContent: ByteArrayOutputStream + + @BeforeEach + fun beforeEach() { + originalErr = System.err + errContent = ByteArrayOutputStream() + System.setErr(PrintStream(errContent)) + } + + @AfterEach + fun afterEach() { + System.setErr(originalErr) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun offLevel_noOutput(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.OFF) + + val response = client.execute(simpleGetRequest(), async).apply { body().readBytes() } + + assertThat(response.statusCode()).isEqualTo(200) + assertThat(stderrOutput()).isEmpty() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsGetRequest(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.INFO) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 200 (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsPostRequestWithBodySize(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.INFO) + + client.execute(postRequestWithBody("""{"key":"value"}"""), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> POST https://api.example.com/v1/resources (15-byte body) + |<-- 200 (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsRequestWithUnknownLengthBody(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.INFO) + + client + .execute(postRequestWithBody("""{"key":"value"}""", contentLength = -1L), async) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> POST https://api.example.com/v1/resources (unknown-length body) + |<-- 200 (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsResponseStatusAndDuration(async: Boolean) { + val clock = + clockFrom( + Instant.parse("1998-04-21T00:00:00Z"), + Instant.parse("1998-04-21T00:00:01.234Z"), + ) + val client = loggingClient(fakeHttpClient(statusCode = 201), LogLevel.INFO, clock) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 201 (1s 234ms) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsResponseContentLength(async: Boolean) { + val headers = + Headers.builder().put("Content-Length", "42").put("Content-Type", "text/plain").build() + val client = loggingClient(fakeHttpClient(responseHeaders = headers), LogLevel.INFO) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 200 (0s, 42-byte body) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_doesNotLogHeaders(async: Boolean) { + val headers = Headers.builder().put("X-Custom", "visible").build() + val client = loggingClient(fakeHttpClient(responseHeaders = headers), LogLevel.INFO) + + client + .execute( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("v1") + .putHeader("X-Request-Custom", "req-value") + .build(), + async, + ) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1 + |<-- 200 (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsGetWithEndMarker(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.DEBUG) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsRequestAndResponseHeaders(async: Boolean) { + val responseHeaders = + Headers.builder() + .put("X-Response-Id", "abc-123") + .put("Content-Type", "text/plain") + .build() + val client = + loggingClient(fakeHttpClient(responseHeaders = responseHeaders), LogLevel.DEBUG) + + client + .execute( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("test") + .putHeader("X-Custom", "my-value") + .build(), + async, + ) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/test + |X-Custom: my-value + |--> END GET + | + |<-- 200 (0s) + |Content-Type: text/plain + |X-Response-Id: abc-123 + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_redactsSensitiveHeaders(async: Boolean) { + val client = + loggingClient( + fakeHttpClient(), + LogLevel.DEBUG, + redactedHeaders = setOf("Authorization", "X-Secret"), + ) + + client + .execute( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("test") + .putHeader("Authorization", "Bearer token-123") + .putHeader("X-Secret", "secret-value") + .putHeader("X-Public", "public-value") + .build(), + async, + ) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/test + |Authorization: ██ + |X-Public: public-value + |X-Secret: ██ + |--> END GET + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_redactsHeadersCaseInsensitively(async: Boolean) { + val client = + loggingClient( + fakeHttpClient(), + LogLevel.DEBUG, + redactedHeaders = setOf("Authorization"), + ) + + client + .execute( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("test") + .putHeader("authorization", "Bearer secret") + .build(), + async, + ) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/test + |authorization: ██ + |--> END GET + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsRequestBody(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.DEBUG) + val body = """{"name":"test","value":42}""" + + client.execute(postRequestWithBody(body), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> POST https://api.example.com/v1/resources (26-byte body) + | + |{"name":"test","value":42} + |--> END POST (26-byte body) + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsResponseBody(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + val response = client.execute(simpleGetRequest(), async) + val body = response.body().readBytes().toString(StandardCharsets.UTF_8) + + assertThat(body).isEqualTo(responseBody) + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + | + |{"id":1,"status":"ok"} + |<-- END HTTP (22-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsBinaryResponseBodyAsOmitted(async: Boolean) { + val binaryBody = ByteArray(256) { it.toByte() } + val client = loggingClient(fakeHttpClient(responseBody = binaryBody), LogLevel.DEBUG) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + | + |(binary body omitted) + |<-- END HTTP (256-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsMultilineResponseBody(async: Boolean) { + val multilineBody = "line1\nline2\nline3" + val headers = Headers.builder().put("Content-Type", "text/plain; charset=utf-8").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = multilineBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: text/plain; charset=utf-8 + | + |line1 + |line2 + |line3 + |<-- END HTTP (17-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsResponseBodyWithExplicitCharset(async: Boolean) { + val responseBody = "héllo wörld" + val headers = Headers.builder().put("Content-Type", "text/plain; charset=utf-8").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: text/plain; charset=utf-8 + | + |héllo wörld + |<-- END HTTP (13-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsResponseBodyWithNoContentType(async: Boolean) { + val responseBody = "plain text body" + val client = + loggingClient( + fakeHttpClient(responseBody = responseBody.toByteArray(StandardCharsets.UTF_8)), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + | + |plain text body + |<-- END HTTP (15-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsEmptyResponseBody(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.DEBUG) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsEndHttpMarkerOnEarlyClose(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + val body = client.execute(simpleGetRequest(), async).body() + body.read(ByteArray(5)) + body.close() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + | + |{"id" + |<-- END HTTP (5-byte body, closed early) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsEndHttpMarkerOnCloseWithoutReading(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).body().close() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + |<-- END HTTP (0-byte body, closed early) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsEndHttpMarkerWhenResponseClosedAfterPartialRead(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + val response = client.execute(simpleGetRequest(), async) + response.body().read(ByteArray(5)) + response.close() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + | + |{"id" + |<-- END HTTP (5-byte body, closed early) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_doesNotLogEndHttpMarkerWhenResponseClosedWithoutBodyAccess(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).close() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun errorLevel_logsRequestFailure(async: Boolean) { + val clock = + clockFrom( + Instant.parse("1998-04-21T00:00:00Z"), + Instant.parse("1998-04-21T00:00:01.234Z"), + ) + val client = + loggingClient( + failingHttpClient(IOException("Connection refused")), + LogLevel.ERROR, + clock, + ) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- !! IOException: Connection refused (1s 234ms) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_doesNotLogRequestFailure(async: Boolean) { + val client = + loggingClient(failingHttpClient(IOException("Connection refused")), LogLevel.INFO) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsRequestFailureAfterHeaders(async: Boolean) { + val client = + loggingClient(failingHttpClient(IOException("Connection refused")), LogLevel.DEBUG) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- !! IOException: Connection refused (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun errorLevel_logsRequestFailureWithoutMessage(async: Boolean) { + val client = loggingClient(failingHttpClient(IOException()), LogLevel.ERROR) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- !! IOException (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun offLevel_doesNotLogRequestFailure(async: Boolean) { + val client = + loggingClient(failingHttpClient(IOException("Connection refused")), LogLevel.OFF) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()).isEmpty() + } + + @Test + fun errorLevel_logsExecuteAsyncSynchronousThrow() { + val error = IOException("Connection refused") + val client = + loggingClient( + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = throw UnsupportedOperationException() + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = throw error + + override fun close() {} + }, + LogLevel.ERROR, + ) + + assertThatThrownBy { client.execute(simpleGetRequest(), async = true) }.isSameAs(error) + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- !! IOException: Connection refused (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun durationFormat_seconds(async: Boolean) { + val clock = + clockFrom( + Instant.parse("1998-04-21T00:00:00Z"), + Instant.parse("1998-04-21T00:00:02.500Z"), + ) + val client = loggingClient(fakeHttpClient(), LogLevel.INFO, clock) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 200 (2s 500ms) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun durationFormat_minutesAndSeconds(async: Boolean) { + val clock = + clockFrom( + Instant.parse("1998-04-21T00:00:00Z"), + Instant.parse("1998-04-21T00:01:40.467Z"), + ) + val client = loggingClient(fakeHttpClient(), LogLevel.INFO, clock) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 200 (1m 40s 467ms) + |""" + .trimMargin() + ) + } + + @Test + fun builder_toBuilder_roundtrips() { + val delegate = fakeHttpClient() + val clock = Clock.fixed(Instant.parse("1998-04-21T00:00:00Z"), ZoneOffset.UTC) + val client = + LoggingHttpClient.builder() + .httpClient(delegate) + .level(LogLevel.DEBUG) + .redactedHeaders(setOf("X-Secret")) + .clock(clock) + .build() + + val rebuilt = client.toBuilder().build() + + assertThat(rebuilt.httpClient).isSameAs(delegate) + assertThat(rebuilt.level).isEqualTo(LogLevel.DEBUG) + assertThat(rebuilt.redactedHeaders).containsExactly("X-Secret") + assertThat(rebuilt.clock).isEqualTo(clock) + } + + @Test + fun close_delegatesToUnderlyingClient() { + var closed = false + val delegate = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = throw UnsupportedOperationException() + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = throw UnsupportedOperationException() + + override fun close() { + closed = true + } + } + val client = loggingClient(delegate, LogLevel.OFF) + + client.close() + + assertThat(closed).isTrue() + } + + private fun stderrOutput(): String = errContent.toString("UTF-8") + + private fun loggingClient( + httpClient: HttpClient, + level: LogLevel, + clock: Clock = clockFrom(Instant.parse("1998-04-21T00:00:00Z")), + redactedHeaders: Set = setOf(), + ): LoggingHttpClient = + LoggingHttpClient.builder() + .httpClient(httpClient) + .level(level) + .clock(clock) + .redactedHeaders(redactedHeaders) + .build() + + private fun simpleGetRequest(): HttpRequest = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("v1") + .addPathSegment("resources") + .build() + + private fun postRequestWithBody( + body: String, + contentType: String = "application/json", + contentLength: Long? = null, + ): HttpRequest = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl("https://api.example.com") + .addPathSegment("v1") + .addPathSegment("resources") + .body( + object : HttpRequestBody { + private val bytes = body.toByteArray(StandardCharsets.UTF_8) + + override fun writeTo(outputStream: OutputStream) { + outputStream.write(bytes) + } + + override fun contentType(): String = contentType + + override fun contentLength(): Long = contentLength ?: bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + ) + .build() + + private fun fakeHttpClient( + statusCode: Int = 200, + responseHeaders: Headers = Headers.builder().build(), + responseBody: ByteArray = ByteArray(0), + ): HttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + // Consume the request body if present to trigger logging. + request.body?.let { + val out = ByteArrayOutputStream() + it.writeTo(out) + } + return fakeResponse(statusCode, responseHeaders, responseBody) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = + CompletableFuture.completedFuture(execute(request, requestOptions)) + + override fun close() {} + } + + private fun failingHttpClient(error: Throwable): HttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + request.body?.let { + val out = ByteArrayOutputStream() + it.writeTo(out) + } + throw error + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val future = CompletableFuture() + future.completeExceptionally(error) + return future + } + + override fun close() {} + } + + private fun fakeResponse(statusCode: Int, headers: Headers, body: ByteArray): HttpResponse = + object : HttpResponse { + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): InputStream = ByteArrayInputStream(body) + + override fun close() {} + } + + private fun clockFrom(vararg instants: Instant): Clock = + object : Clock() { + private var index = 0 + + override fun getZone() = ZoneOffset.UTC + + override fun withZone(zone: java.time.ZoneId?) = this + + override fun instant(): Instant { + val instant = instants[index % instants.size] + index++ + return instant + } + } + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) +} From 051e173193c87cabce6486b1d419e1a5c230c444 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 04:29:28 +0000 Subject: [PATCH 31/38] chore: redact api-key headers in debug logs --- .../kotlin/org/onebusaway/core/http/LoggingHttpClient.kt | 7 ++++--- .../org/onebusaway/core/http/LoggingHttpClientTest.kt | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/LoggingHttpClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/LoggingHttpClient.kt index f1079f0..98fee55 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/LoggingHttpClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/LoggingHttpClient.kt @@ -31,7 +31,7 @@ private constructor( /** * Sensitive headers to redact from logs. * - * Defaults to `Set.of()`. + * Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie")`. */ @get:JvmName("redactedHeaders") val redactedHeaders: SortedSet, /** @@ -192,7 +192,8 @@ private constructor( class Builder internal constructor() { private var httpClient: HttpClient? = null - private var redactedHeaders: Set = setOf() + private var redactedHeaders: Set = + setOf("authorization", "api-key", "x-api-key", "cookie", "set-cookie") private var clock: Clock = Clock.systemUTC() private var level: LogLevel? = null @@ -210,7 +211,7 @@ private constructor( /** * Sensitive headers to redact from logs. * - * Defaults to `Set.of()`. + * Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie")`. */ fun redactedHeaders(redactedHeaders: Set) = apply { this.redactedHeaders = redactedHeaders diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/LoggingHttpClientTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/LoggingHttpClientTest.kt index 0498a77..d3afc2b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/LoggingHttpClientTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/LoggingHttpClientTest.kt @@ -870,7 +870,8 @@ internal class LoggingHttpClientTest { httpClient: HttpClient, level: LogLevel, clock: Clock = clockFrom(Instant.parse("1998-04-21T00:00:00Z")), - redactedHeaders: Set = setOf(), + redactedHeaders: Set = + setOf("authorization", "api-key", "x-api-key", "cookie", "set-cookie"), ): LoggingHttpClient = LoggingHttpClient.builder() .httpClient(httpClient) From 1cad394444409bd3e6264f2de9d345bf9ff4ac4d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 02:54:25 +0000 Subject: [PATCH 32/38] chore(internal): codegen related update --- .github/workflows/ci.yml | 20 ++++++++++---------- .github/workflows/publish-sonatype.yml | 6 +++--- .github/workflows/release-doctor.yml | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ea8820..6d7583d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,10 +22,10 @@ jobs: if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -34,7 +34,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3 - name: Run lints run: ./scripts/lint @@ -49,10 +49,10 @@ jobs: if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -61,7 +61,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3 - name: Build SDK run: ./scripts/build @@ -71,7 +71,7 @@ jobs: github.repository == 'stainless-sdks/open-transit-java' && !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v8 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); @@ -91,10 +91,10 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -103,7 +103,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0 - name: Run tests run: ./scripts/test diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 7da89b6..9ee4085 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -26,7 +26,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0 - name: Publish to Sonatype run: |- diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index d7ecefc..3b12bc9 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'OneBusAway/java-sdk' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | From 437baa4d600d5504c7e269a4b6f41381810f6027 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 20 May 2026 03:29:10 +0000 Subject: [PATCH 33/38] feat(api): api update --- .stats.yml | 4 ++-- .../models/tripdetails/TripDetailRetrieveResponse.kt | 4 ++++ .../models/tripforvehicle/TripForVehicleRetrieveResponse.kt | 4 ++++ .../models/tripsforlocation/TripsForLocationListResponse.kt | 4 ++++ .../models/tripsforroute/TripsForRouteListResponse.kt | 4 ++++ .../models/vehiclesforagency/VehiclesForAgencyListResponse.kt | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6608e4d..62a092e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-b625345de7b9c51744ddc6c75b8c37a159a536204481404cca91d7d6a859149d.yml -openapi_spec_hash: 9bf1e5bf00ef9936a9181ebd0956d5b8 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-4a35fd1e705bc2b75f44e2fd82144b95eeb56f329e4e05bbede7e6bc8adc479e.yml +openapi_spec_hash: bc73be5518578c9ad8e878b82c540691 config_hash: c28ddf5b7754155603d9fd1c5fcaeeff diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt index e76dff2..2c0d081 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt @@ -558,6 +558,8 @@ private constructor( fun situationIds(): Optional> = situationIds.getOptional("situationIds") /** + * Trip-specific status for the arriving transit vehicle. + * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -739,6 +741,7 @@ private constructor( } } + /** Trip-specific status for the arriving transit vehicle. */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -1594,6 +1597,7 @@ private constructor( "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" } + /** Trip-specific status for the arriving transit vehicle. */ class Status @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt index 02901ad..bba9ae3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt @@ -560,6 +560,8 @@ private constructor( fun situationIds(): Optional> = situationIds.getOptional("situationIds") /** + * Trip-specific status for the arriving transit vehicle. + * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -741,6 +743,7 @@ private constructor( } } + /** Trip-specific status for the arriving transit vehicle. */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -1596,6 +1599,7 @@ private constructor( "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" } + /** Trip-specific status for the arriving transit vehicle. */ class Status @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt index cb8b625..af73a2f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt @@ -633,6 +633,8 @@ private constructor( fun schedule(): Schedule = schedule.getRequired("schedule") /** + * Trip-specific status for the arriving transit vehicle. + * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -779,6 +781,7 @@ private constructor( */ fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + /** Trip-specific status for the arriving transit vehicle. */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -1702,6 +1705,7 @@ private constructor( "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" } + /** Trip-specific status for the arriving transit vehicle. */ class Status @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt index feebad5..a2e1a6c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt @@ -592,6 +592,8 @@ private constructor( fun schedule(): Schedule = schedule.getRequired("schedule") /** + * Trip-specific status for the arriving transit vehicle. + * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -738,6 +740,7 @@ private constructor( */ fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + /** Trip-specific status for the arriving transit vehicle. */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -1661,6 +1664,7 @@ private constructor( "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" } + /** Trip-specific status for the arriving transit vehicle. */ class Status @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt index fdfb08e..fad0f50 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -682,6 +682,8 @@ private constructor( fun tripId(): Optional = tripId.getOptional("tripId") /** + * Trip-specific status for the arriving transit vehicle. + * * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -972,6 +974,7 @@ private constructor( */ fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + /** Trip-specific status for the arriving transit vehicle. */ fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) /** @@ -1281,6 +1284,7 @@ private constructor( "Location{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" } + /** Trip-specific status for the arriving transit vehicle. */ class TripStatus @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( From 97d101f05496b1456a689edc3405c8ec1daf4087 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Jun 2026 22:09:37 +0000 Subject: [PATCH 34/38] feat(api): api update --- .stats.yml | 4 +- .../ArrivalAndDepartureListResponse.kt | 56 +++++++++++++++---- .../ArrivalAndDepartureRetrieveResponse.kt | 54 ++++++++++++++---- ...alsAndDeparturesForLocationListResponse.kt | 56 +++++++++++++++---- .../tripdetails/TripDetailRetrieveResponse.kt | 10 +++- .../TripForVehicleRetrieveResponse.kt | 10 +++- .../TripsForLocationListResponse.kt | 19 ++++--- .../TripsForRouteListResponse.kt | 19 ++++--- .../VehiclesForAgencyListResponse.kt | 5 +- 9 files changed, 182 insertions(+), 51 deletions(-) diff --git a/.stats.yml b/.stats.yml index 62a092e..3367948 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-4a35fd1e705bc2b75f44e2fd82144b95eeb56f329e4e05bbede7e6bc8adc479e.yml -openapi_spec_hash: bc73be5518578c9ad8e878b82c540691 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-5f69b2b288261c7adfd9acb065dce897caf8782aff1687efe38ba52541ef7b96.yml +openapi_spec_hash: b03acca245aef78353d3b7a6a4a62eb2 config_hash: c28ddf5b7754155603d9fd1c5fcaeeff diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt index 42f7a5f..3b88287 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt @@ -1901,7 +1901,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. @@ -1974,8 +1977,15 @@ private constructor( } /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: String) = - predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) + fun predictedArrivalInterval(predictedArrivalInterval: String?) = + predictedArrivalInterval(JsonField.ofNullable(predictedArrivalInterval)) + + /** + * Alias for calling [Builder.predictedArrivalInterval] with + * `predictedArrivalInterval.orElse(null)`. + */ + fun predictedArrivalInterval(predictedArrivalInterval: Optional) = + predictedArrivalInterval(predictedArrivalInterval.getOrNull()) /** * Sets [Builder.predictedArrivalInterval] to an arbitrary JSON value. @@ -1990,8 +2000,15 @@ private constructor( } /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: String) = - predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) + fun predictedDepartureInterval(predictedDepartureInterval: String?) = + predictedDepartureInterval(JsonField.ofNullable(predictedDepartureInterval)) + + /** + * Alias for calling [Builder.predictedDepartureInterval] with + * `predictedDepartureInterval.orElse(null)`. + */ + fun predictedDepartureInterval(predictedDepartureInterval: Optional) = + predictedDepartureInterval(predictedDepartureInterval.getOrNull()) /** * Sets [Builder.predictedDepartureInterval] to an arbitrary JSON value. @@ -2057,8 +2074,15 @@ private constructor( } /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: String) = - scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) + fun scheduledArrivalInterval(scheduledArrivalInterval: String?) = + scheduledArrivalInterval(JsonField.ofNullable(scheduledArrivalInterval)) + + /** + * Alias for calling [Builder.scheduledArrivalInterval] with + * `scheduledArrivalInterval.orElse(null)`. + */ + fun scheduledArrivalInterval(scheduledArrivalInterval: Optional) = + scheduledArrivalInterval(scheduledArrivalInterval.getOrNull()) /** * Sets [Builder.scheduledArrivalInterval] to an arbitrary JSON value. @@ -2073,8 +2097,15 @@ private constructor( } /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: String) = - scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) + fun scheduledDepartureInterval(scheduledDepartureInterval: String?) = + scheduledDepartureInterval(JsonField.ofNullable(scheduledDepartureInterval)) + + /** + * Alias for calling [Builder.scheduledDepartureInterval] with + * `scheduledDepartureInterval.orElse(null)`. + */ + fun scheduledDepartureInterval(scheduledDepartureInterval: Optional) = + scheduledDepartureInterval(scheduledDepartureInterval.getOrNull()) /** * Sets [Builder.scheduledDepartureInterval] to an arbitrary JSON value. @@ -3403,7 +3434,12 @@ private constructor( /** * Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = + frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = + frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt index e5bc6ce..f5a5984 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt @@ -1705,7 +1705,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. @@ -1774,8 +1777,15 @@ private constructor( fun predicted(predicted: JsonField) = apply { this.predicted = predicted } /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: String) = - predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) + fun predictedArrivalInterval(predictedArrivalInterval: String?) = + predictedArrivalInterval(JsonField.ofNullable(predictedArrivalInterval)) + + /** + * Alias for calling [Builder.predictedArrivalInterval] with + * `predictedArrivalInterval.orElse(null)`. + */ + fun predictedArrivalInterval(predictedArrivalInterval: Optional) = + predictedArrivalInterval(predictedArrivalInterval.getOrNull()) /** * Sets [Builder.predictedArrivalInterval] to an arbitrary JSON value. @@ -1789,8 +1799,15 @@ private constructor( } /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: String) = - predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) + fun predictedDepartureInterval(predictedDepartureInterval: String?) = + predictedDepartureInterval(JsonField.ofNullable(predictedDepartureInterval)) + + /** + * Alias for calling [Builder.predictedDepartureInterval] with + * `predictedDepartureInterval.orElse(null)`. + */ + fun predictedDepartureInterval(predictedDepartureInterval: Optional) = + predictedDepartureInterval(predictedDepartureInterval.getOrNull()) /** * Sets [Builder.predictedDepartureInterval] to an arbitrary JSON value. @@ -1856,8 +1873,15 @@ private constructor( } /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: String) = - scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) + fun scheduledArrivalInterval(scheduledArrivalInterval: String?) = + scheduledArrivalInterval(JsonField.ofNullable(scheduledArrivalInterval)) + + /** + * Alias for calling [Builder.scheduledArrivalInterval] with + * `scheduledArrivalInterval.orElse(null)`. + */ + fun scheduledArrivalInterval(scheduledArrivalInterval: Optional) = + scheduledArrivalInterval(scheduledArrivalInterval.getOrNull()) /** * Sets [Builder.scheduledArrivalInterval] to an arbitrary JSON value. @@ -1871,8 +1895,15 @@ private constructor( } /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: String) = - scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) + fun scheduledDepartureInterval(scheduledDepartureInterval: String?) = + scheduledDepartureInterval(JsonField.ofNullable(scheduledDepartureInterval)) + + /** + * Alias for calling [Builder.scheduledDepartureInterval] with + * `scheduledDepartureInterval.orElse(null)`. + */ + fun scheduledDepartureInterval(scheduledDepartureInterval: Optional) = + scheduledDepartureInterval(scheduledDepartureInterval.getOrNull()) /** * Sets [Builder.scheduledDepartureInterval] to an arbitrary JSON value. @@ -3178,7 +3209,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt index 1b8c611..4d60364 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalsanddeparturesforlocation/ArrivalsAndDeparturesForLocationListResponse.kt @@ -2110,7 +2110,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. @@ -2183,8 +2186,15 @@ private constructor( } /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: String) = - predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) + fun predictedArrivalInterval(predictedArrivalInterval: String?) = + predictedArrivalInterval(JsonField.ofNullable(predictedArrivalInterval)) + + /** + * Alias for calling [Builder.predictedArrivalInterval] with + * `predictedArrivalInterval.orElse(null)`. + */ + fun predictedArrivalInterval(predictedArrivalInterval: Optional) = + predictedArrivalInterval(predictedArrivalInterval.getOrNull()) /** * Sets [Builder.predictedArrivalInterval] to an arbitrary JSON value. @@ -2199,8 +2209,15 @@ private constructor( } /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: String) = - predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) + fun predictedDepartureInterval(predictedDepartureInterval: String?) = + predictedDepartureInterval(JsonField.ofNullable(predictedDepartureInterval)) + + /** + * Alias for calling [Builder.predictedDepartureInterval] with + * `predictedDepartureInterval.orElse(null)`. + */ + fun predictedDepartureInterval(predictedDepartureInterval: Optional) = + predictedDepartureInterval(predictedDepartureInterval.getOrNull()) /** * Sets [Builder.predictedDepartureInterval] to an arbitrary JSON value. @@ -2266,8 +2283,15 @@ private constructor( } /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: String) = - scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) + fun scheduledArrivalInterval(scheduledArrivalInterval: String?) = + scheduledArrivalInterval(JsonField.ofNullable(scheduledArrivalInterval)) + + /** + * Alias for calling [Builder.scheduledArrivalInterval] with + * `scheduledArrivalInterval.orElse(null)`. + */ + fun scheduledArrivalInterval(scheduledArrivalInterval: Optional) = + scheduledArrivalInterval(scheduledArrivalInterval.getOrNull()) /** * Sets [Builder.scheduledArrivalInterval] to an arbitrary JSON value. @@ -2282,8 +2306,15 @@ private constructor( } /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: String) = - scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) + fun scheduledDepartureInterval(scheduledDepartureInterval: String?) = + scheduledDepartureInterval(JsonField.ofNullable(scheduledDepartureInterval)) + + /** + * Alias for calling [Builder.scheduledDepartureInterval] with + * `scheduledDepartureInterval.orElse(null)`. + */ + fun scheduledDepartureInterval(scheduledDepartureInterval: Optional) = + scheduledDepartureInterval(scheduledDepartureInterval.getOrNull()) /** * Sets [Builder.scheduledDepartureInterval] to an arbitrary JSON value. @@ -3612,7 +3643,12 @@ private constructor( /** * Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = + frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = + frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt index 2c0d081..13aad6a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt @@ -691,7 +691,10 @@ private constructor( */ fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + fun schedule(schedule: Schedule?) = schedule(JsonField.ofNullable(schedule)) + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = schedule(schedule.getOrNull()) /** * Sets [Builder.schedule] to an arbitrary JSON value. @@ -2627,7 +2630,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt index bba9ae3..b8a3125 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt @@ -693,7 +693,10 @@ private constructor( */ fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + fun schedule(schedule: Schedule?) = schedule(JsonField.ofNullable(schedule)) + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = schedule(schedule.getOrNull()) /** * Sets [Builder.schedule] to an arbitrary JSON value. @@ -2629,7 +2632,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt index af73a2f..f1ba984 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt @@ -626,11 +626,10 @@ private constructor( ) : this(schedule, status, tripId, frequency, serviceDate, situationIds, mutableMapOf()) /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun schedule(): Schedule = schedule.getRequired("schedule") + fun schedule(): Optional = schedule.getOptional("schedule") /** * Trip-specific status for the arriving transit vehicle. @@ -770,7 +769,10 @@ private constructor( additionalProperties = list.additionalProperties.toMutableMap() } - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + fun schedule(schedule: Schedule?) = schedule(JsonField.ofNullable(schedule)) + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = schedule(schedule.getOrNull()) /** * Sets [Builder.schedule] to an arbitrary JSON value. @@ -922,7 +924,7 @@ private constructor( return@apply } - schedule().validate() + schedule().ifPresent { it.validate() } status().validate() tripId() frequency() @@ -2735,7 +2737,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt index a2e1a6c..9c1c2bd 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt @@ -585,11 +585,10 @@ private constructor( ) : this(schedule, status, tripId, frequency, serviceDate, situationIds, mutableMapOf()) /** - * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun schedule(): Schedule = schedule.getRequired("schedule") + fun schedule(): Optional = schedule.getOptional("schedule") /** * Trip-specific status for the arriving transit vehicle. @@ -729,7 +728,10 @@ private constructor( additionalProperties = list.additionalProperties.toMutableMap() } - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + fun schedule(schedule: Schedule?) = schedule(JsonField.ofNullable(schedule)) + + /** Alias for calling [Builder.schedule] with `schedule.orElse(null)`. */ + fun schedule(schedule: Optional) = schedule(schedule.getOrNull()) /** * Sets [Builder.schedule] to an arbitrary JSON value. @@ -881,7 +883,7 @@ private constructor( return@apply } - schedule().validate() + schedule().ifPresent { it.validate() } status().validate() tripId() frequency() @@ -2694,7 +2696,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt index fad0f50..5585604 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -2314,7 +2314,10 @@ private constructor( } /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) /** * Sets [Builder.frequency] to an arbitrary JSON value. From 4d09d774e8091b803ae44d61146b6d060a120d79 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 06:30:57 +0000 Subject: [PATCH 35/38] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3367948..c36cce3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-5f69b2b288261c7adfd9acb065dce897caf8782aff1687efe38ba52541ef7b96.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-dee931967ba2ef46e7c8172181c5e92a5555eb0e39ac972540c2c7f9afa5a4f3.yml openapi_spec_hash: b03acca245aef78353d3b7a6a4a62eb2 -config_hash: c28ddf5b7754155603d9fd1c5fcaeeff +config_hash: 90ead07431e6975682fbca7c92b7e14d From 5cea3bb342b8682c65a1c2119dfb343231325e8f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 06:31:11 +0000 Subject: [PATCH 36/38] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index c36cce3..a3a2c77 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-dee931967ba2ef46e7c8172181c5e92a5555eb0e39ac972540c2c7f9afa5a4f3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit/open-transit-49611a380a238e29ad714c2f6d66a35ada42e3931d2aad2839afd1f13b585de1.yml openapi_spec_hash: b03acca245aef78353d3b7a6a4a62eb2 -config_hash: 90ead07431e6975682fbca7c92b7e14d +config_hash: ff7ff57d4c7f9c3f7a4f9bae39aa00e3 From 3da2b5266b27f4cd9a383728cb3b7263dea01764 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:07:41 +0000 Subject: [PATCH 37/38] release: 0.1.0-alpha.57 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 59 +++++++++++++++++++++++++++++++++++ README.md | 10 +++--- build.gradle.kts | 2 +- 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 0815771..f406ff1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.56" + ".": "0.1.0-alpha.57" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 24c0ddd..bf52abd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,64 @@ # Changelog +## 0.1.0-alpha.57 (2026-06-08) + +Full Changelog: [v0.1.0-alpha.56...v0.1.0-alpha.57](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.56...v0.1.0-alpha.57) + +### Features + +* **api:** api update ([97d101f](https://github.com/OneBusAway/java-sdk/commit/97d101f05496b1456a689edc3405c8ec1daf4087)) +* **api:** api update ([437baa4](https://github.com/OneBusAway/java-sdk/commit/437baa4d600d5504c7e269a4b6f41381810f6027)) +* **api:** api update ([6b55911](https://github.com/OneBusAway/java-sdk/commit/6b55911920235024bc07b4bdfd44768a70df1d48)) +* **api:** api update ([fbaadd8](https://github.com/OneBusAway/java-sdk/commit/fbaadd8e2395cc74e3748f486fb17513a211bc1b)) +* **api:** api update ([0d4ee8e](https://github.com/OneBusAway/java-sdk/commit/0d4ee8e11408ed9a067d3a45038d1bfe45ad58a3)) +* **api:** api update ([1e5faa0](https://github.com/OneBusAway/java-sdk/commit/1e5faa0e778189bb3ffc214ac370b0f8c5085824)) +* **api:** api update ([fff5ec2](https://github.com/OneBusAway/java-sdk/commit/fff5ec2ab5207e5e378a1cf59e79922f1f8ade21)) +* **client:** improve logging ([80d4a74](https://github.com/OneBusAway/java-sdk/commit/80d4a74241fa268e03504f2fc565df666da77400)) +* **client:** more robust error parsing ([8c92200](https://github.com/OneBusAway/java-sdk/commit/8c92200d5138d6ff8acad77742994445992d0c0a)) +* **client:** support proxy authentication ([baeb731](https://github.com/OneBusAway/java-sdk/commit/baeb731d323acdc19d58ec4a0134107203f45e18)) +* support setting headers via env ([58e75c3](https://github.com/OneBusAway/java-sdk/commit/58e75c3de82e535d8c8a1a69922edc71f231d149)) + + +### Bug Fixes + +* **client:** allow updating header/query affecting fields in `toBuilder()` ([3964864](https://github.com/OneBusAway/java-sdk/commit/3964864f1cb0ebea7318a6e0fd68ea12e6705b24)) +* **client:** incorrect `Retry-After` parsing ([ee33acf](https://github.com/OneBusAway/java-sdk/commit/ee33acffec6143677ceae8a1e155c31736c0e4e0)) + + +### Performance Improvements + +* **client:** create one json mapper ([8157d7e](https://github.com/OneBusAway/java-sdk/commit/8157d7ecfa89ee3ccb179a57c2b8cd0665a1f5d1)) + + +### Chores + +* **ci:** skip lint on metadata-only changes ([e23b045](https://github.com/OneBusAway/java-sdk/commit/e23b04511c261dd1b68e84e7302361cae57f8a0c)) +* **internal:** bump ktfmt ([ffd9a1b](https://github.com/OneBusAway/java-sdk/commit/ffd9a1b7d321a1a0d89f5d00184ba94341db23aa)) +* **internal:** codegen related update ([1cad394](https://github.com/OneBusAway/java-sdk/commit/1cad394444409bd3e6264f2de9d345bf9ff4ac4d)) +* **internal:** tweak CI branches ([165398b](https://github.com/OneBusAway/java-sdk/commit/165398b0c6f820ec29093b1122837a990b2ae587)) +* **internal:** update gitignore ([2976e04](https://github.com/OneBusAway/java-sdk/commit/2976e04d3381ba91ed619eac4cdb9a001fbf46e8)) +* **internal:** update multipart form array serialization ([7208a3c](https://github.com/OneBusAway/java-sdk/commit/7208a3c4f47fc1070808d19e78f3d86c6daa9307)) +* **internal:** update retry delay tests ([56092cf](https://github.com/OneBusAway/java-sdk/commit/56092cf073f68b0631750dda62089acb0496affc)) +* redact api-key headers in debug logs ([051e173](https://github.com/OneBusAway/java-sdk/commit/051e173193c87cabce6486b1d419e1a5c230c444)) +* remove duplicated dokka setup ([88e7490](https://github.com/OneBusAway/java-sdk/commit/88e7490658f71bbe6ae94b8727746b5f34722244)) +* **tests:** bump steady to v0.19.4 ([633a61a](https://github.com/OneBusAway/java-sdk/commit/633a61ab965ff86afd6466106c9c1325ace48187)) +* **tests:** bump steady to v0.19.5 ([22f82da](https://github.com/OneBusAway/java-sdk/commit/22f82dae778becca20f549b8410a7c1d2c954655)) +* **tests:** bump steady to v0.19.6 ([e334755](https://github.com/OneBusAway/java-sdk/commit/e334755a99bdf8f096d8247ffd40e416471db36b)) +* **tests:** bump steady to v0.19.7 ([ef0587c](https://github.com/OneBusAway/java-sdk/commit/ef0587c47711d53a97a7982fbf352de7c3f17333)) +* **tests:** bump steady to v0.20.1 ([f74e874](https://github.com/OneBusAway/java-sdk/commit/f74e874bd26003286fbf031c340bf1ae25e1de63)) +* **tests:** bump steady to v0.20.2 ([7e86c45](https://github.com/OneBusAway/java-sdk/commit/7e86c4531e42593b1f50806efd88afaa2f46bdd1)) +* **tests:** bump steady to v0.22.1 ([344888d](https://github.com/OneBusAway/java-sdk/commit/344888d82e5616e2f6e6400c270b8e9e89072bbf)) + + +### Documentation + +* clarify forwards compat behavior ([ce30a3c](https://github.com/OneBusAway/java-sdk/commit/ce30a3c1bdf6f81bcb3af3cb10470a68b9065b9b)) + + +### Refactors + +* **tests:** switch from prism to steady ([77efbfa](https://github.com/OneBusAway/java-sdk/commit/77efbfa7675a8d7d8335e445ea0caac680017e57)) + ## 0.1.0-alpha.56 (2026-03-07) Full Changelog: [v0.1.0-alpha.55...v0.1.0-alpha.56](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.55...v0.1.0-alpha.56) diff --git a/README.md b/README.md index 1ea5fe7..64f61c6 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.56) -[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.56/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.56) +[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.57) +[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.57/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.57) @@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.56). +The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.57). @@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.onebusaway.org](https://de ### Gradle ```kotlin -implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.56") +implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.57") ``` ### Maven @@ -35,7 +35,7 @@ implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.56") org.onebusaway onebusaway-sdk-java - 0.1.0-alpha.56 + 0.1.0-alpha.57 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 0b7dae3..53cee8d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "org.onebusaway" - version = "0.1.0-alpha.56" // x-release-please-version + version = "0.1.0-alpha.57" // x-release-please-version } subprojects { From 3ee0ce755ea049f6e3085a1b35a0a60b0c5ab24b Mon Sep 17 00:00:00 2001 From: Ahmedhossamdev Date: Mon, 8 Jun 2026 19:22:28 +0300 Subject: [PATCH 38/38] fix(api): improve formatting and annotations in StopsForAgencyListResponse --- .../stopsforagency/StopsForAgencyListResponse.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt index 34efc3c..c848110 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt @@ -318,7 +318,9 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("list") @ExcludeMissing list: JsonField> = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing references: JsonField = JsonMissing.of(), @@ -359,7 +361,9 @@ private constructor( * * Unlike [list], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list /** * Returns the raw JSON value of [references]. @@ -438,9 +442,9 @@ private constructor( /** * Sets [Builder.list] to an arbitrary JSON value. * - * You should usually call [Builder.list] with a well-typed `kotlin.collections.List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.list] with a well-typed + * `kotlin.collections.List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ fun list(list: JsonField>) = apply { this.list = list.map { it.toMutableList() }