From c5e90c0cda29a9131fd81e60d22711794a2f0a71 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 30 Nov 2024 07:24:50 +0000 Subject: [PATCH 01/11] chore(internal): codegen related update (#71) --- README.md | 16 ++ .../build.gradle.kts | 3 +- .../onebusaway/client/okhttp/OkHttpClient.kt | 56 +++-- .../okhttp/OnebusawaySdkOkHttpClient.kt | 18 ++ .../okhttp/OnebusawaySdkOkHttpClientAsync.kt | 18 ++ onebusaway-sdk-java-core/build.gradle.kts | 18 +- .../client/OnebusawaySdkClientAsyncImpl.kt | 2 +- .../client/OnebusawaySdkClientImpl.kt | 2 +- .../org/onebusaway/core/ClientOptions.kt | 88 +++++--- .../org/onebusaway/core/PhantomReachable.kt | 18 +- .../main/kotlin/org/onebusaway/core/Utils.kt | 6 - .../onebusaway/core/handlers/ErrorHandler.kt | 4 +- .../org/onebusaway/core/http/HttpRequest.kt | 82 ++++--- .../org/onebusaway/core/http/HttpResponse.kt | 3 +- .../core/http/RetryingHttpClient.kt | 50 +++-- .../onebusaway/errors/BadRequestException.kt | 4 +- .../errors/InternalServerException.kt | 4 +- .../onebusaway/errors/NotFoundException.kt | 4 +- .../onebusaway/errors/OnebusawaySdkError.kt | 51 +++-- .../errors/OnebusawaySdkServiceException.kt | 6 +- .../errors/PermissionDeniedException.kt | 4 +- .../onebusaway/errors/RateLimitException.kt | 4 +- .../errors/UnauthorizedException.kt | 4 +- .../errors/UnexpectedStatusCodeException.kt | 4 +- .../errors/UnprocessableEntityException.kt | 4 +- .../models/AgenciesWithCoverageListParams.kt | 120 +++++----- .../AgenciesWithCoverageListResponse.kt | 39 ++-- .../onebusaway/models/AgencyRetrieveParams.kt | 125 ++++++----- .../models/AgencyRetrieveResponse.kt | 39 ++-- .../models/ArrivalAndDepartureListParams.kt | 143 ++++++------ .../models/ArrivalAndDepartureListResponse.kt | 91 +++----- .../ArrivalAndDepartureRetrieveParams.kt | 152 +++++++------ .../ArrivalAndDepartureRetrieveResponse.kt | 78 +++---- .../onebusaway/models/BlockRetrieveParams.kt | 125 ++++++----- .../models/BlockRetrieveResponse.kt | 91 +++----- .../onebusaway/models/ConfigRetrieveParams.kt | 120 +++++----- .../models/ConfigRetrieveResponse.kt | 52 ++--- .../models/CurrentTimeRetrieveParams.kt | 120 +++++----- .../models/CurrentTimeRetrieveResponse.kt | 39 ++-- .../org/onebusaway/models/References.kt | 210 +++++++----------- .../ReportProblemWithStopRetrieveParams.kt | 156 +++++++------ .../ReportProblemWithTripRetrieveParams.kt | 176 ++++++++------- .../org/onebusaway/models/ResponseWrapper.kt | 13 +- .../models/RouteIdsForAgencyListParams.kt | 125 ++++++----- .../models/RouteIdsForAgencyListResponse.kt | 26 +-- .../onebusaway/models/RouteRetrieveParams.kt | 125 ++++++----- .../models/RouteRetrieveResponse.kt | 39 ++-- .../models/RoutesForAgencyListParams.kt | 125 ++++++----- .../models/RoutesForAgencyListResponse.kt | 39 ++-- .../models/RoutesForLocationListParams.kt | 151 +++++++------ .../models/RoutesForLocationListResponse.kt | 39 ++-- .../models/ScheduleForRouteRetrieveParams.kt | 135 ++++++----- .../ScheduleForRouteRetrieveResponse.kt | 104 ++++----- .../models/ScheduleForStopRetrieveParams.kt | 135 ++++++----- .../models/ScheduleForStopRetrieveResponse.kt | 91 +++----- .../models/SearchForRouteListParams.kt | 135 ++++++----- .../models/SearchForRouteListResponse.kt | 39 ++-- .../models/SearchForStopListParams.kt | 135 ++++++----- .../models/SearchForStopListResponse.kt | 39 ++-- .../onebusaway/models/ShapeRetrieveParams.kt | 125 ++++++----- .../models/ShapeRetrieveResponse.kt | 39 ++-- .../models/StopIdsForAgencyListParams.kt | 125 ++++++----- .../models/StopIdsForAgencyListResponse.kt | 26 +-- .../onebusaway/models/StopRetrieveParams.kt | 125 ++++++----- .../onebusaway/models/StopRetrieveResponse.kt | 39 ++-- .../models/StopsForAgencyListParams.kt | 125 ++++++----- .../models/StopsForAgencyListResponse.kt | 26 +-- .../models/StopsForLocationListParams.kt | 151 +++++++------ .../models/StopsForLocationListResponse.kt | 39 ++-- .../models/StopsForRouteListParams.kt | 139 ++++++------ .../models/StopsForRouteListResponse.kt | 91 +++----- .../models/TripDetailRetrieveParams.kt | 151 +++++++------ .../models/TripDetailRetrieveResponse.kt | 104 ++++----- .../models/TripForVehicleRetrieveParams.kt | 147 ++++++------ .../models/TripForVehicleRetrieveResponse.kt | 104 ++++----- .../onebusaway/models/TripRetrieveParams.kt | 125 ++++++----- .../onebusaway/models/TripRetrieveResponse.kt | 39 ++-- .../models/TripsForLocationListParams.kt | 155 +++++++------ .../models/TripsForLocationListResponse.kt | 104 ++++----- .../models/TripsForRouteListParams.kt | 143 ++++++------ .../models/TripsForRouteListResponse.kt | 104 ++++----- .../models/VehiclesForAgencyListParams.kt | 135 ++++++----- .../models/VehiclesForAgencyListResponse.kt | 91 +++----- .../AgenciesWithCoverageServiceAsyncImpl.kt | 4 +- .../services/async/AgencyServiceAsyncImpl.kt | 4 +- .../ArrivalAndDepartureServiceAsyncImpl.kt | 8 +- .../services/async/BlockServiceAsyncImpl.kt | 4 +- .../services/async/ConfigServiceAsyncImpl.kt | 4 +- .../async/CurrentTimeServiceAsyncImpl.kt | 4 +- .../ReportProblemWithStopServiceAsyncImpl.kt | 4 +- .../ReportProblemWithTripServiceAsyncImpl.kt | 4 +- .../RouteIdsForAgencyServiceAsyncImpl.kt | 4 +- .../services/async/RouteServiceAsyncImpl.kt | 4 +- .../async/RoutesForAgencyServiceAsyncImpl.kt | 4 +- .../RoutesForLocationServiceAsyncImpl.kt | 4 +- .../async/ScheduleForRouteServiceAsyncImpl.kt | 4 +- .../async/ScheduleForStopServiceAsyncImpl.kt | 4 +- .../async/SearchForRouteServiceAsyncImpl.kt | 4 +- .../async/SearchForStopServiceAsyncImpl.kt | 4 +- .../services/async/ShapeServiceAsyncImpl.kt | 4 +- .../async/StopIdsForAgencyServiceAsyncImpl.kt | 4 +- .../services/async/StopServiceAsyncImpl.kt | 4 +- .../async/StopsForAgencyServiceAsyncImpl.kt | 4 +- .../async/StopsForLocationServiceAsyncImpl.kt | 4 +- .../async/StopsForRouteServiceAsyncImpl.kt | 4 +- .../async/TripDetailServiceAsyncImpl.kt | 4 +- .../async/TripForVehicleServiceAsyncImpl.kt | 4 +- .../services/async/TripServiceAsyncImpl.kt | 4 +- .../async/TripsForLocationServiceAsyncImpl.kt | 4 +- .../async/TripsForRouteServiceAsyncImpl.kt | 4 +- .../VehiclesForAgencyServiceAsyncImpl.kt | 4 +- .../AgenciesWithCoverageServiceImpl.kt | 4 +- .../services/blocking/AgencyServiceImpl.kt | 4 +- .../ArrivalAndDepartureServiceImpl.kt | 8 +- .../services/blocking/BlockServiceImpl.kt | 4 +- .../services/blocking/ConfigServiceImpl.kt | 4 +- .../blocking/CurrentTimeServiceImpl.kt | 4 +- .../ReportProblemWithStopServiceImpl.kt | 4 +- .../ReportProblemWithTripServiceImpl.kt | 4 +- .../blocking/RouteIdsForAgencyServiceImpl.kt | 4 +- .../services/blocking/RouteServiceImpl.kt | 4 +- .../blocking/RoutesForAgencyServiceImpl.kt | 4 +- .../blocking/RoutesForLocationServiceImpl.kt | 4 +- .../blocking/ScheduleForRouteServiceImpl.kt | 4 +- .../blocking/ScheduleForStopServiceImpl.kt | 4 +- .../blocking/SearchForRouteServiceImpl.kt | 4 +- .../blocking/SearchForStopServiceImpl.kt | 4 +- .../services/blocking/ShapeServiceImpl.kt | 4 +- .../blocking/StopIdsForAgencyServiceImpl.kt | 4 +- .../services/blocking/StopServiceImpl.kt | 4 +- .../blocking/StopsForAgencyServiceImpl.kt | 4 +- .../blocking/StopsForLocationServiceImpl.kt | 4 +- .../blocking/StopsForRouteServiceImpl.kt | 4 +- .../blocking/TripDetailServiceImpl.kt | 4 +- .../blocking/TripForVehicleServiceImpl.kt | 4 +- .../services/blocking/TripServiceImpl.kt | 4 +- .../blocking/TripsForLocationServiceImpl.kt | 4 +- .../blocking/TripsForRouteServiceImpl.kt | 4 +- .../blocking/VehiclesForAgencyServiceImpl.kt | 4 +- .../onebusaway/core/http/HttpRequestTest.kt | 22 -- .../ArrivalAndDepartureListParamsTest.kt | 15 +- .../ArrivalAndDepartureRetrieveParamsTest.kt | 23 +- ...ReportProblemWithStopRetrieveParamsTest.kt | 22 +- ...ReportProblemWithTripRetrieveParamsTest.kt | 32 ++- .../models/RoutesForLocationListParamsTest.kt | 25 ++- .../ScheduleForRouteRetrieveParamsTest.kt | 11 +- .../ScheduleForStopRetrieveParamsTest.kt | 11 +- .../models/SearchForRouteListParamsTest.kt | 15 +- .../models/SearchForStopListParamsTest.kt | 15 +- .../models/StopsForLocationListParamsTest.kt | 25 ++- .../models/StopsForRouteListParamsTest.kt | 13 +- .../models/TripDetailRetrieveParamsTest.kt | 19 +- .../TripForVehicleRetrieveParamsTest.kt | 17 +- .../models/TripsForLocationListParamsTest.kt | 31 +-- .../models/TripsForRouteListParamsTest.kt | 15 +- .../models/VehiclesForAgencyListParamsTest.kt | 11 +- .../onebusaway/services/ErrorHandlingTest.kt | 84 +++---- 157 files changed, 3526 insertions(+), 3408 deletions(-) delete mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HttpRequestTest.kt diff --git a/README.md b/README.md index 7dd1dc3..6c33aad 100644 --- a/README.md +++ b/README.md @@ -240,6 +240,22 @@ get a map of untyped fields of type `Map`. You can then acces `._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. +## Logging + +We use the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). + +You can enable logging by setting the environment variable `ONEBUSAWAY_SDK_LOG` to `info`. + +```sh +$ export ONEBUSAWAY_SDK_LOG=info +``` + +Or to `debug` for more verbose logging. + +```sh +$ export ONEBUSAWAY_SDK_LOG=debug +``` + ## Semantic versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: diff --git a/onebusaway-sdk-java-client-okhttp/build.gradle.kts b/onebusaway-sdk-java-client-okhttp/build.gradle.kts index 037ef81..2fd0abf 100644 --- a/onebusaway-sdk-java-client-okhttp/build.gradle.kts +++ b/onebusaway-sdk-java-client-okhttp/build.gradle.kts @@ -6,10 +6,9 @@ plugins { dependencies { api(project(":onebusaway-sdk-java-core")) - implementation("com.google.guava:guava:33.0.0-jre") 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.25.3") - testImplementation("org.slf4j:slf4j-simple:2.0.12") } 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 427df17..0635f4e 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 @@ -1,7 +1,5 @@ package org.onebusaway.client.okhttp -import com.google.common.collect.ListMultimap -import com.google.common.collect.MultimapBuilder import java.io.IOException import java.io.InputStream import java.net.Proxy @@ -9,7 +7,6 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.Headers import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType @@ -18,8 +15,10 @@ import okhttp3.Request import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response +import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest @@ -32,14 +31,28 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val HttpClient { private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { - val timeout = requestOptions.timeout ?: return okHttpClient - return okHttpClient - .newBuilder() - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) - .build() + val clientBuilder = okHttpClient.newBuilder() + + 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)) + } + + val timeout = requestOptions.timeout + if (timeout != null) { + clientBuilder + .connectTimeout(timeout) + .readTimeout(timeout) + .writeTimeout(timeout) + .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + } + + return clientBuilder.build() } override fun execute( @@ -95,7 +108,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } val builder = Request.Builder().url(toUrl()).method(method.name, body) - headers.forEach(builder::header) + headers.names().forEach { name -> + headers.values(name).forEach { builder.header(name, it) } + } return builder.build() } @@ -107,7 +122,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val val builder = baseUrl.newBuilder() pathSegments.forEach(builder::addPathSegment) - queryParams.forEach(builder::addQueryParameter) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } return builder.toString() } @@ -133,7 +150,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val return object : HttpResponse { override fun statusCode(): Int = code - override fun headers(): ListMultimap = headers + override fun headers(): Headers = headers override fun body(): InputStream = body!!.byteStream() @@ -141,13 +158,10 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } } - private fun Headers.toHeaders(): ListMultimap { - val headers = - MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) - .arrayListValues() - .build() - forEach { pair -> headers.put(pair.first, pair.second) } - return headers + private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() } companion object { 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 4c71daa..dfb3f1b 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 @@ -9,6 +9,8 @@ import java.time.Duration import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.OnebusawaySdkClientImpl import org.onebusaway.core.ClientOptions +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams class OnebusawaySdkOkHttpClient private constructor() { @@ -36,6 +38,8 @@ class OnebusawaySdkOkHttpClient private constructor() { fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + fun headers(headers: Map>) = apply { clientOptions.headers(headers) } @@ -46,6 +50,8 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.putHeaders(name, values) } + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + fun putAllHeaders(headers: Map>) = apply { clientOptions.putAllHeaders(headers) } @@ -58,6 +64,8 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.replaceHeaders(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + fun replaceAllHeaders(headers: Map>) = apply { clientOptions.replaceAllHeaders(headers) } @@ -66,6 +74,8 @@ class OnebusawaySdkOkHttpClient private constructor() { fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + fun queryParams(queryParams: Map>) = apply { clientOptions.queryParams(queryParams) } @@ -78,6 +88,10 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.putQueryParams(key, values) } + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + fun putAllQueryParams(queryParams: Map>) = apply { clientOptions.putAllQueryParams(queryParams) } @@ -90,6 +104,10 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.replaceQueryParams(key, values) } + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + fun replaceAllQueryParams(queryParams: Map>) = apply { clientOptions.replaceAllQueryParams(queryParams) } 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 00ea3d2..37c60ab 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 @@ -9,6 +9,8 @@ import java.time.Duration import org.onebusaway.client.OnebusawaySdkClientAsync import org.onebusaway.client.OnebusawaySdkClientAsyncImpl import org.onebusaway.core.ClientOptions +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams class OnebusawaySdkOkHttpClientAsync private constructor() { @@ -36,6 +38,8 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + fun headers(headers: Map>) = apply { clientOptions.headers(headers) } @@ -46,6 +50,8 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.putHeaders(name, values) } + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + fun putAllHeaders(headers: Map>) = apply { clientOptions.putAllHeaders(headers) } @@ -58,6 +64,8 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.replaceHeaders(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + fun replaceAllHeaders(headers: Map>) = apply { clientOptions.replaceAllHeaders(headers) } @@ -66,6 +74,8 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + fun queryParams(queryParams: Map>) = apply { clientOptions.queryParams(queryParams) } @@ -78,6 +88,10 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.putQueryParams(key, values) } + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + fun putAllQueryParams(queryParams: Map>) = apply { clientOptions.putAllQueryParams(queryParams) } @@ -90,6 +104,10 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.replaceQueryParams(key, values) } + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + fun replaceAllQueryParams(queryParams: Map>) = apply { clientOptions.replaceAllQueryParams(queryParams) } diff --git a/onebusaway-sdk-java-core/build.gradle.kts b/onebusaway-sdk-java-core/build.gradle.kts index 8f52193..6a0859b 100644 --- a/onebusaway-sdk-java-core/build.gradle.kts +++ b/onebusaway-sdk-java-core/build.gradle.kts @@ -4,14 +4,13 @@ plugins { } dependencies { - api("com.fasterxml.jackson.core:jackson-core:2.14.3") - api("com.fasterxml.jackson.core:jackson-databind:2.14.3") - api("com.google.guava:guava:33.0.0-jre") + api("com.fasterxml.jackson.core:jackson-core:2.18.1") + api("com.fasterxml.jackson.core:jackson-databind:2.18.1") - implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.3") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.3") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3") + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1") implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") @@ -19,8 +18,9 @@ dependencies { testImplementation(project(":onebusaway-sdk-java-client-okhttp")) testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") testImplementation("org.assertj:assertj-core:3.25.3") - testImplementation("org.assertj:assertj-guava:3.25.3") - testImplementation("org.slf4j:slf4j-simple:2.0.12") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.mockito:mockito-core:5.14.2") + testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") + testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") } 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 f930dc9..cdf19c3 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 @@ -13,7 +13,7 @@ constructor( ) : OnebusawaySdkClientAsync { private val clientOptionsWithUserAgent = - if (clientOptions.headers.containsKey("User-Agent")) clientOptions + if (clientOptions.headers.names().contains("User-Agent")) clientOptions else clientOptions .toBuilder() 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 1183849..a5ada81 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 @@ -13,7 +13,7 @@ constructor( ) : OnebusawaySdkClient { private val clientOptionsWithUserAgent = - if (clientOptions.headers.containsKey("User-Agent")) clientOptions + if (clientOptions.headers.names().contains("User-Agent")) clientOptions else clientOptions .toBuilder() 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 370b3f4..7f4054b 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 @@ -3,11 +3,11 @@ package org.onebusaway.core import com.fasterxml.jackson.databind.json.JsonMapper -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.time.Clock +import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient import org.onebusaway.core.http.PhantomReachableClosingHttpClient +import org.onebusaway.core.http.QueryParams import org.onebusaway.core.http.RetryingHttpClient class ClientOptions @@ -17,8 +17,8 @@ private constructor( @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @get:JvmName("baseUrl") val baseUrl: String, - @get:JvmName("headers") val headers: ListMultimap, - @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, @get:JvmName("maxRetries") val maxRetries: Int, @get:JvmName("apiKey") val apiKey: String, @@ -41,8 +41,8 @@ private constructor( private var jsonMapper: JsonMapper = jsonMapper() private var clock: Clock = Clock.systemUTC() private var baseUrl: String = PRODUCTION_URL - private var headers: ListMultimap = ArrayListMultimap.create() - private var queryParams: ListMultimap = ArrayListMultimap.create() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false private var maxRetries: Int = 2 private var apiKey: String? = null @@ -53,8 +53,8 @@ private constructor( jsonMapper = clientOptions.jsonMapper clock = clientOptions.clock baseUrl = clientOptions.baseUrl - headers = ArrayListMultimap.create(clientOptions.headers) - queryParams = ArrayListMultimap.create(clientOptions.queryParams) + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() responseValidation = clientOptions.responseValidation maxRetries = clientOptions.maxRetries apiKey = clientOptions.apiKey @@ -68,6 +68,11 @@ private constructor( fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + fun headers(headers: Map>) = apply { this.headers.clear() putAllHeaders(headers) @@ -75,29 +80,34 @@ private constructor( fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - fun putHeaders(name: String, values: Iterable) = apply { - headers.putAll(name, values) - } + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } fun putAllHeaders(headers: Map>) = apply { - headers.forEach(::putHeaders) + this.headers.putAll(headers) } - fun replaceHeaders(name: String, value: String) = apply { - headers.replaceValues(name, listOf(value)) - } + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replaceValues(name, values) + headers.replace(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + fun replaceAllHeaders(headers: Map>) = apply { - headers.forEach(::replaceHeaders) + this.headers.replaceAll(headers) } - fun removeHeaders(name: String) = apply { headers.removeAll(name) } + fun removeHeaders(name: String) = apply { headers.remove(name) } - fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) } + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -107,28 +117,36 @@ private constructor( fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.putAll(key, values) + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) } fun putAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::putQueryParams) + this.queryParams.putAll(queryParams) } fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replaceValues(key, listOf(value)) + queryParams.replace(key, value) } fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replaceValues(key, values) + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) } fun replaceAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::replaceQueryParams) + this.queryParams.replaceAll(queryParams) } - fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) } + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) } + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -144,8 +162,8 @@ private constructor( checkNotNull(httpClient) { "`httpClient` is required but was not set" } checkNotNull(apiKey) { "`apiKey` is required but was not set" } - val headers = ArrayListMultimap.create() - val queryParams = ArrayListMultimap.create() + val headers = Headers.builder() + val queryParams = QueryParams.builder() headers.put("X-Stainless-Lang", "java") headers.put("X-Stainless-Arch", getOsArch()) headers.put("X-Stainless-OS", getOsName()) @@ -153,11 +171,13 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - if (!apiKey.isNullOrEmpty()) { - queryParams.put("key", apiKey) + apiKey?.let { + if (!it.isEmpty()) { + headers.put("key", it) + } } - this.headers.asMap().forEach(headers::replaceValues) - this.queryParams.asMap().forEach(queryParams::replaceValues) + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) return ClientOptions( httpClient!!, @@ -171,8 +191,8 @@ private constructor( jsonMapper, clock, baseUrl, - headers.toImmutable(), - queryParams.toImmutable(), + headers.build(), + queryParams.build(), responseValidation, maxRetries, apiKey!!, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachable.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachable.kt index e35ca9a..8391e58 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachable.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachable.kt @@ -15,10 +15,20 @@ internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable) check(observed !== closeable) { "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" } - closeWhenPhantomReachable?.let { it(observed, closeable::close) } + closeWhenPhantomReachable(observed, closeable::close) } -private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy { +/** + * Calls [close] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, close: () -> Unit) { + closeWhenPhantomReachable?.let { it(observed, close) } +} + +private val closeWhenPhantomReachable: ((Any, () -> Unit) -> Unit)? by lazy { try { val cleanerClass = Class.forName("java.lang.ref.Cleaner") val cleanerCreate = cleanerClass.getMethod("create") @@ -26,9 +36,9 @@ private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy { cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) val cleanerObject = cleanerCreate.invoke(null); - { observed, closeable -> + { observed, close -> try { - cleanerRegister.invoke(cleanerObject, observed, Runnable { closeable.close() }) + cleanerRegister.invoke(cleanerObject, observed, Runnable { close() }) } catch (e: ReflectiveOperationException) { if (e is InvocationTargetException) { when (val cause = e.cause) { 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 4ccb63c..030a344 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 @@ -2,8 +2,6 @@ package org.onebusaway.core -import com.google.common.collect.ImmutableListMultimap -import com.google.common.collect.ListMultimap import java.util.Collections import java.util.SortedMap import org.onebusaway.errors.OnebusawaySdkInvalidDataException @@ -25,8 +23,4 @@ internal fun , V> SortedMap.toImmutable(): SortedMap ListMultimap.toImmutable(): ListMultimap = - ImmutableListMultimap.copyOf(this) - internal interface Enum diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt index f7938ba..621d820 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt @@ -3,9 +3,9 @@ package org.onebusaway.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper -import com.google.common.collect.ListMultimap import java.io.ByteArrayInputStream import java.io.InputStream +import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpResponse import org.onebusaway.core.http.HttpResponse.Handler import org.onebusaway.errors.BadRequestException @@ -118,7 +118,7 @@ private fun HttpResponse.buffered(): HttpResponse { return object : HttpResponse { override fun statusCode(): Int = this@buffered.statusCode() - override fun headers(): ListMultimap = this@buffered.headers() + override fun headers(): Headers = this@buffered.headers() override fun body(): InputStream = ByteArrayInputStream(body) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt index 9139930..f654c32 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt @@ -1,8 +1,5 @@ package org.onebusaway.core.http -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import com.google.common.collect.MultimapBuilder import org.onebusaway.core.toImmutable class HttpRequest @@ -10,11 +7,13 @@ private constructor( @get:JvmName("method") val method: HttpMethod, @get:JvmName("url") val url: String?, @get:JvmName("pathSegments") val pathSegments: List, - @get:JvmName("headers") val headers: ListMultimap, - @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("body") val body: HttpRequestBody?, ) { + fun toBuilder(): Builder = Builder().from(this) + override fun toString(): String = "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" @@ -27,11 +26,20 @@ private constructor( private var method: HttpMethod? = null private var url: String? = null private var pathSegments: MutableList = mutableListOf() - private var headers: ListMultimap = - MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).arrayListValues().build() - private var queryParams: ListMultimap = ArrayListMultimap.create() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() private var body: HttpRequestBody? = null + @JvmSynthetic + internal fun from(request: HttpRequest) = apply { + method = request.method + url = request.url + pathSegments = request.pathSegments.toMutableList() + headers = request.headers.toBuilder() + queryParams = request.queryParams.toBuilder() + body = request.body + } + fun method(method: HttpMethod) = apply { this.method = method } fun url(url: String) = apply { this.url = url } @@ -42,6 +50,11 @@ private constructor( this.pathSegments.addAll(pathSegments) } + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + fun headers(headers: Map>) = apply { this.headers.clear() putAllHeaders(headers) @@ -49,29 +62,34 @@ private constructor( fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - fun putHeaders(name: String, values: Iterable) = apply { - headers.putAll(name, values) - } + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } fun putAllHeaders(headers: Map>) = apply { - headers.forEach(::putHeaders) + this.headers.putAll(headers) } - fun replaceHeaders(name: String, value: String) = apply { - headers.replaceValues(name, listOf(value)) - } + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replaceValues(name, values) + headers.replace(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + fun replaceAllHeaders(headers: Map>) = apply { - headers.forEach(::replaceHeaders) + this.headers.replaceAll(headers) } - fun removeHeaders(name: String) = apply { headers.removeAll(name) } + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } - fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) } + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -81,28 +99,36 @@ private constructor( fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.putAll(key, values) + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) } fun putAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::putQueryParams) + this.queryParams.putAll(queryParams) } fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replaceValues(key, listOf(value)) + queryParams.replace(key, value) } fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replaceValues(key, values) + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) } fun replaceAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::replaceQueryParams) + this.queryParams.replaceAll(queryParams) } - fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) } + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) } + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } fun body(body: HttpRequestBody) = apply { this.body = body } @@ -111,8 +137,8 @@ private constructor( checkNotNull(method) { "`method` is required but was not set" }, url, pathSegments.toImmutable(), - headers, - queryParams.toImmutable(), + headers.build(), + queryParams.build(), body, ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt index b2870ca..1a3f27d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt @@ -1,6 +1,5 @@ package org.onebusaway.core.http -import com.google.common.collect.ListMultimap import java.io.InputStream import java.lang.AutoCloseable @@ -8,7 +7,7 @@ interface HttpResponse : AutoCloseable { fun statusCode(): Int - fun headers(): ListMultimap + fun headers(): Headers fun body(): InputStream 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 37bc637..fa4ed7a 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 @@ -35,21 +35,22 @@ private constructor( return httpClient.execute(request, requestOptions) } - maybeAddIdempotencyHeader(request) + var modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. - val shouldSendRetryCount = !request.headers.containsKey("x-stainless-retry-count") + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") var retries = 0 while (true) { if (shouldSendRetryCount) { - setRetryCountHeader(request, retries) + modifiedRequest = setRetryCountHeader(modifiedRequest, retries) } val response = try { - val response = httpClient.execute(request, requestOptions) + val response = httpClient.execute(modifiedRequest, requestOptions) if (++retries > maxRetries || !shouldRetry(response)) { return response } @@ -76,10 +77,11 @@ private constructor( return httpClient.executeAsync(request, requestOptions) } - maybeAddIdempotencyHeader(request) + val modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. - val shouldSendRetryCount = !request.headers.containsKey("x-stainless-retry-count") + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") var retries = 0 @@ -87,12 +89,11 @@ private constructor( request: HttpRequest, requestOptions: RequestOptions, ): CompletableFuture { - if (shouldSendRetryCount) { - setRetryCountHeader(request, retries) - } + val requestWithRetryCount = + if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request return httpClient - .executeAsync(request, requestOptions) + .executeAsync(requestWithRetryCount, requestOptions) .handleAsync( fun( response: HttpResponse?, @@ -112,7 +113,7 @@ private constructor( val backoffMillis = getRetryBackoffMillis(retries, response) return sleepAsync(backoffMillis.toMillis()).thenCompose { - executeWithRetries(request, requestOptions) + executeWithRetries(requestWithRetryCount, requestOptions) } }, ) { @@ -122,7 +123,7 @@ private constructor( .thenCompose(Function.identity()) } - return executeWithRetries(request, requestOptions) + return executeWithRetries(modifiedRequest, requestOptions) } override fun close() = httpClient.close() @@ -132,23 +133,26 @@ private constructor( // the body data aren't available on subsequent attempts. request.body?.repeatable() ?: true - private fun setRetryCountHeader(request: HttpRequest, retries: Int) { - request.headers.removeAll("x-stainless-retry-count") - request.headers.put("x-stainless-retry-count", retries.toString()) - } + private fun setRetryCountHeader(request: HttpRequest, retries: Int): HttpRequest = + request.toBuilder().replaceHeaders("X-Stainless-Retry-Count", retries.toString()).build() private fun idempotencyKey(): String = "stainless-java-retry-${UUID.randomUUID()}" - private fun maybeAddIdempotencyHeader(request: HttpRequest) { - if (idempotencyHeader != null && !request.headers.containsKey(idempotencyHeader)) { - // Set a header to uniquely identify the request when retried - request.headers.put(idempotencyHeader, idempotencyKey()) + private fun maybeAddIdempotencyHeader(request: HttpRequest): HttpRequest { + if (idempotencyHeader == null || request.headers.names().contains(idempotencyHeader)) { + return request } + + return request + .toBuilder() + // Set a header to uniquely identify the request when retried. + .putHeader(idempotencyHeader, idempotencyKey()) + .build() } private fun shouldRetry(response: HttpResponse): Boolean { // Note: this is not a standard header - val shouldRetryHeader = response.headers().get("x-should-retry").getOrNull(0) + val shouldRetryHeader = response.headers().values("X-Should-Retry").getOrNull(0) val statusCode = response.statusCode() return when { @@ -181,11 +185,11 @@ private constructor( ?.headers() ?.let { headers -> headers - .get("Retry-After-Ms") + .values("Retry-After-Ms") .getOrNull(0) ?.toFloatOrNull() ?.times(TimeUnit.MILLISECONDS.toNanos(1)) - ?: headers.get("Retry-After").getOrNull(0)?.let { retryAfter -> + ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { ChronoUnit.MILLIS.between( 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 dee8196..036562b 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 @@ -1,9 +1,9 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers class BadRequestException( - headers: ListMultimap, + headers: Headers, body: String, error: OnebusawaySdkError, ) : OnebusawaySdkServiceException(400, headers, body, error) 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 5c3229f..b99d5f0 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 @@ -1,10 +1,10 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers class InternalServerException( statusCode: Int, - headers: ListMultimap, + headers: Headers, body: String, error: OnebusawaySdkError, ) : OnebusawaySdkServiceException(statusCode, headers, body, error) 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 35e69c4..d7215fd 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 @@ -1,9 +1,9 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers class NotFoundException( - headers: ListMultimap, + headers: Headers, body: String, error: OnebusawaySdkError, ) : OnebusawaySdkServiceException(404, headers, body, error) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt index 6f0a191..bc720ae 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt @@ -13,27 +13,13 @@ import org.onebusaway.core.toImmutable @JsonDeserialize(builder = OnebusawaySdkError.Builder::class) @NoAutoDetect class OnebusawaySdkError -constructor( - private val additionalProperties: Map, +private constructor( + @JsonAnyGetter + @get:JvmName("additionalProperties") + val additionalProperties: Map, ) { - @JsonAnyGetter fun additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OnebusawaySdkError && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - - override fun toString() = "OnebusawaySdkError{additionalProperties=$additionalProperties}" + fun toBuilder() = Builder().from(this) companion object { @@ -44,24 +30,43 @@ constructor( private var additionalProperties: MutableMap = mutableMapOf() - fun from(error: OnebusawaySdkError) = apply { - additionalProperties(error.additionalProperties) + @JvmSynthetic + internal fun from(onebusawaySdkError: OnebusawaySdkError) = apply { + additionalProperties = onebusawaySdkError.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): OnebusawaySdkError = OnebusawaySdkError(additionalProperties.toImmutable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OnebusawaySdkError && additionalProperties == other.additionalProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + + override fun toString() = "OnebusawaySdkError{additionalProperties=$additionalProperties}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt index 96d7d2d..e65331d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt @@ -1,12 +1,12 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers abstract class OnebusawaySdkServiceException @JvmOverloads constructor( private val statusCode: Int, - private val headers: ListMultimap, + private val headers: Headers, private val body: String, private val error: OnebusawaySdkError, message: String = "$statusCode: $error", @@ -15,7 +15,7 @@ constructor( fun statusCode(): Int = statusCode - fun headers(): ListMultimap = headers + fun headers(): Headers = headers fun body(): String = body 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 bb06e6a..7c70b0b 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 @@ -1,9 +1,9 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers class PermissionDeniedException( - headers: ListMultimap, + headers: Headers, body: String, error: OnebusawaySdkError, ) : OnebusawaySdkServiceException(403, headers, body, error) 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 c210a32..314ad3b 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 @@ -1,9 +1,9 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers class RateLimitException( - headers: ListMultimap, + headers: Headers, body: String, error: OnebusawaySdkError, ) : OnebusawaySdkServiceException(429, headers, body, error) 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 dc34495..7b6a7a3 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 @@ -1,9 +1,9 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers class UnauthorizedException( - headers: ListMultimap, + headers: Headers, body: String, error: OnebusawaySdkError, ) : OnebusawaySdkServiceException(401, headers, body, error) 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 a54c02d..192fed6 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 @@ -1,10 +1,10 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers class UnexpectedStatusCodeException( statusCode: Int, - headers: ListMultimap, + headers: Headers, body: String, error: OnebusawaySdkError, ) : OnebusawaySdkServiceException(statusCode, headers, body, error) 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 a30211a..bc0e0a7 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 @@ -1,9 +1,9 @@ package org.onebusaway.errors -import com.google.common.collect.ListMultimap +import org.onebusaway.core.http.Headers class UnprocessableEntityException( - headers: ListMultimap, + headers: Headers, body: String, error: OnebusawaySdkError, ) : OnebusawaySdkServiceException(422, headers, body, error) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt index 6e8ed63..cd6b74f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt @@ -2,41 +2,25 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class AgenciesWithCoverageListParams constructor( - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AgenciesWithCoverageListParams && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "AgenciesWithCoverageListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -48,13 +32,18 @@ constructor( @NoAutoDetect class Builder { - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(agenciesWithCoverageListParams: AgenciesWithCoverageListParams) = apply { - additionalHeaders(agenciesWithCoverageListParams.additionalHeaders) - additionalQueryParams(agenciesWithCoverageListParams.additionalQueryParams) + additionalHeaders = agenciesWithCoverageListParams.additionalHeaders.toBuilder() + additionalQueryParams = agenciesWithCoverageListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } fun additionalHeaders(additionalHeaders: Map>) = apply { @@ -67,29 +56,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -102,45 +104,55 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): AgenciesWithCoverageListParams = - AgenciesWithCoverageListParams( - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable() - ) + AgenciesWithCoverageListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AgenciesWithCoverageListParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AgenciesWithCoverageListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt index 0349ee9..52b2d3a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt @@ -393,17 +393,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.agencyId == other.agencyId && this.lat == other.lat && this.latSpan == other.latSpan && this.lon == other.lon && this.lonSpan == other.lonSpan && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && agencyId == other.agencyId && lat == other.lat && latSpan == other.latSpan && lon == other.lon && lonSpan == other.lonSpan && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, lat, latSpan, lon, lonSpan, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, lat, latSpan, lon, lonSpan, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{agencyId=$agencyId, lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, additionalProperties=$additionalProperties}" @@ -414,17 +411,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" @@ -435,17 +429,14 @@ private constructor( return true } - return /* spotless:off */ other is AgenciesWithCoverageListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AgenciesWithCoverageListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AgenciesWithCoverageListResponse{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/AgencyRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt index 69a140e..69a633c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class AgencyRetrieveParams constructor( private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun agencyId(): String = agencyId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AgencyRetrieveParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "AgencyRetrieveParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(agencyRetrieveParams: AgencyRetrieveParams) = apply { - this.agencyId = agencyRetrieveParams.agencyId - additionalHeaders(agencyRetrieveParams.additionalHeaders) - additionalQueryParams(agencyRetrieveParams.additionalQueryParams) + agencyId = agencyRetrieveParams.agencyId + additionalHeaders = agencyRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = agencyRetrieveParams.additionalQueryParams.toBuilder() } fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): AgencyRetrieveParams = AgencyRetrieveParams( checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AgencyRetrieveParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AgencyRetrieveParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt index 3dbad5f..a4c9fa4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt @@ -475,17 +475,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.disclaimer == other.disclaimer && this.email == other.email && this.fareUrl == other.fareUrl && this.id == other.id && this.lang == other.lang && this.name == other.name && this.phone == other.phone && this.privateService == other.privateService && this.timezone == other.timezone && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && id == other.id && lang == other.lang && name == other.name && phone == other.phone && privateService == other.privateService && timezone == other.timezone && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(disclaimer, email, fareUrl, id, lang, name, phone, privateService, timezone, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(disclaimer, email, fareUrl, id, lang, name, phone, privateService, timezone, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, id=$id, lang=$lang, name=$name, phone=$phone, privateService=$privateService, timezone=$timezone, url=$url, additionalProperties=$additionalProperties}" @@ -496,17 +493,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -517,17 +511,14 @@ private constructor( return true } - return /* spotless:off */ other is AgencyRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AgencyRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AgencyRetrieveResponse{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/ArrivalAndDepartureListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt index 10d7678..9bdb475 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt @@ -2,14 +2,13 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.time.OffsetDateTime import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ArrivalAndDepartureListParams @@ -18,8 +17,8 @@ constructor( private val minutesAfter: Long?, private val minutesBefore: Long?, private val time: OffsetDateTime?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun stopId(): String = stopId @@ -30,18 +29,22 @@ constructor( fun time(): Optional = Optional.ofNullable(time) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.minutesAfter?.let { params.put("minutesAfter", listOf(it.toString())) } - this.minutesBefore?.let { params.put("minutesBefore", listOf(it.toString())) } + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.minutesAfter?.let { queryParams.put("minutesAfter", listOf(it.toString())) } + this.minutesBefore?.let { queryParams.put("minutesBefore", listOf(it.toString())) } this.time?.let { - params.put("time", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) + queryParams.put("time", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) } - params.putAll(additionalQueryParams) - return params.toImmutable() + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -51,25 +54,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ArrivalAndDepartureListParams && this.stopId == other.stopId && this.minutesAfter == other.minutesAfter && this.minutesBefore == other.minutesBefore && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, minutesAfter, minutesBefore, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ArrivalAndDepartureListParams{stopId=$stopId, minutesAfter=$minutesAfter, minutesBefore=$minutesBefore, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -84,17 +68,17 @@ constructor( private var minutesAfter: Long? = null private var minutesBefore: Long? = null private var time: OffsetDateTime? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(arrivalAndDepartureListParams: ArrivalAndDepartureListParams) = apply { - this.stopId = arrivalAndDepartureListParams.stopId - this.minutesAfter = arrivalAndDepartureListParams.minutesAfter - this.minutesBefore = arrivalAndDepartureListParams.minutesBefore - this.time = arrivalAndDepartureListParams.time - additionalHeaders(arrivalAndDepartureListParams.additionalHeaders) - additionalQueryParams(arrivalAndDepartureListParams.additionalQueryParams) + stopId = arrivalAndDepartureListParams.stopId + minutesAfter = arrivalAndDepartureListParams.minutesAfter + minutesBefore = arrivalAndDepartureListParams.minutesBefore + time = arrivalAndDepartureListParams.time + additionalHeaders = arrivalAndDepartureListParams.additionalHeaders.toBuilder() + additionalQueryParams = arrivalAndDepartureListParams.additionalQueryParams.toBuilder() } fun stopId(stopId: String) = apply { this.stopId = stopId } @@ -108,6 +92,11 @@ constructor( /** The specific time for querying the system status. */ fun time(time: OffsetDateTime) = apply { this.time = time } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -118,29 +107,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -153,33 +155,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ArrivalAndDepartureListParams = @@ -188,14 +196,21 @@ constructor( minutesAfter, minutesBefore, time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ArrivalAndDepartureListParams && stopId == other.stopId && minutesAfter == other.minutesAfter && minutesBefore == other.minutesBefore && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, minutesAfter, minutesBefore, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ArrivalAndDepartureListParams{stopId=$stopId, minutesAfter=$minutesAfter, minutesBefore=$minutesBefore, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt index 1bd13ba..9db8dcc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt @@ -2206,17 +2206,14 @@ private constructor( return true } - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -2323,17 +2320,14 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -2344,17 +2338,14 @@ private constructor( return true } - return /* spotless:off */ other is TripStatus && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -2365,17 +2356,14 @@ private constructor( return true } - return /* spotless:off */ other is ArrivalsAndDeparture && this.actualTrack == other.actualTrack && this.arrivalEnabled == other.arrivalEnabled && this.blockTripSequence == other.blockTripSequence && this.departureEnabled == other.departureEnabled && this.distanceFromStop == other.distanceFromStop && this.frequency == other.frequency && this.historicalOccupancy == other.historicalOccupancy && this.lastUpdateTime == other.lastUpdateTime && this.numberOfStopsAway == other.numberOfStopsAway && this.occupancyStatus == other.occupancyStatus && this.predicted == other.predicted && this.predictedArrivalInterval == other.predictedArrivalInterval && this.predictedArrivalTime == other.predictedArrivalTime && this.predictedDepartureInterval == other.predictedDepartureInterval && this.predictedDepartureTime == other.predictedDepartureTime && this.predictedOccupancy == other.predictedOccupancy && this.routeId == other.routeId && this.routeLongName == other.routeLongName && this.routeShortName == other.routeShortName && this.scheduledArrivalInterval == other.scheduledArrivalInterval && this.scheduledArrivalTime == other.scheduledArrivalTime && this.scheduledDepartureInterval == other.scheduledDepartureInterval && this.scheduledDepartureTime == other.scheduledDepartureTime && this.scheduledTrack == other.scheduledTrack && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.stopId == other.stopId && this.stopSequence == other.stopSequence && this.totalStopsInTrip == other.totalStopsInTrip && this.tripHeadsign == other.tripHeadsign && this.tripId == other.tripId && this.tripStatus == other.tripStatus && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ArrivalsAndDeparture && actualTrack == other.actualTrack && arrivalEnabled == other.arrivalEnabled && blockTripSequence == other.blockTripSequence && departureEnabled == other.departureEnabled && distanceFromStop == other.distanceFromStop && frequency == other.frequency && historicalOccupancy == other.historicalOccupancy && lastUpdateTime == other.lastUpdateTime && numberOfStopsAway == other.numberOfStopsAway && occupancyStatus == other.occupancyStatus && predicted == other.predicted && predictedArrivalInterval == other.predictedArrivalInterval && predictedArrivalTime == other.predictedArrivalTime && predictedDepartureInterval == other.predictedDepartureInterval && predictedDepartureTime == other.predictedDepartureTime && predictedOccupancy == other.predictedOccupancy && routeId == other.routeId && routeLongName == other.routeLongName && routeShortName == other.routeShortName && scheduledArrivalInterval == other.scheduledArrivalInterval && scheduledArrivalTime == other.scheduledArrivalTime && scheduledDepartureInterval == other.scheduledDepartureInterval && scheduledDepartureTime == other.scheduledDepartureTime && scheduledTrack == other.scheduledTrack && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && stopId == other.stopId && stopSequence == other.stopSequence && totalStopsInTrip == other.totalStopsInTrip && tripHeadsign == other.tripHeadsign && tripId == other.tripId && tripStatus == other.tripStatus && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(actualTrack, arrivalEnabled, blockTripSequence, departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, predictedArrivalTime, predictedDepartureInterval, predictedDepartureTime, predictedOccupancy, routeId, routeLongName, routeShortName, scheduledArrivalInterval, scheduledArrivalTime, scheduledDepartureInterval, scheduledDepartureTime, scheduledTrack, serviceDate, situationIds, status, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, tripStatus, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(actualTrack, arrivalEnabled, blockTripSequence, departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, predictedArrivalTime, predictedDepartureInterval, predictedDepartureTime, predictedOccupancy, routeId, routeLongName, routeShortName, scheduledArrivalInterval, scheduledArrivalTime, scheduledDepartureInterval, scheduledDepartureTime, scheduledTrack, serviceDate, situationIds, status, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, tripStatus, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ArrivalsAndDeparture{actualTrack=$actualTrack, arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, numberOfStopsAway=$numberOfStopsAway, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedArrivalTime=$predictedArrivalTime, predictedDepartureInterval=$predictedDepartureInterval, predictedDepartureTime=$predictedDepartureTime, predictedOccupancy=$predictedOccupancy, routeId=$routeId, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledDepartureTime=$scheduledDepartureTime, scheduledTrack=$scheduledTrack, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, tripStatus=$tripStatus, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -2386,17 +2374,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.arrivalsAndDepartures == other.arrivalsAndDepartures && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && arrivalsAndDepartures == other.arrivalsAndDepartures && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalsAndDepartures, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalsAndDepartures, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{arrivalsAndDepartures=$arrivalsAndDepartures, additionalProperties=$additionalProperties}" @@ -2407,17 +2392,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -2428,17 +2410,14 @@ private constructor( return true } - return /* spotless:off */ other is ArrivalAndDepartureListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ArrivalAndDepartureListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ArrivalAndDepartureListResponse{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/ArrivalAndDepartureRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt index a4890f6..e84785b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt @@ -2,12 +2,11 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ArrivalAndDepartureRetrieveParams @@ -18,8 +17,8 @@ constructor( private val stopSequence: Long?, private val time: Long?, private val vehicleId: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun stopId(): String = stopId @@ -34,18 +33,22 @@ constructor( fun vehicleId(): Optional = Optional.ofNullable(vehicleId) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.serviceDate.let { params.put("serviceDate", listOf(it.toString())) } - this.tripId.let { params.put("tripId", listOf(it.toString())) } - this.stopSequence?.let { params.put("stopSequence", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - this.vehicleId?.let { params.put("vehicleId", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.serviceDate.let { queryParams.put("serviceDate", listOf(it.toString())) } + this.tripId.let { queryParams.put("tripId", listOf(it.toString())) } + this.stopSequence?.let { queryParams.put("stopSequence", listOf(it.toString())) } + this.time?.let { queryParams.put("time", listOf(it.toString())) } + this.vehicleId?.let { queryParams.put("vehicleId", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -55,25 +58,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ArrivalAndDepartureRetrieveParams && this.stopId == other.stopId && this.serviceDate == other.serviceDate && this.tripId == other.tripId && this.stopSequence == other.stopSequence && this.time == other.time && this.vehicleId == other.vehicleId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, serviceDate, tripId, stopSequence, time, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ArrivalAndDepartureRetrieveParams{stopId=$stopId, serviceDate=$serviceDate, tripId=$tripId, stopSequence=$stopSequence, time=$time, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -90,20 +74,21 @@ constructor( private var stopSequence: Long? = null private var time: Long? = null private var vehicleId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(arrivalAndDepartureRetrieveParams: ArrivalAndDepartureRetrieveParams) = apply { - this.stopId = arrivalAndDepartureRetrieveParams.stopId - this.serviceDate = arrivalAndDepartureRetrieveParams.serviceDate - this.tripId = arrivalAndDepartureRetrieveParams.tripId - this.stopSequence = arrivalAndDepartureRetrieveParams.stopSequence - this.time = arrivalAndDepartureRetrieveParams.time - this.vehicleId = arrivalAndDepartureRetrieveParams.vehicleId - additionalHeaders(arrivalAndDepartureRetrieveParams.additionalHeaders) - additionalQueryParams(arrivalAndDepartureRetrieveParams.additionalQueryParams) + stopId = arrivalAndDepartureRetrieveParams.stopId + serviceDate = arrivalAndDepartureRetrieveParams.serviceDate + tripId = arrivalAndDepartureRetrieveParams.tripId + stopSequence = arrivalAndDepartureRetrieveParams.stopSequence + time = arrivalAndDepartureRetrieveParams.time + vehicleId = arrivalAndDepartureRetrieveParams.vehicleId + additionalHeaders = arrivalAndDepartureRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = + arrivalAndDepartureRetrieveParams.additionalQueryParams.toBuilder() } fun stopId(stopId: String) = apply { this.stopId = stopId } @@ -118,6 +103,11 @@ constructor( fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -128,29 +118,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -163,33 +166,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ArrivalAndDepartureRetrieveParams = @@ -200,14 +209,21 @@ constructor( stopSequence, time, vehicleId, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ArrivalAndDepartureRetrieveParams && stopId == other.stopId && serviceDate == other.serviceDate && tripId == other.tripId && stopSequence == other.stopSequence && time == other.time && vehicleId == other.vehicleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, serviceDate, tripId, stopSequence, time, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ArrivalAndDepartureRetrieveParams{stopId=$stopId, serviceDate=$serviceDate, tripId=$tripId, stopSequence=$stopSequence, time=$time, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt index eaa7107..4db9cf3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt @@ -2053,17 +2053,14 @@ private constructor( return true } - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -2170,17 +2167,14 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -2191,17 +2185,14 @@ private constructor( return true } - return /* spotless:off */ other is TripStatus && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -2212,17 +2203,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.actualTrack == other.actualTrack && this.arrivalEnabled == other.arrivalEnabled && this.blockTripSequence == other.blockTripSequence && this.departureEnabled == other.departureEnabled && this.distanceFromStop == other.distanceFromStop && this.frequency == other.frequency && this.historicalOccupancy == other.historicalOccupancy && this.lastUpdateTime == other.lastUpdateTime && this.numberOfStopsAway == other.numberOfStopsAway && this.occupancyStatus == other.occupancyStatus && this.predicted == other.predicted && this.predictedArrivalInterval == other.predictedArrivalInterval && this.predictedArrivalTime == other.predictedArrivalTime && this.predictedDepartureInterval == other.predictedDepartureInterval && this.predictedDepartureTime == other.predictedDepartureTime && this.predictedOccupancy == other.predictedOccupancy && this.routeId == other.routeId && this.routeLongName == other.routeLongName && this.routeShortName == other.routeShortName && this.scheduledArrivalInterval == other.scheduledArrivalInterval && this.scheduledArrivalTime == other.scheduledArrivalTime && this.scheduledDepartureInterval == other.scheduledDepartureInterval && this.scheduledDepartureTime == other.scheduledDepartureTime && this.scheduledTrack == other.scheduledTrack && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.stopId == other.stopId && this.stopSequence == other.stopSequence && this.totalStopsInTrip == other.totalStopsInTrip && this.tripHeadsign == other.tripHeadsign && this.tripId == other.tripId && this.tripStatus == other.tripStatus && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && actualTrack == other.actualTrack && arrivalEnabled == other.arrivalEnabled && blockTripSequence == other.blockTripSequence && departureEnabled == other.departureEnabled && distanceFromStop == other.distanceFromStop && frequency == other.frequency && historicalOccupancy == other.historicalOccupancy && lastUpdateTime == other.lastUpdateTime && numberOfStopsAway == other.numberOfStopsAway && occupancyStatus == other.occupancyStatus && predicted == other.predicted && predictedArrivalInterval == other.predictedArrivalInterval && predictedArrivalTime == other.predictedArrivalTime && predictedDepartureInterval == other.predictedDepartureInterval && predictedDepartureTime == other.predictedDepartureTime && predictedOccupancy == other.predictedOccupancy && routeId == other.routeId && routeLongName == other.routeLongName && routeShortName == other.routeShortName && scheduledArrivalInterval == other.scheduledArrivalInterval && scheduledArrivalTime == other.scheduledArrivalTime && scheduledDepartureInterval == other.scheduledDepartureInterval && scheduledDepartureTime == other.scheduledDepartureTime && scheduledTrack == other.scheduledTrack && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && stopId == other.stopId && stopSequence == other.stopSequence && totalStopsInTrip == other.totalStopsInTrip && tripHeadsign == other.tripHeadsign && tripId == other.tripId && tripStatus == other.tripStatus && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(actualTrack, arrivalEnabled, blockTripSequence, departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, predictedArrivalTime, predictedDepartureInterval, predictedDepartureTime, predictedOccupancy, routeId, routeLongName, routeShortName, scheduledArrivalInterval, scheduledArrivalTime, scheduledDepartureInterval, scheduledDepartureTime, scheduledTrack, serviceDate, situationIds, status, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, tripStatus, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(actualTrack, arrivalEnabled, blockTripSequence, departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, predictedArrivalTime, predictedDepartureInterval, predictedDepartureTime, predictedOccupancy, routeId, routeLongName, routeShortName, scheduledArrivalInterval, scheduledArrivalTime, scheduledDepartureInterval, scheduledDepartureTime, scheduledTrack, serviceDate, situationIds, status, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, tripStatus, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{actualTrack=$actualTrack, arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, numberOfStopsAway=$numberOfStopsAway, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedArrivalTime=$predictedArrivalTime, predictedDepartureInterval=$predictedDepartureInterval, predictedDepartureTime=$predictedDepartureTime, predictedOccupancy=$predictedOccupancy, routeId=$routeId, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledDepartureTime=$scheduledDepartureTime, scheduledTrack=$scheduledTrack, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, tripStatus=$tripStatus, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -2233,17 +2221,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -2254,17 +2239,14 @@ private constructor( return true } - return /* spotless:off */ other is ArrivalAndDepartureRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ArrivalAndDepartureRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ArrivalAndDepartureRetrieveResponse{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/BlockRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt index 58536ee..a670734 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class BlockRetrieveParams constructor( private val blockId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun blockId(): String = blockId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BlockRetrieveParams && this.blockId == other.blockId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(blockId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "BlockRetrieveParams{blockId=$blockId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var blockId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(blockRetrieveParams: BlockRetrieveParams) = apply { - this.blockId = blockRetrieveParams.blockId - additionalHeaders(blockRetrieveParams.additionalHeaders) - additionalQueryParams(blockRetrieveParams.additionalQueryParams) + blockId = blockRetrieveParams.blockId + additionalHeaders = blockRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = blockRetrieveParams.additionalQueryParams.toBuilder() } fun blockId(blockId: String) = apply { this.blockId = blockId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): BlockRetrieveParams = BlockRetrieveParams( checkNotNull(blockId) { "`blockId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BlockRetrieveParams && blockId == other.blockId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(blockId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "BlockRetrieveParams{blockId=$blockId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt index fc59f55..8b9b6b4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt @@ -878,17 +878,14 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && this.stopId == other.stopId && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.pickupType == other.pickupType && this.dropOffType == other.dropOffType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && stopId == other.stopId && arrivalTime == other.arrivalTime && departureTime == other.departureTime && pickupType == other.pickupType && dropOffType == other.dropOffType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(stopId, arrivalTime, departureTime, pickupType, dropOffType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(stopId, arrivalTime, departureTime, pickupType, dropOffType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTime{stopId=$stopId, arrivalTime=$arrivalTime, departureTime=$departureTime, pickupType=$pickupType, dropOffType=$dropOffType, additionalProperties=$additionalProperties}" @@ -899,17 +896,14 @@ private constructor( return true } - return /* spotless:off */ other is BlockStopTime && this.blockSequence == other.blockSequence && this.distanceAlongBlock == other.distanceAlongBlock && this.accumulatedSlackTime == other.accumulatedSlackTime && this.stopTime == other.stopTime && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BlockStopTime && blockSequence == other.blockSequence && distanceAlongBlock == other.distanceAlongBlock && accumulatedSlackTime == other.accumulatedSlackTime && stopTime == other.stopTime && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(blockSequence, distanceAlongBlock, accumulatedSlackTime, stopTime, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(blockSequence, distanceAlongBlock, accumulatedSlackTime, stopTime, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "BlockStopTime{blockSequence=$blockSequence, distanceAlongBlock=$distanceAlongBlock, accumulatedSlackTime=$accumulatedSlackTime, stopTime=$stopTime, additionalProperties=$additionalProperties}" @@ -920,17 +914,14 @@ private constructor( return true } - return /* spotless:off */ other is Trip && this.tripId == other.tripId && this.distanceAlongBlock == other.distanceAlongBlock && this.accumulatedSlackTime == other.accumulatedSlackTime && this.blockStopTimes == other.blockStopTimes && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Trip && tripId == other.tripId && distanceAlongBlock == other.distanceAlongBlock && accumulatedSlackTime == other.accumulatedSlackTime && blockStopTimes == other.blockStopTimes && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tripId, distanceAlongBlock, accumulatedSlackTime, blockStopTimes, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(tripId, distanceAlongBlock, accumulatedSlackTime, blockStopTimes, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Trip{tripId=$tripId, distanceAlongBlock=$distanceAlongBlock, accumulatedSlackTime=$accumulatedSlackTime, blockStopTimes=$blockStopTimes, additionalProperties=$additionalProperties}" @@ -941,17 +932,14 @@ private constructor( return true } - return /* spotless:off */ other is Configuration && this.activeServiceIds == other.activeServiceIds && this.inactiveServiceIds == other.inactiveServiceIds && this.trips == other.trips && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Configuration && activeServiceIds == other.activeServiceIds && inactiveServiceIds == other.inactiveServiceIds && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeServiceIds, inactiveServiceIds, trips, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeServiceIds, inactiveServiceIds, trips, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Configuration{activeServiceIds=$activeServiceIds, inactiveServiceIds=$inactiveServiceIds, trips=$trips, additionalProperties=$additionalProperties}" @@ -962,17 +950,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.id == other.id && this.configurations == other.configurations && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && id == other.id && configurations == other.configurations && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, configurations, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, configurations, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{id=$id, configurations=$configurations, additionalProperties=$additionalProperties}" @@ -983,17 +968,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -1004,17 +986,14 @@ private constructor( return true } - return /* spotless:off */ other is BlockRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BlockRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "BlockRetrieveResponse{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/ConfigRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt index 411d31f..92577ea 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt @@ -2,41 +2,25 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ConfigRetrieveParams constructor( - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ConfigRetrieveParams && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ConfigRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -48,13 +32,18 @@ constructor( @NoAutoDetect class Builder { - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(configRetrieveParams: ConfigRetrieveParams) = apply { - additionalHeaders(configRetrieveParams.additionalHeaders) - additionalQueryParams(configRetrieveParams.additionalQueryParams) + additionalHeaders = configRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = configRetrieveParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } fun additionalHeaders(additionalHeaders: Map>) = apply { @@ -67,29 +56,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -102,45 +104,55 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ConfigRetrieveParams = - ConfigRetrieveParams( - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable() - ) + ConfigRetrieveParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ConfigRetrieveParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ConfigRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt index 22b23c2..dc1d823 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt @@ -854,17 +854,14 @@ private constructor( return true } - return /* spotless:off */ other is GitProperties && this.gitBranch == other.gitBranch && this.gitBuildHost == other.gitBuildHost && this.gitBuildTime == other.gitBuildTime && this.gitBuildUserEmail == other.gitBuildUserEmail && this.gitBuildUserName == other.gitBuildUserName && this.gitBuildVersion == other.gitBuildVersion && this.gitClosestTagCommitCount == other.gitClosestTagCommitCount && this.gitClosestTagName == other.gitClosestTagName && this.gitCommitId == other.gitCommitId && this.gitCommitIdAbbrev == other.gitCommitIdAbbrev && this.gitCommitIdDescribe == other.gitCommitIdDescribe && this.gitCommitIdDescribeShort == other.gitCommitIdDescribeShort && this.gitCommitMessageFull == other.gitCommitMessageFull && this.gitCommitMessageShort == other.gitCommitMessageShort && this.gitCommitTime == other.gitCommitTime && this.gitCommitUserEmail == other.gitCommitUserEmail && this.gitCommitUserName == other.gitCommitUserName && this.gitDirty == other.gitDirty && this.gitRemoteOriginUrl == other.gitRemoteOriginUrl && this.gitTags == other.gitTags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GitProperties && gitBranch == other.gitBranch && gitBuildHost == other.gitBuildHost && gitBuildTime == other.gitBuildTime && gitBuildUserEmail == other.gitBuildUserEmail && gitBuildUserName == other.gitBuildUserName && gitBuildVersion == other.gitBuildVersion && gitClosestTagCommitCount == other.gitClosestTagCommitCount && gitClosestTagName == other.gitClosestTagName && gitCommitId == other.gitCommitId && gitCommitIdAbbrev == other.gitCommitIdAbbrev && gitCommitIdDescribe == other.gitCommitIdDescribe && gitCommitIdDescribeShort == other.gitCommitIdDescribeShort && gitCommitMessageFull == other.gitCommitMessageFull && gitCommitMessageShort == other.gitCommitMessageShort && gitCommitTime == other.gitCommitTime && gitCommitUserEmail == other.gitCommitUserEmail && gitCommitUserName == other.gitCommitUserName && gitDirty == other.gitDirty && gitRemoteOriginUrl == other.gitRemoteOriginUrl && gitTags == other.gitTags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(gitBranch, gitBuildHost, gitBuildTime, gitBuildUserEmail, gitBuildUserName, gitBuildVersion, gitClosestTagCommitCount, gitClosestTagName, gitCommitId, gitCommitIdAbbrev, gitCommitIdDescribe, gitCommitIdDescribeShort, gitCommitMessageFull, gitCommitMessageShort, gitCommitTime, gitCommitUserEmail, gitCommitUserName, gitDirty, gitRemoteOriginUrl, gitTags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(gitBranch, gitBuildHost, gitBuildTime, gitBuildUserEmail, gitBuildUserName, gitBuildVersion, gitClosestTagCommitCount, gitClosestTagName, gitCommitId, gitCommitIdAbbrev, gitCommitIdDescribe, gitCommitIdDescribeShort, gitCommitMessageFull, gitCommitMessageShort, gitCommitTime, gitCommitUserEmail, gitCommitUserName, gitDirty, gitRemoteOriginUrl, gitTags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "GitProperties{gitBranch=$gitBranch, gitBuildHost=$gitBuildHost, gitBuildTime=$gitBuildTime, gitBuildUserEmail=$gitBuildUserEmail, gitBuildUserName=$gitBuildUserName, gitBuildVersion=$gitBuildVersion, gitClosestTagCommitCount=$gitClosestTagCommitCount, gitClosestTagName=$gitClosestTagName, gitCommitId=$gitCommitId, gitCommitIdAbbrev=$gitCommitIdAbbrev, gitCommitIdDescribe=$gitCommitIdDescribe, gitCommitIdDescribeShort=$gitCommitIdDescribeShort, gitCommitMessageFull=$gitCommitMessageFull, gitCommitMessageShort=$gitCommitMessageShort, gitCommitTime=$gitCommitTime, gitCommitUserEmail=$gitCommitUserEmail, gitCommitUserName=$gitCommitUserName, gitDirty=$gitDirty, gitRemoteOriginUrl=$gitRemoteOriginUrl, gitTags=$gitTags, additionalProperties=$additionalProperties}" @@ -875,17 +872,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.gitProperties == other.gitProperties && this.id == other.id && this.name == other.name && this.serviceDateFrom == other.serviceDateFrom && this.serviceDateTo == other.serviceDateTo && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && gitProperties == other.gitProperties && id == other.id && name == other.name && serviceDateFrom == other.serviceDateFrom && serviceDateTo == other.serviceDateTo && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(gitProperties, id, name, serviceDateFrom, serviceDateTo, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(gitProperties, id, name, serviceDateFrom, serviceDateTo, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{gitProperties=$gitProperties, id=$id, name=$name, serviceDateFrom=$serviceDateFrom, serviceDateTo=$serviceDateTo, additionalProperties=$additionalProperties}" @@ -896,17 +890,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -917,17 +908,14 @@ private constructor( return true } - return /* spotless:off */ other is ConfigRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ConfigRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ConfigRetrieveResponse{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/CurrentTimeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt index 8cefdb2..6d03116 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt @@ -2,41 +2,25 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class CurrentTimeRetrieveParams constructor( - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CurrentTimeRetrieveParams && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "CurrentTimeRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -48,13 +32,18 @@ constructor( @NoAutoDetect class Builder { - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(currentTimeRetrieveParams: CurrentTimeRetrieveParams) = apply { - additionalHeaders(currentTimeRetrieveParams.additionalHeaders) - additionalQueryParams(currentTimeRetrieveParams.additionalQueryParams) + additionalHeaders = currentTimeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = currentTimeRetrieveParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } fun additionalHeaders(additionalHeaders: Map>) = apply { @@ -67,29 +56,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -102,45 +104,55 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): CurrentTimeRetrieveParams = - CurrentTimeRetrieveParams( - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable() - ) + CurrentTimeRetrieveParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CurrentTimeRetrieveParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "CurrentTimeRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt index a1499d6..1df37ab 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt @@ -334,17 +334,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.readableTime == other.readableTime && this.time == other.time && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && readableTime == other.readableTime && time == other.time && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(readableTime, time, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(readableTime, time, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{readableTime=$readableTime, time=$time, additionalProperties=$additionalProperties}" @@ -355,17 +352,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -376,17 +370,14 @@ private constructor( return true } - return /* spotless:off */ other is CurrentTimeRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CurrentTimeRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "CurrentTimeRetrieveResponse{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/References.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt index 698d6d7..3c52cf4 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 @@ -380,17 +380,14 @@ private constructor( return true } - return /* spotless:off */ other is Agency && this.disclaimer == other.disclaimer && this.email == other.email && this.fareUrl == other.fareUrl && this.id == other.id && this.lang == other.lang && this.name == other.name && this.phone == other.phone && this.privateService == other.privateService && this.timezone == other.timezone && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Agency && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && id == other.id && lang == other.lang && name == other.name && phone == other.phone && privateService == other.privateService && timezone == other.timezone && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(disclaimer, email, fareUrl, id, lang, name, phone, privateService, timezone, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(disclaimer, email, fareUrl, id, lang, name, phone, privateService, timezone, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Agency{disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, id=$id, lang=$lang, name=$name, phone=$phone, privateService=$privateService, timezone=$timezone, url=$url, additionalProperties=$additionalProperties}" @@ -615,17 +612,14 @@ private constructor( return true } - return /* spotless:off */ other is Route && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Route && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Route{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" @@ -1013,17 +1007,14 @@ private constructor( return true } - return /* spotless:off */ other is ActiveWindow && this.from == other.from && this.to == other.to && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ActiveWindow && from == other.from && to == other.to && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(from, to, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(from, to, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ActiveWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" @@ -1211,17 +1202,14 @@ private constructor( return true } - return /* spotless:off */ other is AllAffect && this.agencyId == other.agencyId && this.applicationId == other.applicationId && this.directionId == other.directionId && this.routeId == other.routeId && this.stopId == other.stopId && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AllAffect && agencyId == other.agencyId && applicationId == other.applicationId && directionId == other.directionId && routeId == other.routeId && stopId == other.stopId && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, applicationId, directionId, routeId, stopId, tripId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, applicationId, directionId, routeId, stopId, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AllAffect{agencyId=$agencyId, applicationId=$applicationId, directionId=$directionId, routeId=$routeId, stopId=$stopId, tripId=$tripId, additionalProperties=$additionalProperties}" @@ -1541,17 +1529,14 @@ private constructor( return true } - return /* spotless:off */ other is DiversionPath && this.length == other.length && this.levels == other.levels && this.points == other.points && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DiversionPath && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(length, levels, points, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DiversionPath{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" @@ -1562,17 +1547,14 @@ private constructor( return true } - return /* spotless:off */ other is ConditionDetails && this.diversionPath == other.diversionPath && this.diversionStopIds == other.diversionStopIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ConditionDetails && diversionPath == other.diversionPath && diversionStopIds == other.diversionStopIds && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(diversionPath, diversionStopIds, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(diversionPath, diversionStopIds, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ConditionDetails{diversionPath=$diversionPath, diversionStopIds=$diversionStopIds, additionalProperties=$additionalProperties}" @@ -1583,17 +1565,14 @@ private constructor( return true } - return /* spotless:off */ other is Consequence && this.condition == other.condition && this.conditionDetails == other.conditionDetails && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Consequence && condition == other.condition && conditionDetails == other.conditionDetails && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(condition, conditionDetails, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(condition, conditionDetails, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Consequence{condition=$condition, conditionDetails=$conditionDetails, additionalProperties=$additionalProperties}" @@ -1698,17 +1677,14 @@ private constructor( return true } - return /* spotless:off */ other is Description && this.lang == other.lang && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Description && lang == other.lang && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lang, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Description{lang=$lang, value=$value, additionalProperties=$additionalProperties}" @@ -1813,17 +1789,14 @@ private constructor( return true } - return /* spotless:off */ other is PublicationWindow && this.from == other.from && this.to == other.to && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PublicationWindow && from == other.from && to == other.to && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(from, to, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(from, to, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PublicationWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" @@ -1842,7 +1815,7 @@ private constructor( return true } - return /* spotless:off */ other is Reason && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Reason && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2003,17 +1976,14 @@ private constructor( return true } - return /* spotless:off */ other is Summary && this.lang == other.lang && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Summary && lang == other.lang && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lang, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Summary{lang=$lang, value=$value, additionalProperties=$additionalProperties}" @@ -2118,17 +2088,14 @@ private constructor( return true } - return /* spotless:off */ other is Url && this.lang == other.lang && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Url && lang == other.lang && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lang, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Url{lang=$lang, value=$value, additionalProperties=$additionalProperties}" @@ -2139,17 +2106,14 @@ private constructor( return true } - return /* spotless:off */ other is Situation && this.id == other.id && this.creationTime == other.creationTime && this.reason == other.reason && this.summary == other.summary && this.description == other.description && this.url == other.url && this.activeWindows == other.activeWindows && this.allAffects == other.allAffects && this.consequences == other.consequences && this.publicationWindows == other.publicationWindows && this.severity == other.severity && this.consequenceMessage == other.consequenceMessage && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Situation && id == other.id && creationTime == other.creationTime && reason == other.reason && summary == other.summary && description == other.description && url == other.url && activeWindows == other.activeWindows && allAffects == other.allAffects && consequences == other.consequences && publicationWindows == other.publicationWindows && severity == other.severity && consequenceMessage == other.consequenceMessage && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creationTime, reason, summary, description, url, activeWindows, allAffects, consequences, publicationWindows, severity, consequenceMessage, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, creationTime, reason, summary, description, url, activeWindows, allAffects, consequences, publicationWindows, severity, consequenceMessage, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Situation{id=$id, creationTime=$creationTime, reason=$reason, summary=$summary, description=$description, url=$url, activeWindows=$activeWindows, allAffects=$allAffects, consequences=$consequences, publicationWindows=$publicationWindows, severity=$severity, consequenceMessage=$consequenceMessage, additionalProperties=$additionalProperties}" @@ -2392,17 +2356,14 @@ private constructor( return true } - return /* spotless:off */ other is Stop && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Stop && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Stop{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" @@ -2577,17 +2538,14 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" @@ -2832,17 +2790,14 @@ private constructor( return true } - return /* spotless:off */ other is Trip && this.blockId == other.blockId && this.directionId == other.directionId && this.id == other.id && this.peakOffpeak == other.peakOffpeak && this.routeId == other.routeId && this.routeShortName == other.routeShortName && this.serviceId == other.serviceId && this.shapeId == other.shapeId && this.timeZone == other.timeZone && this.tripHeadsign == other.tripHeadsign && this.tripShortName == other.tripShortName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Trip && blockId == other.blockId && directionId == other.directionId && id == other.id && peakOffpeak == other.peakOffpeak && routeId == other.routeId && routeShortName == other.routeShortName && serviceId == other.serviceId && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Trip{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" @@ -2853,17 +2808,14 @@ private constructor( return true } - return /* spotless:off */ other is References && this.agencies == other.agencies && this.routes == other.routes && this.situations == other.situations && this.stopTimes == other.stopTimes && this.stops == other.stops && this.trips == other.trips && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is References && agencies == other.agencies && routes == other.routes && situations == other.situations && stopTimes == other.stopTimes && stops == other.stops && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencies, routes, situations, stopTimes, stops, trips, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencies, routes, situations, stopTimes, stops, trips, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "References{agencies=$agencies, routes=$routes, situations=$situations, stopTimes=$stopTimes, stops=$stops, trips=$trips, additionalProperties=$additionalProperties}" diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt index 65aa1bc..01a7a2c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt @@ -3,15 +3,14 @@ package org.onebusaway.models import com.fasterxml.jackson.annotation.JsonCreator -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.Enum import org.onebusaway.core.JsonField import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.errors.OnebusawaySdkInvalidDataException import org.onebusaway.models.* @@ -23,8 +22,8 @@ constructor( private val userLat: Double?, private val userLocationAccuracy: Double?, private val userLon: Double?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun stopId(): String = stopId @@ -39,18 +38,24 @@ constructor( fun userLon(): Optional = Optional.ofNullable(userLon) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.code?.let { params.put("code", listOf(it.toString())) } - this.userComment?.let { params.put("userComment", listOf(it.toString())) } - this.userLat?.let { params.put("userLat", listOf(it.toString())) } - this.userLocationAccuracy?.let { params.put("userLocationAccuracy", listOf(it.toString())) } - this.userLon?.let { params.put("userLon", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.code?.let { queryParams.put("code", listOf(it.toString())) } + this.userComment?.let { queryParams.put("userComment", listOf(it.toString())) } + this.userLat?.let { queryParams.put("userLat", listOf(it.toString())) } + this.userLocationAccuracy?.let { + queryParams.put("userLocationAccuracy", listOf(it.toString())) + } + this.userLon?.let { queryParams.put("userLon", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -60,25 +65,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReportProblemWithStopRetrieveParams && this.stopId == other.stopId && this.code == other.code && this.userComment == other.userComment && this.userLat == other.userLat && this.userLocationAccuracy == other.userLocationAccuracy && this.userLon == other.userLon && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, code, userComment, userLat, userLocationAccuracy, userLon, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ReportProblemWithStopRetrieveParams{stopId=$stopId, code=$code, userComment=$userComment, userLat=$userLat, userLocationAccuracy=$userLocationAccuracy, userLon=$userLon, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -95,21 +81,22 @@ constructor( private var userLat: Double? = null private var userLocationAccuracy: Double? = null private var userLon: Double? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from( reportProblemWithStopRetrieveParams: ReportProblemWithStopRetrieveParams ) = apply { - this.stopId = reportProblemWithStopRetrieveParams.stopId - this.code = reportProblemWithStopRetrieveParams.code - this.userComment = reportProblemWithStopRetrieveParams.userComment - this.userLat = reportProblemWithStopRetrieveParams.userLat - this.userLocationAccuracy = reportProblemWithStopRetrieveParams.userLocationAccuracy - this.userLon = reportProblemWithStopRetrieveParams.userLon - additionalHeaders(reportProblemWithStopRetrieveParams.additionalHeaders) - additionalQueryParams(reportProblemWithStopRetrieveParams.additionalQueryParams) + stopId = reportProblemWithStopRetrieveParams.stopId + code = reportProblemWithStopRetrieveParams.code + userComment = reportProblemWithStopRetrieveParams.userComment + userLat = reportProblemWithStopRetrieveParams.userLat + userLocationAccuracy = reportProblemWithStopRetrieveParams.userLocationAccuracy + userLon = reportProblemWithStopRetrieveParams.userLon + additionalHeaders = reportProblemWithStopRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = + reportProblemWithStopRetrieveParams.additionalQueryParams.toBuilder() } fun stopId(stopId: String) = apply { this.stopId = stopId } @@ -131,6 +118,11 @@ constructor( /** The reporting user’s current longitude */ fun userLon(userLon: Double) = apply { this.userLon = userLon } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -141,29 +133,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -176,33 +181,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ReportProblemWithStopRetrieveParams = @@ -213,14 +224,8 @@ constructor( userLat, userLocationAccuracy, userLon, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @@ -237,7 +242,7 @@ constructor( return true } - return /* spotless:off */ other is Code && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Code && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -298,4 +303,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReportProblemWithStopRetrieveParams && stopId == other.stopId && code == other.code && userComment == other.userComment && userLat == other.userLat && userLocationAccuracy == other.userLocationAccuracy && userLon == other.userLon && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, code, userComment, userLat, userLocationAccuracy, userLon, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ReportProblemWithStopRetrieveParams{stopId=$stopId, code=$code, userComment=$userComment, userLat=$userLat, userLocationAccuracy=$userLocationAccuracy, userLon=$userLon, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt index 8767e9b..f1a7b2f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt @@ -3,15 +3,14 @@ package org.onebusaway.models import com.fasterxml.jackson.annotation.JsonCreator -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.Enum import org.onebusaway.core.JsonField import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.errors.OnebusawaySdkInvalidDataException import org.onebusaway.models.* @@ -28,8 +27,8 @@ constructor( private val userOnVehicle: Boolean?, private val userVehicleNumber: String?, private val vehicleId: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun tripId(): String = tripId @@ -54,23 +53,29 @@ constructor( fun vehicleId(): Optional = Optional.ofNullable(vehicleId) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.code?.let { params.put("code", listOf(it.toString())) } - this.serviceDate?.let { params.put("serviceDate", listOf(it.toString())) } - this.stopId?.let { params.put("stopID", listOf(it.toString())) } - this.userComment?.let { params.put("userComment", listOf(it.toString())) } - this.userLat?.let { params.put("userLat", listOf(it.toString())) } - this.userLocationAccuracy?.let { params.put("userLocationAccuracy", listOf(it.toString())) } - this.userLon?.let { params.put("userLon", listOf(it.toString())) } - this.userOnVehicle?.let { params.put("userOnVehicle", listOf(it.toString())) } - this.userVehicleNumber?.let { params.put("userVehicleNumber", listOf(it.toString())) } - this.vehicleId?.let { params.put("vehicleID", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.code?.let { queryParams.put("code", listOf(it.toString())) } + this.serviceDate?.let { queryParams.put("serviceDate", listOf(it.toString())) } + this.stopId?.let { queryParams.put("stopID", listOf(it.toString())) } + this.userComment?.let { queryParams.put("userComment", listOf(it.toString())) } + this.userLat?.let { queryParams.put("userLat", listOf(it.toString())) } + this.userLocationAccuracy?.let { + queryParams.put("userLocationAccuracy", listOf(it.toString())) + } + this.userLon?.let { queryParams.put("userLon", listOf(it.toString())) } + this.userOnVehicle?.let { queryParams.put("userOnVehicle", listOf(it.toString())) } + this.userVehicleNumber?.let { queryParams.put("userVehicleNumber", listOf(it.toString())) } + this.vehicleId?.let { queryParams.put("vehicleID", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -80,25 +85,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReportProblemWithTripRetrieveParams && this.tripId == other.tripId && this.code == other.code && this.serviceDate == other.serviceDate && this.stopId == other.stopId && this.userComment == other.userComment && this.userLat == other.userLat && this.userLocationAccuracy == other.userLocationAccuracy && this.userLon == other.userLon && this.userOnVehicle == other.userOnVehicle && this.userVehicleNumber == other.userVehicleNumber && this.vehicleId == other.vehicleId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(tripId, code, serviceDate, stopId, userComment, userLat, userLocationAccuracy, userLon, userOnVehicle, userVehicleNumber, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ReportProblemWithTripRetrieveParams{tripId=$tripId, code=$code, serviceDate=$serviceDate, stopId=$stopId, userComment=$userComment, userLat=$userLat, userLocationAccuracy=$userLocationAccuracy, userLon=$userLon, userOnVehicle=$userOnVehicle, userVehicleNumber=$userVehicleNumber, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -120,26 +106,27 @@ constructor( private var userOnVehicle: Boolean? = null private var userVehicleNumber: String? = null private var vehicleId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from( reportProblemWithTripRetrieveParams: ReportProblemWithTripRetrieveParams ) = apply { - this.tripId = reportProblemWithTripRetrieveParams.tripId - this.code = reportProblemWithTripRetrieveParams.code - this.serviceDate = reportProblemWithTripRetrieveParams.serviceDate - this.stopId = reportProblemWithTripRetrieveParams.stopId - this.userComment = reportProblemWithTripRetrieveParams.userComment - this.userLat = reportProblemWithTripRetrieveParams.userLat - this.userLocationAccuracy = reportProblemWithTripRetrieveParams.userLocationAccuracy - this.userLon = reportProblemWithTripRetrieveParams.userLon - this.userOnVehicle = reportProblemWithTripRetrieveParams.userOnVehicle - this.userVehicleNumber = reportProblemWithTripRetrieveParams.userVehicleNumber - this.vehicleId = reportProblemWithTripRetrieveParams.vehicleId - additionalHeaders(reportProblemWithTripRetrieveParams.additionalHeaders) - additionalQueryParams(reportProblemWithTripRetrieveParams.additionalQueryParams) + tripId = reportProblemWithTripRetrieveParams.tripId + code = reportProblemWithTripRetrieveParams.code + serviceDate = reportProblemWithTripRetrieveParams.serviceDate + stopId = reportProblemWithTripRetrieveParams.stopId + userComment = reportProblemWithTripRetrieveParams.userComment + userLat = reportProblemWithTripRetrieveParams.userLat + userLocationAccuracy = reportProblemWithTripRetrieveParams.userLocationAccuracy + userLon = reportProblemWithTripRetrieveParams.userLon + userOnVehicle = reportProblemWithTripRetrieveParams.userOnVehicle + userVehicleNumber = reportProblemWithTripRetrieveParams.userVehicleNumber + vehicleId = reportProblemWithTripRetrieveParams.vehicleId + additionalHeaders = reportProblemWithTripRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = + reportProblemWithTripRetrieveParams.additionalQueryParams.toBuilder() } fun tripId(tripId: String) = apply { this.tripId = tripId } @@ -178,6 +165,11 @@ constructor( /** The vehicle actively serving the trip */ fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -188,29 +180,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -223,33 +228,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ReportProblemWithTripRetrieveParams = @@ -265,14 +276,8 @@ constructor( userOnVehicle, userVehicleNumber, vehicleId, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @@ -289,7 +294,7 @@ constructor( return true } - return /* spotless:off */ other is Code && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Code && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -357,4 +362,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReportProblemWithTripRetrieveParams && tripId == other.tripId && code == other.code && serviceDate == other.serviceDate && stopId == other.stopId && userComment == other.userComment && userLat == other.userLat && userLocationAccuracy == other.userLocationAccuracy && userLon == other.userLon && userOnVehicle == other.userOnVehicle && userVehicleNumber == other.userVehicleNumber && vehicleId == other.vehicleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(tripId, code, serviceDate, stopId, userComment, userLat, userLocationAccuracy, userLon, userOnVehicle, userVehicleNumber, vehicleId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ReportProblemWithTripRetrieveParams{tripId=$tripId, code=$code, serviceDate=$serviceDate, stopId=$stopId, userComment=$userComment, userLat=$userLat, userLocationAccuracy=$userLocationAccuracy, userLon=$userLon, userOnVehicle=$userOnVehicle, userVehicleNumber=$userVehicleNumber, vehicleId=$vehicleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 dd7c5c0..96d774b 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 @@ -134,17 +134,14 @@ private constructor( return true } - return /* spotless:off */ other is ResponseWrapper && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ResponseWrapper && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ResponseWrapper{code=$code, currentTime=$currentTime, text=$text, version=$version, additionalProperties=$additionalProperties}" diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt index c56d127..f9ee685 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class RouteIdsForAgencyListParams constructor( private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun agencyId(): String = agencyId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RouteIdsForAgencyListParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "RouteIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(routeIdsForAgencyListParams: RouteIdsForAgencyListParams) = apply { - this.agencyId = routeIdsForAgencyListParams.agencyId - additionalHeaders(routeIdsForAgencyListParams.additionalHeaders) - additionalQueryParams(routeIdsForAgencyListParams.additionalQueryParams) + agencyId = routeIdsForAgencyListParams.agencyId + additionalHeaders = routeIdsForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = routeIdsForAgencyListParams.additionalQueryParams.toBuilder() } fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): RouteIdsForAgencyListParams = RouteIdsForAgencyListParams( checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RouteIdsForAgencyListParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RouteIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt index ba35c08..64d3b4a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt @@ -261,17 +261,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" @@ -282,17 +279,14 @@ private constructor( return true } - return /* spotless:off */ other is RouteIdsForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RouteIdsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RouteIdsForAgencyListResponse{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/RouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt index a37fb4d..c2dd038 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class RouteRetrieveParams constructor( private val routeId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun routeId(): String = routeId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RouteRetrieveParams && this.routeId == other.routeId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(routeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "RouteRetrieveParams{routeId=$routeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var routeId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(routeRetrieveParams: RouteRetrieveParams) = apply { - this.routeId = routeRetrieveParams.routeId - additionalHeaders(routeRetrieveParams.additionalHeaders) - additionalQueryParams(routeRetrieveParams.additionalQueryParams) + routeId = routeRetrieveParams.routeId + additionalHeaders = routeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = routeRetrieveParams.additionalQueryParams.toBuilder() } fun routeId(routeId: String) = apply { this.routeId = routeId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): RouteRetrieveParams = RouteRetrieveParams( checkNotNull(routeId) { "`routeId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RouteRetrieveParams && routeId == other.routeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(routeId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RouteRetrieveParams{routeId=$routeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt index 4b903c4..22c03a1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt @@ -462,17 +462,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" @@ -483,17 +480,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -504,17 +498,14 @@ private constructor( return true } - return /* spotless:off */ other is RouteRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RouteRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RouteRetrieveResponse{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/RoutesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt index 07bf4e9..daedf1b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class RoutesForAgencyListParams constructor( private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun agencyId(): String = agencyId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoutesForAgencyListParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "RoutesForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(routesForAgencyListParams: RoutesForAgencyListParams) = apply { - this.agencyId = routesForAgencyListParams.agencyId - additionalHeaders(routesForAgencyListParams.additionalHeaders) - additionalQueryParams(routesForAgencyListParams.additionalQueryParams) + agencyId = routesForAgencyListParams.agencyId + additionalHeaders = routesForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = routesForAgencyListParams.additionalQueryParams.toBuilder() } fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): RoutesForAgencyListParams = RoutesForAgencyListParams( checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoutesForAgencyListParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RoutesForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt index 7f3fa67..7882c21 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt @@ -479,17 +479,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" @@ -500,17 +497,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" @@ -521,17 +515,14 @@ private constructor( return true } - return /* spotless:off */ other is RoutesForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RoutesForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RoutesForAgencyListResponse{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/RoutesForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt index fde116f..acbc08d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt @@ -2,12 +2,11 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class RoutesForLocationListParams @@ -18,8 +17,8 @@ constructor( private val lonSpan: Double?, private val query: String?, private val radius: Double?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun lat(): Double = lat @@ -34,40 +33,25 @@ constructor( fun radius(): Optional = Optional.ofNullable(radius) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.lat.let { params.put("lat", listOf(it.toString())) } - this.lon.let { params.put("lon", listOf(it.toString())) } - this.latSpan?.let { params.put("latSpan", listOf(it.toString())) } - this.lonSpan?.let { params.put("lonSpan", listOf(it.toString())) } - this.query?.let { params.put("query", listOf(it.toString())) } - this.radius?.let { params.put("radius", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoutesForLocationListParams && this.lat == other.lat && this.lon == other.lon && this.latSpan == other.latSpan && this.lonSpan == other.lonSpan && this.query == other.query && this.radius == other.radius && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(lat, lon, latSpan, lonSpan, query, radius, additionalHeaders, additionalQueryParams) /* spotless:on */ + @JvmSynthetic + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.lat.let { queryParams.put("lat", listOf(it.toString())) } + this.lon.let { queryParams.put("lon", listOf(it.toString())) } + this.latSpan?.let { queryParams.put("latSpan", listOf(it.toString())) } + this.lonSpan?.let { queryParams.put("lonSpan", listOf(it.toString())) } + this.query?.let { queryParams.put("query", listOf(it.toString())) } + this.radius?.let { queryParams.put("radius", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - override fun toString() = - "RoutesForLocationListParams{lat=$lat, lon=$lon, latSpan=$latSpan, lonSpan=$lonSpan, query=$query, radius=$radius, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -84,19 +68,19 @@ constructor( private var lonSpan: Double? = null private var query: String? = null private var radius: Double? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(routesForLocationListParams: RoutesForLocationListParams) = apply { - this.lat = routesForLocationListParams.lat - this.lon = routesForLocationListParams.lon - this.latSpan = routesForLocationListParams.latSpan - this.lonSpan = routesForLocationListParams.lonSpan - this.query = routesForLocationListParams.query - this.radius = routesForLocationListParams.radius - additionalHeaders(routesForLocationListParams.additionalHeaders) - additionalQueryParams(routesForLocationListParams.additionalQueryParams) + lat = routesForLocationListParams.lat + lon = routesForLocationListParams.lon + latSpan = routesForLocationListParams.latSpan + lonSpan = routesForLocationListParams.lonSpan + query = routesForLocationListParams.query + radius = routesForLocationListParams.radius + additionalHeaders = routesForLocationListParams.additionalHeaders.toBuilder() + additionalQueryParams = routesForLocationListParams.additionalQueryParams.toBuilder() } fun lat(lat: Double) = apply { this.lat = lat } @@ -111,6 +95,11 @@ constructor( fun radius(radius: Double) = apply { this.radius = radius } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -121,29 +110,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -156,33 +158,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): RoutesForLocationListParams = @@ -193,14 +201,21 @@ constructor( lonSpan, query, radius, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoutesForLocationListParams && lat == other.lat && lon == other.lon && latSpan == other.latSpan && lonSpan == other.lonSpan && query == other.query && radius == other.radius && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(lat, lon, latSpan, lonSpan, query, radius, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RoutesForLocationListParams{lat=$lat, lon=$lon, latSpan=$latSpan, lonSpan=$lonSpan, query=$query, radius=$radius, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt index af00a62..04ecb1c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt @@ -494,17 +494,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" @@ -515,17 +512,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.outOfRange == other.outOfRange && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" @@ -536,17 +530,14 @@ private constructor( return true } - return /* spotless:off */ other is RoutesForLocationListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RoutesForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RoutesForLocationListResponse{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/ScheduleForRouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt index 8d835bc..bb28391 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt @@ -2,35 +2,38 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.time.LocalDate import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ScheduleForRouteRetrieveParams constructor( private val routeId: String, private val date: LocalDate?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun routeId(): String = routeId fun date(): Optional = Optional.ofNullable(date) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.date?.let { params.put("date", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.date?.let { queryParams.put("date", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -40,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleForRouteRetrieveParams && this.routeId == other.routeId && this.date == other.date && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(routeId, date, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ScheduleForRouteRetrieveParams{routeId=$routeId, date=$date, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -71,15 +55,15 @@ constructor( private var routeId: String? = null private var date: LocalDate? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(scheduleForRouteRetrieveParams: ScheduleForRouteRetrieveParams) = apply { - this.routeId = scheduleForRouteRetrieveParams.routeId - this.date = scheduleForRouteRetrieveParams.date - additionalHeaders(scheduleForRouteRetrieveParams.additionalHeaders) - additionalQueryParams(scheduleForRouteRetrieveParams.additionalQueryParams) + routeId = scheduleForRouteRetrieveParams.routeId + date = scheduleForRouteRetrieveParams.date + additionalHeaders = scheduleForRouteRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = scheduleForRouteRetrieveParams.additionalQueryParams.toBuilder() } fun routeId(routeId: String) = apply { this.routeId = routeId } @@ -90,6 +74,11 @@ constructor( */ fun date(date: LocalDate) = apply { this.date = date } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -100,29 +89,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -135,47 +137,60 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams( checkNotNull(routeId) { "`routeId` is required but was not set" }, date, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleForRouteRetrieveParams && routeId == other.routeId && date == other.date && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(routeId, date, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ScheduleForRouteRetrieveParams{routeId=$routeId, date=$date, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt index 37a37a4..559e125 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt @@ -622,17 +622,14 @@ private constructor( return true } - return /* spotless:off */ other is Stop && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Stop && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Stop{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" @@ -1084,17 +1081,14 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && this.arrivalEnabled == other.arrivalEnabled && this.arrivalTime == other.arrivalTime && this.departureEnabled == other.departureEnabled && this.departureTime == other.departureTime && this.serviceId == other.serviceId && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && serviceId == other.serviceId && stopHeadsign == other.stopHeadsign && stopId == other.stopId && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, stopHeadsign, stopId, tripId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, stopHeadsign, stopId, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, stopHeadsign=$stopHeadsign, stopId=$stopId, tripId=$tripId, additionalProperties=$additionalProperties}" @@ -1105,17 +1099,14 @@ private constructor( return true } - return /* spotless:off */ other is TripsWithStopTime && this.tripId == other.tripId && this.stopTimes == other.stopTimes && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripsWithStopTime && tripId == other.tripId && stopTimes == other.stopTimes && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tripId, stopTimes, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(tripId, stopTimes, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripsWithStopTime{tripId=$tripId, stopTimes=$stopTimes, additionalProperties=$additionalProperties}" @@ -1126,17 +1117,14 @@ private constructor( return true } - return /* spotless:off */ other is StopTripGrouping && this.directionId == other.directionId && this.stopIds == other.stopIds && this.tripHeadsigns == other.tripHeadsigns && this.tripIds == other.tripIds && this.tripsWithStopTimes == other.tripsWithStopTimes && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTripGrouping && directionId == other.directionId && stopIds == other.stopIds && tripHeadsigns == other.tripHeadsigns && tripIds == other.tripIds && tripsWithStopTimes == other.tripsWithStopTimes && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(directionId, stopIds, tripHeadsigns, tripIds, tripsWithStopTimes, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(directionId, stopIds, tripHeadsigns, tripIds, tripsWithStopTimes, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" @@ -1393,17 +1381,14 @@ private constructor( return true } - return /* spotless:off */ other is Trip && this.blockId == other.blockId && this.directionId == other.directionId && this.id == other.id && this.peakOffpeak == other.peakOffpeak && this.routeId == other.routeId && this.routeShortName == other.routeShortName && this.serviceId == other.serviceId && this.shapeId == other.shapeId && this.timeZone == other.timeZone && this.tripHeadsign == other.tripHeadsign && this.tripShortName == other.tripShortName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Trip && blockId == other.blockId && directionId == other.directionId && id == other.id && peakOffpeak == other.peakOffpeak && routeId == other.routeId && routeShortName == other.routeShortName && serviceId == other.serviceId && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Trip{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" @@ -1414,17 +1399,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.routeId == other.routeId && this.scheduleDate == other.scheduleDate && this.serviceIds == other.serviceIds && this.stopTripGroupings == other.stopTripGroupings && this.stops == other.stops && this.trips == other.trips && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && routeId == other.routeId && scheduleDate == other.scheduleDate && serviceIds == other.serviceIds && stopTripGroupings == other.stopTripGroupings && stops == other.stops && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(routeId, scheduleDate, serviceIds, stopTripGroupings, stops, trips, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(routeId, scheduleDate, serviceIds, stopTripGroupings, stops, trips, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stopTripGroupings=$stopTripGroupings, stops=$stops, trips=$trips, additionalProperties=$additionalProperties}" @@ -1435,17 +1417,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, additionalProperties=$additionalProperties}" } @@ -1455,17 +1434,14 @@ private constructor( return true } - return /* spotless:off */ other is ScheduleForRouteRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScheduleForRouteRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ScheduleForRouteRetrieveResponse{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/ScheduleForStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt index 6153cb7..23621ec 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt @@ -2,35 +2,38 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.time.LocalDate import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ScheduleForStopRetrieveParams constructor( private val stopId: String, private val date: LocalDate?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun stopId(): String = stopId fun date(): Optional = Optional.ofNullable(date) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.date?.let { params.put("date", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.date?.let { queryParams.put("date", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -40,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleForStopRetrieveParams && this.stopId == other.stopId && this.date == other.date && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, date, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ScheduleForStopRetrieveParams{stopId=$stopId, date=$date, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -71,15 +55,15 @@ constructor( private var stopId: String? = null private var date: LocalDate? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(scheduleForStopRetrieveParams: ScheduleForStopRetrieveParams) = apply { - this.stopId = scheduleForStopRetrieveParams.stopId - this.date = scheduleForStopRetrieveParams.date - additionalHeaders(scheduleForStopRetrieveParams.additionalHeaders) - additionalQueryParams(scheduleForStopRetrieveParams.additionalQueryParams) + stopId = scheduleForStopRetrieveParams.stopId + date = scheduleForStopRetrieveParams.date + additionalHeaders = scheduleForStopRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = scheduleForStopRetrieveParams.additionalQueryParams.toBuilder() } fun stopId(stopId: String) = apply { this.stopId = stopId } @@ -90,6 +74,11 @@ constructor( */ fun date(date: LocalDate) = apply { this.date = date } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -100,29 +89,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -135,47 +137,60 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams( checkNotNull(stopId) { "`stopId` is required but was not set" }, date, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleForStopRetrieveParams && stopId == other.stopId && date == other.date && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, date, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ScheduleForStopRetrieveParams{stopId=$stopId, date=$date, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt index 3dab4f2..7063b94 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt @@ -767,17 +767,14 @@ private constructor( return true } - return /* spotless:off */ other is ScheduleStopTime && this.arrivalEnabled == other.arrivalEnabled && this.arrivalTime == other.arrivalTime && this.departureEnabled == other.departureEnabled && this.departureTime == other.departureTime && this.serviceId == other.serviceId && this.stopHeadsign == other.stopHeadsign && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScheduleStopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && serviceId == other.serviceId && stopHeadsign == other.stopHeadsign && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, stopHeadsign, tripId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, stopHeadsign, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ScheduleStopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, stopHeadsign=$stopHeadsign, tripId=$tripId, additionalProperties=$additionalProperties}" @@ -944,17 +941,14 @@ private constructor( return true } - return /* spotless:off */ other is ScheduleFrequency && this.serviceDate == other.serviceDate && this.startTime == other.startTime && this.endTime == other.endTime && this.headway == other.headway && this.serviceId == other.serviceId && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScheduleFrequency && serviceDate == other.serviceDate && startTime == other.startTime && endTime == other.endTime && headway == other.headway && serviceId == other.serviceId && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(serviceDate, startTime, endTime, headway, serviceId, tripId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(serviceDate, startTime, endTime, headway, serviceId, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ScheduleFrequency{serviceDate=$serviceDate, startTime=$startTime, endTime=$endTime, headway=$headway, serviceId=$serviceId, tripId=$tripId, additionalProperties=$additionalProperties}" @@ -965,17 +959,14 @@ private constructor( return true } - return /* spotless:off */ other is StopRouteDirectionSchedule && this.scheduleFrequencies == other.scheduleFrequencies && this.scheduleStopTimes == other.scheduleStopTimes && this.tripHeadsign == other.tripHeadsign && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopRouteDirectionSchedule && scheduleFrequencies == other.scheduleFrequencies && scheduleStopTimes == other.scheduleStopTimes && tripHeadsign == other.tripHeadsign && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(scheduleFrequencies, scheduleStopTimes, tripHeadsign, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(scheduleFrequencies, scheduleStopTimes, tripHeadsign, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopRouteDirectionSchedule{scheduleFrequencies=$scheduleFrequencies, scheduleStopTimes=$scheduleStopTimes, tripHeadsign=$tripHeadsign, additionalProperties=$additionalProperties}" @@ -986,17 +977,14 @@ private constructor( return true } - return /* spotless:off */ other is StopRouteSchedule && this.routeId == other.routeId && this.stopRouteDirectionSchedules == other.stopRouteDirectionSchedules && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopRouteSchedule && routeId == other.routeId && stopRouteDirectionSchedules == other.stopRouteDirectionSchedules && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(routeId, stopRouteDirectionSchedules, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(routeId, stopRouteDirectionSchedules, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopRouteSchedule{routeId=$routeId, stopRouteDirectionSchedules=$stopRouteDirectionSchedules, additionalProperties=$additionalProperties}" @@ -1007,17 +995,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.date == other.date && this.stopId == other.stopId && this.stopRouteSchedules == other.stopRouteSchedules && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && date == other.date && stopId == other.stopId && stopRouteSchedules == other.stopRouteSchedules && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(date, stopId, stopRouteSchedules, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(date, stopId, stopRouteSchedules, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{date=$date, stopId=$stopId, stopRouteSchedules=$stopRouteSchedules, additionalProperties=$additionalProperties}" @@ -1028,17 +1013,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -1049,17 +1031,14 @@ private constructor( return true } - return /* spotless:off */ other is ScheduleForStopRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScheduleForStopRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ScheduleForStopRetrieveResponse{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/SearchForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt index 821db49..54fbeb1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt @@ -2,56 +2,40 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class SearchForRouteListParams constructor( private val input: String, private val maxCount: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun input(): String = input fun maxCount(): Optional = Optional.ofNullable(maxCount) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.input.let { params.put("input", listOf(it.toString())) } - this.maxCount?.let { params.put("maxCount", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SearchForRouteListParams && this.input == other.input && this.maxCount == other.maxCount && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) /* spotless:on */ + @JvmSynthetic + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.input.let { queryParams.put("input", listOf(it.toString())) } + this.maxCount?.let { queryParams.put("maxCount", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - override fun toString() = - "SearchForRouteListParams{input=$input, maxCount=$maxCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -64,15 +48,15 @@ constructor( private var input: String? = null private var maxCount: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(searchForRouteListParams: SearchForRouteListParams) = apply { - this.input = searchForRouteListParams.input - this.maxCount = searchForRouteListParams.maxCount - additionalHeaders(searchForRouteListParams.additionalHeaders) - additionalQueryParams(searchForRouteListParams.additionalQueryParams) + input = searchForRouteListParams.input + maxCount = searchForRouteListParams.maxCount + additionalHeaders = searchForRouteListParams.additionalHeaders.toBuilder() + additionalQueryParams = searchForRouteListParams.additionalQueryParams.toBuilder() } /** The string to search for. */ @@ -81,6 +65,11 @@ constructor( /** The max number of results to return. Defaults to 20. */ fun maxCount(maxCount: Long) = apply { this.maxCount = maxCount } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -91,29 +80,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -126,47 +128,60 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): SearchForRouteListParams = SearchForRouteListParams( checkNotNull(input) { "`input` is required but was not set" }, maxCount, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SearchForRouteListParams && input == other.input && maxCount == other.maxCount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "SearchForRouteListParams{input=$input, maxCount=$maxCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt index d18d1be..3c11e1a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt @@ -494,17 +494,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.agencyId == other.agencyId && this.color == other.color && this.description == other.description && this.id == other.id && this.longName == other.longName && this.nullSafeShortName == other.nullSafeShortName && this.shortName == other.shortName && this.textColor == other.textColor && this.type == other.type && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" @@ -515,17 +512,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.outOfRange == other.outOfRange && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" @@ -536,17 +530,14 @@ private constructor( return true } - return /* spotless:off */ other is SearchForRouteListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SearchForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SearchForRouteListResponse{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/SearchForStopListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt index a4c84eb..01ef1e8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt @@ -2,56 +2,40 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class SearchForStopListParams constructor( private val input: String, private val maxCount: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun input(): String = input fun maxCount(): Optional = Optional.ofNullable(maxCount) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.input.let { params.put("input", listOf(it.toString())) } - this.maxCount?.let { params.put("maxCount", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SearchForStopListParams && this.input == other.input && this.maxCount == other.maxCount && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) /* spotless:on */ + @JvmSynthetic + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.input.let { queryParams.put("input", listOf(it.toString())) } + this.maxCount?.let { queryParams.put("maxCount", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - override fun toString() = - "SearchForStopListParams{input=$input, maxCount=$maxCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -64,15 +48,15 @@ constructor( private var input: String? = null private var maxCount: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(searchForStopListParams: SearchForStopListParams) = apply { - this.input = searchForStopListParams.input - this.maxCount = searchForStopListParams.maxCount - additionalHeaders(searchForStopListParams.additionalHeaders) - additionalQueryParams(searchForStopListParams.additionalQueryParams) + input = searchForStopListParams.input + maxCount = searchForStopListParams.maxCount + additionalHeaders = searchForStopListParams.additionalHeaders.toBuilder() + additionalQueryParams = searchForStopListParams.additionalQueryParams.toBuilder() } /** The string to search for. */ @@ -81,6 +65,11 @@ constructor( /** The max number of results to return. Defaults to 20. */ fun maxCount(maxCount: Long) = apply { this.maxCount = maxCount } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -91,29 +80,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -126,47 +128,60 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): SearchForStopListParams = SearchForStopListParams( checkNotNull(input) { "`input` is required but was not set" }, maxCount, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SearchForStopListParams && input == other.input && maxCount == other.maxCount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "SearchForStopListParams{input=$input, maxCount=$maxCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt index e5437d0..7c1e4d9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt @@ -517,17 +517,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" @@ -538,17 +535,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.outOfRange == other.outOfRange && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" @@ -559,17 +553,14 @@ private constructor( return true } - return /* spotless:off */ other is SearchForStopListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SearchForStopListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SearchForStopListResponse{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/ShapeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt index 0688ca0..016a724 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ShapeRetrieveParams constructor( private val shapeId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun shapeId(): String = shapeId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShapeRetrieveParams && this.shapeId == other.shapeId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(shapeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "ShapeRetrieveParams{shapeId=$shapeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var shapeId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(shapeRetrieveParams: ShapeRetrieveParams) = apply { - this.shapeId = shapeRetrieveParams.shapeId - additionalHeaders(shapeRetrieveParams.additionalHeaders) - additionalQueryParams(shapeRetrieveParams.additionalQueryParams) + shapeId = shapeRetrieveParams.shapeId + additionalHeaders = shapeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = shapeRetrieveParams.additionalQueryParams.toBuilder() } fun shapeId(shapeId: String) = apply { this.shapeId = shapeId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ShapeRetrieveParams = ShapeRetrieveParams( checkNotNull(shapeId) { "`shapeId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ShapeRetrieveParams && shapeId == other.shapeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(shapeId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ShapeRetrieveParams{shapeId=$shapeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt index dc71798..24a8043 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt @@ -350,17 +350,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.length == other.length && this.levels == other.levels && this.points == other.points && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(length, levels, points, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" @@ -371,17 +368,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -392,17 +386,14 @@ private constructor( return true } - return /* spotless:off */ other is ShapeRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ShapeRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ShapeRetrieveResponse{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/StopIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt index 0db9961..04075b1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class StopIdsForAgencyListParams constructor( private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun agencyId(): String = agencyId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopIdsForAgencyListParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(stopIdsForAgencyListParams: StopIdsForAgencyListParams) = apply { - this.agencyId = stopIdsForAgencyListParams.agencyId - additionalHeaders(stopIdsForAgencyListParams.additionalHeaders) - additionalQueryParams(stopIdsForAgencyListParams.additionalQueryParams) + agencyId = stopIdsForAgencyListParams.agencyId + additionalHeaders = stopIdsForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = stopIdsForAgencyListParams.additionalQueryParams.toBuilder() } fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): StopIdsForAgencyListParams = StopIdsForAgencyListParams( checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopIdsForAgencyListParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt index b8cebb1..b95cb63 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt @@ -261,17 +261,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" @@ -282,17 +279,14 @@ private constructor( return true } - return /* spotless:off */ other is StopIdsForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopIdsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopIdsForAgencyListResponse{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/StopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt index f48cb58..867a165 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class StopRetrieveParams constructor( private val stopId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun stopId(): String = stopId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopRetrieveParams && this.stopId == other.stopId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(stopId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopRetrieveParams{stopId=$stopId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var stopId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(stopRetrieveParams: StopRetrieveParams) = apply { - this.stopId = stopRetrieveParams.stopId - additionalHeaders(stopRetrieveParams.additionalHeaders) - additionalQueryParams(stopRetrieveParams.additionalQueryParams) + stopId = stopRetrieveParams.stopId + additionalHeaders = stopRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = stopRetrieveParams.additionalQueryParams.toBuilder() } fun stopId(stopId: String) = apply { this.stopId = stopId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): StopRetrieveParams = StopRetrieveParams( checkNotNull(stopId) { "`stopId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopRetrieveParams && stopId == other.stopId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(stopId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopRetrieveParams{stopId=$stopId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt index c94ac1e..e81fb01 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt @@ -479,17 +479,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" @@ -500,17 +497,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -521,17 +515,14 @@ private constructor( return true } - return /* spotless:off */ other is StopRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopRetrieveResponse{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/StopsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt index 5c4c365..58b9f04 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class StopsForAgencyListParams constructor( private val agencyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun agencyId(): String = agencyId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForAgencyListParams && this.agencyId == other.agencyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var agencyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(stopsForAgencyListParams: StopsForAgencyListParams) = apply { - this.agencyId = stopsForAgencyListParams.agencyId - additionalHeaders(stopsForAgencyListParams.additionalHeaders) - additionalQueryParams(stopsForAgencyListParams.additionalQueryParams) + agencyId = stopsForAgencyListParams.agencyId + additionalHeaders = stopsForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = stopsForAgencyListParams.additionalQueryParams.toBuilder() } fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): StopsForAgencyListParams = StopsForAgencyListParams( checkNotNull(agencyId) { "`agencyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopsForAgencyListParams && agencyId == other.agencyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt index 56a8389..ff40515 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt @@ -442,17 +442,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" @@ -463,17 +460,14 @@ private constructor( return true } - return /* spotless:off */ other is StopsForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.limitExceeded == other.limitExceeded && this.outOfRange == other.outOfRange && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && limitExceeded == other.limitExceeded && outOfRange == other.outOfRange && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, limitExceeded, outOfRange, list, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, limitExceeded, outOfRange, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, limitExceeded=$limitExceeded, outOfRange=$outOfRange, list=$list, references=$references, additionalProperties=$additionalProperties}" diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt index 5a72da8..ff70a36 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt @@ -2,12 +2,11 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class StopsForLocationListParams @@ -18,8 +17,8 @@ constructor( private val lonSpan: Double?, private val query: String?, private val radius: Double?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun lat(): Double = lat @@ -34,40 +33,25 @@ constructor( fun radius(): Optional = Optional.ofNullable(radius) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.lat.let { params.put("lat", listOf(it.toString())) } - this.lon.let { params.put("lon", listOf(it.toString())) } - this.latSpan?.let { params.put("latSpan", listOf(it.toString())) } - this.lonSpan?.let { params.put("lonSpan", listOf(it.toString())) } - this.query?.let { params.put("query", listOf(it.toString())) } - this.radius?.let { params.put("radius", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForLocationListParams && this.lat == other.lat && this.lon == other.lon && this.latSpan == other.latSpan && this.lonSpan == other.lonSpan && this.query == other.query && this.radius == other.radius && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(lat, lon, latSpan, lonSpan, query, radius, additionalHeaders, additionalQueryParams) /* spotless:on */ + @JvmSynthetic + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.lat.let { queryParams.put("lat", listOf(it.toString())) } + this.lon.let { queryParams.put("lon", listOf(it.toString())) } + this.latSpan?.let { queryParams.put("latSpan", listOf(it.toString())) } + this.lonSpan?.let { queryParams.put("lonSpan", listOf(it.toString())) } + this.query?.let { queryParams.put("query", listOf(it.toString())) } + this.radius?.let { queryParams.put("radius", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - override fun toString() = - "StopsForLocationListParams{lat=$lat, lon=$lon, latSpan=$latSpan, lonSpan=$lonSpan, query=$query, radius=$radius, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -84,19 +68,19 @@ constructor( private var lonSpan: Double? = null private var query: String? = null private var radius: Double? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(stopsForLocationListParams: StopsForLocationListParams) = apply { - this.lat = stopsForLocationListParams.lat - this.lon = stopsForLocationListParams.lon - this.latSpan = stopsForLocationListParams.latSpan - this.lonSpan = stopsForLocationListParams.lonSpan - this.query = stopsForLocationListParams.query - this.radius = stopsForLocationListParams.radius - additionalHeaders(stopsForLocationListParams.additionalHeaders) - additionalQueryParams(stopsForLocationListParams.additionalQueryParams) + lat = stopsForLocationListParams.lat + lon = stopsForLocationListParams.lon + latSpan = stopsForLocationListParams.latSpan + lonSpan = stopsForLocationListParams.lonSpan + query = stopsForLocationListParams.query + radius = stopsForLocationListParams.radius + additionalHeaders = stopsForLocationListParams.additionalHeaders.toBuilder() + additionalQueryParams = stopsForLocationListParams.additionalQueryParams.toBuilder() } fun lat(lat: Double) = apply { this.lat = lat } @@ -115,6 +99,11 @@ constructor( /** The radius in meters to search within */ fun radius(radius: Double) = apply { this.radius = radius } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -125,29 +114,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -160,33 +162,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): StopsForLocationListParams = @@ -197,14 +205,21 @@ constructor( lonSpan, query, radius, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopsForLocationListParams && lat == other.lat && lon == other.lon && latSpan == other.latSpan && lonSpan == other.lonSpan && query == other.query && radius == other.radius && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(lat, lon, latSpan, lonSpan, query, radius, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopsForLocationListParams{lat=$lat, lon=$lon, latSpan=$latSpan, lonSpan=$lonSpan, query=$query, radius=$radius, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt index 9a7970a..ea1dd8f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt @@ -518,17 +518,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.code == other.code && this.direction == other.direction && this.id == other.id && this.lat == other.lat && this.locationType == other.locationType && this.lon == other.lon && this.name == other.name && this.parent == other.parent && this.routeIds == other.routeIds && this.staticRouteIds == other.staticRouteIds && this.wheelchairBoarding == other.wheelchairBoarding && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" @@ -539,17 +536,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.outOfRange == other.outOfRange && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && outOfRange == other.outOfRange && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, outOfRange, list, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, outOfRange, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, outOfRange=$outOfRange, list=$list, references=$references, additionalProperties=$additionalProperties}" @@ -560,17 +554,14 @@ private constructor( return true } - return /* spotless:off */ other is StopsForLocationListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopsForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopsForLocationListResponse{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/StopsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt index 6a20455..a81b36f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt @@ -2,12 +2,11 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class StopsForRouteListParams @@ -15,8 +14,8 @@ constructor( private val routeId: String, private val includePolylines: Boolean?, private val time: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun routeId(): String = routeId @@ -25,15 +24,19 @@ constructor( fun time(): Optional = Optional.ofNullable(time) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.includePolylines?.let { params.put("includePolylines", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.includePolylines?.let { queryParams.put("includePolylines", listOf(it.toString())) } + this.time?.let { queryParams.put("time", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -43,25 +46,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForRouteListParams && this.routeId == other.routeId && this.includePolylines == other.includePolylines && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(routeId, includePolylines, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "StopsForRouteListParams{routeId=$routeId, includePolylines=$includePolylines, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -75,16 +59,16 @@ constructor( private var routeId: String? = null private var includePolylines: Boolean? = null private var time: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(stopsForRouteListParams: StopsForRouteListParams) = apply { - this.routeId = stopsForRouteListParams.routeId - this.includePolylines = stopsForRouteListParams.includePolylines - this.time = stopsForRouteListParams.time - additionalHeaders(stopsForRouteListParams.additionalHeaders) - additionalQueryParams(stopsForRouteListParams.additionalQueryParams) + routeId = stopsForRouteListParams.routeId + includePolylines = stopsForRouteListParams.includePolylines + time = stopsForRouteListParams.time + additionalHeaders = stopsForRouteListParams.additionalHeaders.toBuilder() + additionalQueryParams = stopsForRouteListParams.additionalQueryParams.toBuilder() } fun routeId(routeId: String) = apply { this.routeId = routeId } @@ -97,6 +81,11 @@ constructor( /** Specify service date (YYYY-MM-DD or epoch) (default today) */ fun time(time: String) = apply { this.time = time } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -107,29 +96,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -142,33 +144,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): StopsForRouteListParams = @@ -176,14 +184,21 @@ constructor( checkNotNull(routeId) { "`routeId` is required but was not set" }, includePolylines, time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopsForRouteListParams && routeId == other.routeId && includePolylines == other.includePolylines && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(routeId, includePolylines, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "StopsForRouteListParams{routeId=$routeId, includePolylines=$includePolylines, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt index 70761aa..8089ee4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt @@ -470,17 +470,14 @@ private constructor( return true } - return /* spotless:off */ other is Polyline && this.length == other.length && this.levels == other.levels && this.points == other.points && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Polyline && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(length, levels, points, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" @@ -714,17 +711,14 @@ private constructor( return true } - return /* spotless:off */ other is Name && this.name == other.name && this.names == other.names && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Name && name == other.name && names == other.names && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, names, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, names, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" @@ -839,17 +833,14 @@ private constructor( return true } - return /* spotless:off */ other is Polyline && this.length == other.length && this.levels == other.levels && this.points == other.points && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Polyline && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(length, levels, points, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" @@ -860,17 +851,14 @@ private constructor( return true } - return /* spotless:off */ other is StopGrouping && this.id == other.id && this.name == other.name && this.polylines == other.polylines && this.stopIds == other.stopIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopGrouping && id == other.id && name == other.name && polylines == other.polylines && stopIds == other.stopIds && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, polylines, stopIds, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, name, polylines, stopIds, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" @@ -881,17 +869,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.polylines == other.polylines && this.routeId == other.routeId && this.stopGroupings == other.stopGroupings && this.stopIds == other.stopIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && polylines == other.polylines && routeId == other.routeId && stopGroupings == other.stopGroupings && stopIds == other.stopIds && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" @@ -902,17 +887,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -923,17 +905,14 @@ private constructor( return true } - return /* spotless:off */ other is StopsForRouteListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopsForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopsForRouteListResponse{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/TripDetailRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt index 1564725..d054387 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt @@ -2,12 +2,11 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripDetailRetrieveParams @@ -18,8 +17,8 @@ constructor( private val includeTrip: Boolean?, private val serviceDate: Long?, private val time: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun tripId(): String = tripId @@ -34,18 +33,22 @@ constructor( fun time(): Optional = Optional.ofNullable(time) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.includeSchedule?.let { params.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { params.put("includeStatus", listOf(it.toString())) } - this.includeTrip?.let { params.put("includeTrip", listOf(it.toString())) } - this.serviceDate?.let { params.put("serviceDate", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } + this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } + this.includeTrip?.let { queryParams.put("includeTrip", listOf(it.toString())) } + this.serviceDate?.let { queryParams.put("serviceDate", listOf(it.toString())) } + this.time?.let { queryParams.put("time", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -55,25 +58,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripDetailRetrieveParams && this.tripId == other.tripId && this.includeSchedule == other.includeSchedule && this.includeStatus == other.includeStatus && this.includeTrip == other.includeTrip && this.serviceDate == other.serviceDate && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(tripId, includeSchedule, includeStatus, includeTrip, serviceDate, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripDetailRetrieveParams{tripId=$tripId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, includeTrip=$includeTrip, serviceDate=$serviceDate, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -90,19 +74,19 @@ constructor( private var includeTrip: Boolean? = null private var serviceDate: Long? = null private var time: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(tripDetailRetrieveParams: TripDetailRetrieveParams) = apply { - this.tripId = tripDetailRetrieveParams.tripId - this.includeSchedule = tripDetailRetrieveParams.includeSchedule - this.includeStatus = tripDetailRetrieveParams.includeStatus - this.includeTrip = tripDetailRetrieveParams.includeTrip - this.serviceDate = tripDetailRetrieveParams.serviceDate - this.time = tripDetailRetrieveParams.time - additionalHeaders(tripDetailRetrieveParams.additionalHeaders) - additionalQueryParams(tripDetailRetrieveParams.additionalQueryParams) + tripId = tripDetailRetrieveParams.tripId + includeSchedule = tripDetailRetrieveParams.includeSchedule + includeStatus = tripDetailRetrieveParams.includeStatus + includeTrip = tripDetailRetrieveParams.includeTrip + serviceDate = tripDetailRetrieveParams.serviceDate + time = tripDetailRetrieveParams.time + additionalHeaders = tripDetailRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tripDetailRetrieveParams.additionalQueryParams.toBuilder() } fun tripId(tripId: String) = apply { this.tripId = tripId } @@ -131,6 +115,11 @@ constructor( /** Time parameter to query the system at a specific time (optional). */ fun time(time: Long) = apply { this.time = time } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -141,29 +130,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -176,33 +178,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): TripDetailRetrieveParams = @@ -213,14 +221,21 @@ constructor( includeTrip, serviceDate, time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripDetailRetrieveParams && tripId == other.tripId && includeSchedule == other.includeSchedule && includeStatus == other.includeStatus && includeTrip == other.includeTrip && serviceDate == other.serviceDate && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(tripId, includeSchedule, includeStatus, includeTrip, serviceDate, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripDetailRetrieveParams{tripId=$tripId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, includeTrip=$includeTrip, serviceDate=$serviceDate, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt index dcb12a7..4ac12ff 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt @@ -716,17 +716,14 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" @@ -737,17 +734,14 @@ private constructor( return true } - return /* spotless:off */ other is Schedule && this.frequency == other.frequency && this.nextTripId == other.nextTripId && this.previousTripId == other.previousTripId && this.stopTimes == other.stopTimes && this.timeZone == other.timeZone && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schedule && frequency == other.frequency && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" @@ -1628,17 +1622,14 @@ private constructor( return true } - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1745,17 +1736,14 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1766,17 +1754,14 @@ private constructor( return true } - return /* spotless:off */ other is Status && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -1787,17 +1772,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.frequency == other.frequency && this.schedule == other.schedule && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(frequency, schedule, serviceDate, situationIds, status, tripId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, schedule, serviceDate, situationIds, status, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, tripId=$tripId, additionalProperties=$additionalProperties}" @@ -1808,17 +1790,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -1829,17 +1808,14 @@ private constructor( return true } - return /* spotless:off */ other is TripDetailRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripDetailRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripDetailRetrieveResponse{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/TripForVehicleRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt index 2d2527b..1d8bdfc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt @@ -2,12 +2,11 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripForVehicleRetrieveParams @@ -17,8 +16,8 @@ constructor( private val includeStatus: Boolean?, private val includeTrip: Boolean?, private val time: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun vehicleId(): String = vehicleId @@ -31,17 +30,21 @@ constructor( fun time(): Optional = Optional.ofNullable(time) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.includeSchedule?.let { params.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { params.put("includeStatus", listOf(it.toString())) } - this.includeTrip?.let { params.put("includeTrip", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } + this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } + this.includeTrip?.let { queryParams.put("includeTrip", listOf(it.toString())) } + this.time?.let { queryParams.put("time", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -51,25 +54,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripForVehicleRetrieveParams && this.vehicleId == other.vehicleId && this.includeSchedule == other.includeSchedule && this.includeStatus == other.includeStatus && this.includeTrip == other.includeTrip && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(vehicleId, includeSchedule, includeStatus, includeTrip, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripForVehicleRetrieveParams{vehicleId=$vehicleId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, includeTrip=$includeTrip, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -85,18 +69,18 @@ constructor( private var includeStatus: Boolean? = null private var includeTrip: Boolean? = null private var time: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(tripForVehicleRetrieveParams: TripForVehicleRetrieveParams) = apply { - this.vehicleId = tripForVehicleRetrieveParams.vehicleId - this.includeSchedule = tripForVehicleRetrieveParams.includeSchedule - this.includeStatus = tripForVehicleRetrieveParams.includeStatus - this.includeTrip = tripForVehicleRetrieveParams.includeTrip - this.time = tripForVehicleRetrieveParams.time - additionalHeaders(tripForVehicleRetrieveParams.additionalHeaders) - additionalQueryParams(tripForVehicleRetrieveParams.additionalQueryParams) + vehicleId = tripForVehicleRetrieveParams.vehicleId + includeSchedule = tripForVehicleRetrieveParams.includeSchedule + includeStatus = tripForVehicleRetrieveParams.includeStatus + includeTrip = tripForVehicleRetrieveParams.includeTrip + time = tripForVehicleRetrieveParams.time + additionalHeaders = tripForVehicleRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tripForVehicleRetrieveParams.additionalQueryParams.toBuilder() } fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } @@ -124,6 +108,11 @@ constructor( /** Time parameter to query the system at a specific time (optional). */ fun time(time: Long) = apply { this.time = time } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -134,29 +123,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -169,33 +171,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): TripForVehicleRetrieveParams = @@ -205,14 +213,21 @@ constructor( includeStatus, includeTrip, time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripForVehicleRetrieveParams && vehicleId == other.vehicleId && includeSchedule == other.includeSchedule && includeStatus == other.includeStatus && includeTrip == other.includeTrip && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(vehicleId, includeSchedule, includeStatus, includeTrip, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripForVehicleRetrieveParams{vehicleId=$vehicleId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, includeTrip=$includeTrip, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt index f81f2a8..3e30f24 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt @@ -716,17 +716,14 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" @@ -737,17 +734,14 @@ private constructor( return true } - return /* spotless:off */ other is Schedule && this.frequency == other.frequency && this.nextTripId == other.nextTripId && this.previousTripId == other.previousTripId && this.stopTimes == other.stopTimes && this.timeZone == other.timeZone && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schedule && frequency == other.frequency && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" @@ -1628,17 +1622,14 @@ private constructor( return true } - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1745,17 +1736,14 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1766,17 +1754,14 @@ private constructor( return true } - return /* spotless:off */ other is Status && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -1787,17 +1772,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.frequency == other.frequency && this.schedule == other.schedule && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.tripId == other.tripId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(frequency, schedule, serviceDate, situationIds, status, tripId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, schedule, serviceDate, situationIds, status, tripId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, tripId=$tripId, additionalProperties=$additionalProperties}" @@ -1808,17 +1790,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -1829,17 +1808,14 @@ private constructor( return true } - return /* spotless:off */ other is TripForVehicleRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripForVehicleRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripForVehicleRetrieveResponse{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/TripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt index 76f1f30..fffa5d4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt @@ -2,25 +2,28 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripRetrieveParams constructor( private val tripId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun tripId(): String = tripId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,25 +32,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripRetrieveParams && this.tripId == other.tripId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(tripId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripRetrieveParams{tripId=$tripId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -59,18 +43,23 @@ constructor( class Builder { private var tripId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(tripRetrieveParams: TripRetrieveParams) = apply { - this.tripId = tripRetrieveParams.tripId - additionalHeaders(tripRetrieveParams.additionalHeaders) - additionalQueryParams(tripRetrieveParams.additionalQueryParams) + tripId = tripRetrieveParams.tripId + additionalHeaders = tripRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tripRetrieveParams.additionalQueryParams.toBuilder() } fun tripId(tripId: String) = apply { this.tripId = tripId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -81,29 +70,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -116,46 +118,59 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): TripRetrieveParams = TripRetrieveParams( checkNotNull(tripId) { "`tripId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripRetrieveParams && tripId == other.tripId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(tripId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripRetrieveParams{tripId=$tripId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt index 4377e27..097630f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt @@ -483,17 +483,14 @@ private constructor( return true } - return /* spotless:off */ other is Entry && this.blockId == other.blockId && this.directionId == other.directionId && this.id == other.id && this.peakOffpeak == other.peakOffpeak && this.routeId == other.routeId && this.routeShortName == other.routeShortName && this.serviceId == other.serviceId && this.shapeId == other.shapeId && this.timeZone == other.timeZone && this.tripHeadsign == other.tripHeadsign && this.tripShortName == other.tripShortName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && blockId == other.blockId && directionId == other.directionId && id == other.id && peakOffpeak == other.peakOffpeak && routeId == other.routeId && routeShortName == other.routeShortName && serviceId == other.serviceId && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Entry{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" @@ -504,17 +501,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.entry == other.entry && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(entry, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" @@ -525,17 +519,14 @@ private constructor( return true } - return /* spotless:off */ other is TripRetrieveResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripRetrieveResponse{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/TripsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt index 3c39b79..033afce 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt @@ -2,12 +2,11 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripsForLocationListParams @@ -19,8 +18,8 @@ constructor( private val includeSchedule: Boolean?, private val includeTrip: Boolean?, private val time: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun lat(): Double = lat @@ -37,41 +36,26 @@ constructor( fun time(): Optional = Optional.ofNullable(time) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.lat.let { params.put("lat", listOf(it.toString())) } - this.latSpan.let { params.put("latSpan", listOf(it.toString())) } - this.lon.let { params.put("lon", listOf(it.toString())) } - this.lonSpan.let { params.put("lonSpan", listOf(it.toString())) } - this.includeSchedule?.let { params.put("includeSchedule", listOf(it.toString())) } - this.includeTrip?.let { params.put("includeTrip", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() - } - - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsForLocationListParams && this.lat == other.lat && this.latSpan == other.latSpan && this.lon == other.lon && this.lonSpan == other.lonSpan && this.includeSchedule == other.includeSchedule && this.includeTrip == other.includeTrip && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(lat, latSpan, lon, lonSpan, includeSchedule, includeTrip, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + @JvmSynthetic + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.lat.let { queryParams.put("lat", listOf(it.toString())) } + this.latSpan.let { queryParams.put("latSpan", listOf(it.toString())) } + this.lon.let { queryParams.put("lon", listOf(it.toString())) } + this.lonSpan.let { queryParams.put("lonSpan", listOf(it.toString())) } + this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } + this.includeTrip?.let { queryParams.put("includeTrip", listOf(it.toString())) } + this.time?.let { queryParams.put("time", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - override fun toString() = - "TripsForLocationListParams{lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, includeSchedule=$includeSchedule, includeTrip=$includeTrip, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -89,20 +73,20 @@ constructor( private var includeSchedule: Boolean? = null private var includeTrip: Boolean? = null private var time: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(tripsForLocationListParams: TripsForLocationListParams) = apply { - this.lat = tripsForLocationListParams.lat - this.latSpan = tripsForLocationListParams.latSpan - this.lon = tripsForLocationListParams.lon - this.lonSpan = tripsForLocationListParams.lonSpan - this.includeSchedule = tripsForLocationListParams.includeSchedule - this.includeTrip = tripsForLocationListParams.includeTrip - this.time = tripsForLocationListParams.time - additionalHeaders(tripsForLocationListParams.additionalHeaders) - additionalQueryParams(tripsForLocationListParams.additionalQueryParams) + lat = tripsForLocationListParams.lat + latSpan = tripsForLocationListParams.latSpan + lon = tripsForLocationListParams.lon + lonSpan = tripsForLocationListParams.lonSpan + includeSchedule = tripsForLocationListParams.includeSchedule + includeTrip = tripsForLocationListParams.includeTrip + time = tripsForLocationListParams.time + additionalHeaders = tripsForLocationListParams.additionalHeaders.toBuilder() + additionalQueryParams = tripsForLocationListParams.additionalQueryParams.toBuilder() } /** The latitude coordinate of the search center */ @@ -130,6 +114,11 @@ constructor( /** Specific time for the query. Defaults to the current time. */ fun time(time: Long) = apply { this.time = time } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -140,29 +129,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -175,33 +177,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): TripsForLocationListParams = @@ -213,14 +221,21 @@ constructor( includeSchedule, includeTrip, time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripsForLocationListParams && lat == other.lat && latSpan == other.latSpan && lon == other.lon && lonSpan == other.lonSpan && includeSchedule == other.includeSchedule && includeTrip == other.includeTrip && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(lat, latSpan, lon, lonSpan, includeSchedule, includeTrip, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripsForLocationListParams{lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, includeSchedule=$includeSchedule, includeTrip=$includeTrip, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt index 62bf5b0..d5485c4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt @@ -760,17 +760,14 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" @@ -781,17 +778,14 @@ private constructor( return true } - return /* spotless:off */ other is Schedule && this.frequency == other.frequency && this.nextTripId == other.nextTripId && this.previousTripId == other.previousTripId && this.stopTimes == other.stopTimes && this.timeZone == other.timeZone && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schedule && frequency == other.frequency && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" @@ -1674,17 +1668,14 @@ private constructor( return true } - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1791,17 +1782,14 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1812,17 +1800,14 @@ private constructor( return true } - return /* spotless:off */ other is Status && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -1833,17 +1818,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.frequency == other.frequency && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.tripId == other.tripId && this.schedule == other.schedule && this.status == other.status && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && tripId == other.tripId && schedule == other.schedule && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(frequency, serviceDate, situationIds, tripId, schedule, status, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, serviceDate, situationIds, tripId, schedule, status, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, tripId=$tripId, schedule=$schedule, status=$status, additionalProperties=$additionalProperties}" @@ -1854,17 +1836,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.outOfRange == other.outOfRange && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" @@ -1875,17 +1854,14 @@ private constructor( return true } - return /* spotless:off */ other is TripsForLocationListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripsForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripsForLocationListResponse{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/TripsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt index 2e87437..c28df08 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt @@ -2,12 +2,11 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripsForRouteListParams @@ -16,8 +15,8 @@ constructor( private val includeSchedule: Boolean?, private val includeStatus: Boolean?, private val time: Long?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun routeId(): String = routeId @@ -28,16 +27,20 @@ constructor( fun time(): Optional = Optional.ofNullable(time) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.includeSchedule?.let { params.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { params.put("includeStatus", listOf(it.toString())) } - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } + this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } + this.time?.let { queryParams.put("time", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -47,25 +50,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsForRouteListParams && this.routeId == other.routeId && this.includeSchedule == other.includeSchedule && this.includeStatus == other.includeStatus && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(routeId, includeSchedule, includeStatus, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "TripsForRouteListParams{routeId=$routeId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -80,17 +64,17 @@ constructor( private var includeSchedule: Boolean? = null private var includeStatus: Boolean? = null private var time: Long? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(tripsForRouteListParams: TripsForRouteListParams) = apply { - this.routeId = tripsForRouteListParams.routeId - this.includeSchedule = tripsForRouteListParams.includeSchedule - this.includeStatus = tripsForRouteListParams.includeStatus - this.time = tripsForRouteListParams.time - additionalHeaders(tripsForRouteListParams.additionalHeaders) - additionalQueryParams(tripsForRouteListParams.additionalQueryParams) + routeId = tripsForRouteListParams.routeId + includeSchedule = tripsForRouteListParams.includeSchedule + includeStatus = tripsForRouteListParams.includeStatus + time = tripsForRouteListParams.time + additionalHeaders = tripsForRouteListParams.additionalHeaders.toBuilder() + additionalQueryParams = tripsForRouteListParams.additionalQueryParams.toBuilder() } fun routeId(routeId: String) = apply { this.routeId = routeId } @@ -109,6 +93,11 @@ constructor( /** Query the system at a specific time. Useful for testing. */ fun time(time: Long) = apply { this.time = time } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -119,29 +108,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -154,33 +156,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): TripsForRouteListParams = @@ -189,14 +197,21 @@ constructor( includeSchedule, includeStatus, time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripsForRouteListParams && routeId == other.routeId && includeSchedule == other.includeSchedule && includeStatus == other.includeStatus && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(routeId, includeSchedule, includeStatus, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TripsForRouteListParams{routeId=$routeId, includeSchedule=$includeSchedule, includeStatus=$includeStatus, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt index e048b4e..aa65c0a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt @@ -736,17 +736,14 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && this.arrivalTime == other.arrivalTime && this.departureTime == other.departureTime && this.distanceAlongTrip == other.distanceAlongTrip && this.historicalOccupancy == other.historicalOccupancy && this.stopHeadsign == other.stopHeadsign && this.stopId == other.stopId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" @@ -757,17 +754,14 @@ private constructor( return true } - return /* spotless:off */ other is Schedule && this.frequency == other.frequency && this.nextTripId == other.nextTripId && this.previousTripId == other.previousTripId && this.stopTimes == other.stopTimes && this.timeZone == other.timeZone && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schedule && frequency == other.frequency && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" @@ -1650,17 +1644,14 @@ private constructor( return true } - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1767,17 +1758,14 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1788,17 +1776,14 @@ private constructor( return true } - return /* spotless:off */ other is Status && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -1809,17 +1794,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.frequency == other.frequency && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.tripId == other.tripId && this.schedule == other.schedule && this.status == other.status && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && tripId == other.tripId && schedule == other.schedule && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(frequency, serviceDate, situationIds, tripId, schedule, status, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(frequency, serviceDate, situationIds, tripId, schedule, status, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, tripId=$tripId, schedule=$schedule, status=$status, additionalProperties=$additionalProperties}" @@ -1830,17 +1812,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.limitExceeded == other.limitExceeded && this.list == other.list && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(limitExceeded, list, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" @@ -1851,17 +1830,14 @@ private constructor( return true } - return /* spotless:off */ other is TripsForRouteListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripsForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripsForRouteListResponse{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/VehiclesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt index 0fccd78..22c2d4e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt @@ -2,34 +2,37 @@ package org.onebusaway.models -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.toImmutable +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class VehiclesForAgencyListParams constructor( private val agencyId: String, private val time: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun agencyId(): String = agencyId fun time(): Optional = Optional.ofNullable(time) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.time?.let { params.put("time", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.time?.let { queryParams.put("time", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -39,25 +42,6 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VehiclesForAgencyListParams && this.agencyId == other.agencyId && this.time == other.time && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(agencyId, time, additionalHeaders, additionalQueryParams) /* spotless:on */ - } - - override fun toString() = - "VehiclesForAgencyListParams{agencyId=$agencyId, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -70,15 +54,15 @@ constructor( private var agencyId: String? = null private var time: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(vehiclesForAgencyListParams: VehiclesForAgencyListParams) = apply { - this.agencyId = vehiclesForAgencyListParams.agencyId - this.time = vehiclesForAgencyListParams.time - additionalHeaders(vehiclesForAgencyListParams.additionalHeaders) - additionalQueryParams(vehiclesForAgencyListParams.additionalQueryParams) + agencyId = vehiclesForAgencyListParams.agencyId + time = vehiclesForAgencyListParams.time + additionalHeaders = vehiclesForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = vehiclesForAgencyListParams.additionalQueryParams.toBuilder() } fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } @@ -86,6 +70,11 @@ constructor( /** Specific time for querying the status (timestamp format) */ fun time(time: String) = apply { this.time = time } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -96,29 +85,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -131,47 +133,60 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): VehiclesForAgencyListParams = VehiclesForAgencyListParams( checkNotNull(agencyId) { "`agencyId` is required but was not set" }, time, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is VehiclesForAgencyListParams && agencyId == other.agencyId && time == other.time && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(agencyId, time, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "VehiclesForAgencyListParams{agencyId=$agencyId, time=$time, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt index 6adbe4f..cd7ba9e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt @@ -598,17 +598,14 @@ private constructor( return true } - return /* spotless:off */ other is Location && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Location && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Location{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1491,17 +1488,14 @@ private constructor( return true } - return /* spotless:off */ other is LastKnownLocation && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1608,17 +1602,14 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.lat == other.lat && this.lon == other.lon && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(lat, lon, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" @@ -1629,17 +1620,14 @@ private constructor( return true } - return /* spotless:off */ other is TripStatus && this.activeTripId == other.activeTripId && this.blockTripSequence == other.blockTripSequence && this.closestStop == other.closestStop && this.closestStopTimeOffset == other.closestStopTimeOffset && this.distanceAlongTrip == other.distanceAlongTrip && this.frequency == other.frequency && this.lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && this.lastKnownLocation == other.lastKnownLocation && this.lastKnownOrientation == other.lastKnownOrientation && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.lastUpdateTime == other.lastUpdateTime && this.nextStop == other.nextStop && this.nextStopTimeOffset == other.nextStopTimeOffset && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.orientation == other.orientation && this.phase == other.phase && this.position == other.position && this.predicted == other.predicted && this.scheduleDeviation == other.scheduleDeviation && this.scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && this.serviceDate == other.serviceDate && this.situationIds == other.situationIds && this.status == other.status && this.totalDistanceAlongTrip == other.totalDistanceAlongTrip && this.vehicleId == other.vehicleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" @@ -1650,17 +1638,14 @@ private constructor( return true } - return /* spotless:off */ other is List && this.vehicleId == other.vehicleId && this.lastUpdateTime == other.lastUpdateTime && this.lastLocationUpdateTime == other.lastLocationUpdateTime && this.location == other.location && this.tripId == other.tripId && this.tripStatus == other.tripStatus && this.occupancyCapacity == other.occupancyCapacity && this.occupancyCount == other.occupancyCount && this.occupancyStatus == other.occupancyStatus && this.phase == other.phase && this.status == other.status && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && vehicleId == other.vehicleId && lastUpdateTime == other.lastUpdateTime && lastLocationUpdateTime == other.lastLocationUpdateTime && location == other.location && tripId == other.tripId && tripStatus == other.tripStatus && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(vehicleId, lastUpdateTime, lastLocationUpdateTime, location, tripId, tripStatus, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(vehicleId, lastUpdateTime, lastLocationUpdateTime, location, tripId, tripStatus, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "List{vehicleId=$vehicleId, lastUpdateTime=$lastUpdateTime, lastLocationUpdateTime=$lastLocationUpdateTime, location=$location, tripId=$tripId, tripStatus=$tripStatus, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, status=$status, additionalProperties=$additionalProperties}" @@ -1671,15 +1656,14 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.list == other.list && this.limitExceeded == other.limitExceeded && this.references == other.references && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && list == other.list && limitExceeded == other.limitExceeded && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(list, limitExceeded, references, additionalProperties) /* spotless:on */ - } - return hashCode - } + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(list, limitExceeded, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode override fun toString() = "Data{list=$list, limitExceeded=$limitExceeded, references=$references, additionalProperties=$additionalProperties}" @@ -1690,17 +1674,14 @@ private constructor( return true } - return /* spotless:off */ other is VehiclesForAgencyListResponse && this.code == other.code && this.currentTime == other.currentTime && this.text == other.text && this.version == other.version && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is VehiclesForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(code, currentTime, text, version, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "VehiclesForAgencyListResponse{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/AgenciesWithCoverageServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt index 323fc27..d71c3ec 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt @@ -38,9 +38,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "agencies-with-coverage.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt index cb99dec..f60ba45 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "agency", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt index 44a3670..204abfe 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt @@ -42,9 +42,9 @@ constructor( "arrival-and-departure-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -77,9 +77,9 @@ constructor( "arrivals-and-departures-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt index a0f011e..9f096ec 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "block", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt index 4ab63ba..a5fca9d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "config.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt index fb53cef..9ce90d7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt @@ -35,9 +35,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "current-time.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt index d1fdd21..faffec9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt @@ -39,9 +39,9 @@ constructor( "report-problem-with-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt index a9684b4..5f05c95 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt @@ -39,9 +39,9 @@ constructor( "report-problem-with-trip", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt index 946e9e5..5eff280 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "route-ids-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt index 2053d9f..aefd043 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "route", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt index be8954a..e224551 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "routes-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt index 3da5cf6..c064084 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt @@ -35,9 +35,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "routes-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt index 4d0fed3..8becc41 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "schedule-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt index 5b4b0f3..2e7d2db 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "schedule-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt index 0dd6fb7..31e79fa 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt @@ -35,9 +35,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "search", "route.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt index e644aa3..548d135 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt @@ -35,9 +35,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "search", "stop.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt index 456938b..62212c7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "shape", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt index 80f9fe1..ac255ef 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "stop-ids-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt index 134682e..224c85b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "stop", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt index e77c0d7..2014540 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "stops-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt index e646761..e8c9059 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt @@ -35,9 +35,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "stops-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt index f65a3d9..37dfda5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "stops-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt index 653962f..7327ed8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt @@ -35,9 +35,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trip-details", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt index 222c4ce..3fcabfc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "trip-for-vehicle", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt index 784b015..d0b805c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trip", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt index d4eb6e1..d94a02c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt @@ -35,9 +35,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trips-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt index 0ab7488..56fa6a6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "trips-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt index 81658bb..8041ee4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( "vehicles-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt index 1c8cfeb..96e220f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt @@ -37,9 +37,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "agencies-with-coverage.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt index c39bf09..601f734 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt @@ -33,9 +33,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "agency", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt index aa760e4..a2b5c2b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt @@ -41,9 +41,9 @@ constructor( "arrival-and-departure-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -75,9 +75,9 @@ constructor( "arrivals-and-departures-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt index c540ec2..e548168 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt @@ -33,9 +33,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "block", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt index 574e7b2..559ee0e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt @@ -33,9 +33,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "config.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt index b5abf2f..4c2fbb3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "current-time.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt index fc36bc6..96cc31f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt @@ -38,9 +38,9 @@ constructor( "report-problem-with-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt index e6b700e..58edddb 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt @@ -38,9 +38,9 @@ constructor( "report-problem-with-trip", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt index b6f67da..f8bc0a8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "route-ids-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt index 0e6ea10..34b2b54 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt @@ -33,9 +33,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "route", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt index 858cf23..635e3ec 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "routes-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt index 0abe6fc..224ef56 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "routes-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt index 00372d5..e8258ab 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "schedule-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt index bbeb9f0..d3e5860 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "schedule-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt index c772d84..7f891ca 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "search", "route.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt index 4392c97..1d11851 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "search", "stop.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt index 72b6132..688e7f9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt @@ -33,9 +33,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "shape", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt index e78aca1..44057c5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "stop-ids-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt index 9a72422..408115e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt @@ -33,9 +33,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "stop", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt index 6b64894..5c47981 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "stops-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt index 89b6807..c372642 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "stops-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt index f5a5459..747794f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "stops-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt index 4229393..6715731 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trip-details", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt index a1251db..e70fa50 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "trip-for-vehicle", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt index 484fe4c..91e1972 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt @@ -33,9 +33,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trip", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt index 7133779..7505571 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt @@ -34,9 +34,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trips-for-location.json") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt index b7f5799..029f847 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "trips-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt index 65a44c4..5bcd201 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt @@ -39,9 +39,9 @@ constructor( "vehicles-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HttpRequestTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HttpRequestTest.kt deleted file mode 100644 index 1a19904..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HttpRequestTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package org.onebusaway.core.http - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class HttpRequestTest { - - @Test - fun caseInsensitiveHeadersAccessors() { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .putHeader("something_lowercase", "lowercase") - .putHeader("Something_Capitalized", "Capitalized") - .putHeader("SOMETHING_UPPERCASE", "UPPERCASE") - .build() - assertThat(request.headers.get("SOMETHING_LOWERCASE").getOrNull(0)).isEqualTo("lowercase") - assertThat(request.headers.get("something_capitalized").getOrNull(0)) - .isEqualTo("Capitalized") - assertThat(request.headers.get("Something_Uppercase").getOrNull(0)).isEqualTo("UPPERCASE") - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt index a926379..af00f65 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt @@ -5,6 +5,7 @@ package org.onebusaway.models import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ArrivalAndDepartureListParamsTest { @@ -28,18 +29,18 @@ class ArrivalAndDepartureListParamsTest { .minutesBefore(123L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() - val expected = mutableMapOf>() - expected.put("minutesAfter", listOf("123")) - expected.put("minutesBefore", listOf("123")) - expected.put("time", listOf("2019-12-27T18:11:19.117Z")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("minutesAfter", "123") + expected.put("minutesBefore", "123") + expected.put("time", "2019-12-27T18:11:19.117Z") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ArrivalAndDepartureListParams.builder().stopId("stopID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt index 1dcf6c7..5cf2300 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ArrivalAndDepartureRetrieveParamsTest { @@ -31,13 +32,13 @@ class ArrivalAndDepartureRetrieveParamsTest { .time(123L) .vehicleId("vehicleId") .build() - val expected = mutableMapOf>() - expected.put("serviceDate", listOf("123")) - expected.put("tripId", listOf("tripId")) - expected.put("stopSequence", listOf("123")) - expected.put("time", listOf("123")) - expected.put("vehicleId", listOf("vehicleId")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("serviceDate", "123") + expected.put("tripId", "tripId") + expected.put("stopSequence", "123") + expected.put("time", "123") + expected.put("vehicleId", "vehicleId") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -48,10 +49,10 @@ class ArrivalAndDepartureRetrieveParamsTest { .serviceDate(123L) .tripId("tripId") .build() - val expected = mutableMapOf>() - expected.put("serviceDate", listOf("123")) - expected.put("tripId", listOf("tripId")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("serviceDate", "123") + expected.put("tripId", "tripId") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt index ca3f9e6..c072ad0 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ReportProblemWithStopRetrieveParamsTest { @@ -31,23 +32,20 @@ class ReportProblemWithStopRetrieveParamsTest { .userLocationAccuracy(42.23) .userLon(42.23) .build() - val expected = mutableMapOf>() - expected.put( - "code", - listOf(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG.toString()) - ) - expected.put("userComment", listOf("userComment")) - expected.put("userLat", listOf("42.23")) - expected.put("userLocationAccuracy", listOf("42.23")) - expected.put("userLon", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("code", ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG.toString()) + expected.put("userComment", "userComment") + expected.put("userLat", "42.23") + expected.put("userLocationAccuracy", "42.23") + expected.put("userLon", "42.23") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ReportProblemWithStopRetrieveParams.builder().stopId("stopID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt index 64ed4cc..36d0286 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ReportProblemWithTripRetrieveParamsTest { @@ -41,28 +42,25 @@ class ReportProblemWithTripRetrieveParamsTest { .userVehicleNumber("userVehicleNumber") .vehicleId("vehicleID") .build() - val expected = mutableMapOf>() - expected.put( - "code", - listOf(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME.toString()) - ) - expected.put("serviceDate", listOf("123")) - expected.put("stopID", listOf("stopID")) - expected.put("userComment", listOf("userComment")) - expected.put("userLat", listOf("42.23")) - expected.put("userLocationAccuracy", listOf("42.23")) - expected.put("userLon", listOf("42.23")) - expected.put("userOnVehicle", listOf("true")) - expected.put("userVehicleNumber", listOf("userVehicleNumber")) - expected.put("vehicleID", listOf("vehicleID")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("code", ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME.toString()) + expected.put("serviceDate", "123") + expected.put("stopID", "stopID") + expected.put("userComment", "userComment") + expected.put("userLat", "42.23") + expected.put("userLocationAccuracy", "42.23") + expected.put("userLon", "42.23") + expected.put("userOnVehicle", "true") + expected.put("userVehicleNumber", "userVehicleNumber") + expected.put("vehicleID", "vehicleID") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ReportProblemWithTripRetrieveParams.builder().tripId("tripID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt index 946a91a..5f7fde3 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class RoutesForLocationListParamsTest { @@ -31,22 +32,22 @@ class RoutesForLocationListParamsTest { .query("query") .radius(42.23) .build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("lon", listOf("42.23")) - expected.put("latSpan", listOf("42.23")) - expected.put("lonSpan", listOf("42.23")) - expected.put("query", listOf("query")) - expected.put("radius", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("lat", "42.23") + expected.put("lon", "42.23") + expected.put("latSpan", "42.23") + expected.put("lonSpan", "42.23") + expected.put("query", "query") + expected.put("radius", "42.23") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = RoutesForLocationListParams.builder().lat(42.23).lon(42.23).build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("lon", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("lat", "42.23") + expected.put("lon", "42.23") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt index 98f2520..0d0db68 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt @@ -5,6 +5,7 @@ package org.onebusaway.models import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ScheduleForRouteRetrieveParamsTest { @@ -24,16 +25,16 @@ class ScheduleForRouteRetrieveParamsTest { .routeId("routeID") .date(LocalDate.parse("2019-12-27")) .build() - val expected = mutableMapOf>() - expected.put("date", listOf("2019-12-27")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("date", "2019-12-27") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ScheduleForRouteRetrieveParams.builder().routeId("routeID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt index 645d47e..152488d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt @@ -5,6 +5,7 @@ package org.onebusaway.models import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class ScheduleForStopRetrieveParamsTest { @@ -24,16 +25,16 @@ class ScheduleForStopRetrieveParamsTest { .stopId("stopID") .date(LocalDate.parse("2019-12-27")) .build() - val expected = mutableMapOf>() - expected.put("date", listOf("2019-12-27")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("date", "2019-12-27") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ScheduleForStopRetrieveParams.builder().stopId("stopID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt index 1b2453d..2c1e5b5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class SearchForRouteListParamsTest { @@ -16,17 +17,17 @@ class SearchForRouteListParamsTest { @Test fun getQueryParams() { val params = SearchForRouteListParams.builder().input("input").maxCount(123L).build() - val expected = mutableMapOf>() - expected.put("input", listOf("input")) - expected.put("maxCount", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("input", "input") + expected.put("maxCount", "123") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = SearchForRouteListParams.builder().input("input").build() - val expected = mutableMapOf>() - expected.put("input", listOf("input")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("input", "input") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt index 1825b87..2bc2eb6 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class SearchForStopListParamsTest { @@ -16,17 +17,17 @@ class SearchForStopListParamsTest { @Test fun getQueryParams() { val params = SearchForStopListParams.builder().input("input").maxCount(123L).build() - val expected = mutableMapOf>() - expected.put("input", listOf("input")) - expected.put("maxCount", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("input", "input") + expected.put("maxCount", "123") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = SearchForStopListParams.builder().input("input").build() - val expected = mutableMapOf>() - expected.put("input", listOf("input")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("input", "input") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt index 07dde7e..71ad03a 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class StopsForLocationListParamsTest { @@ -31,22 +32,22 @@ class StopsForLocationListParamsTest { .query("query") .radius(42.23) .build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("lon", listOf("42.23")) - expected.put("latSpan", listOf("42.23")) - expected.put("lonSpan", listOf("42.23")) - expected.put("query", listOf("query")) - expected.put("radius", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("lat", "42.23") + expected.put("lon", "42.23") + expected.put("latSpan", "42.23") + expected.put("lonSpan", "42.23") + expected.put("query", "query") + expected.put("radius", "42.23") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = StopsForLocationListParams.builder().lat(42.23).lon(42.23).build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("lon", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("lat", "42.23") + expected.put("lon", "42.23") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt index 607e832..4a88cad 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class StopsForRouteListParamsTest { @@ -25,17 +26,17 @@ class StopsForRouteListParamsTest { .includePolylines(true) .time("time") .build() - val expected = mutableMapOf>() - expected.put("includePolylines", listOf("true")) - expected.put("time", listOf("time")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("includePolylines", "true") + expected.put("time", "time") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = StopsForRouteListParams.builder().routeId("routeID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt index 2e4eaa9..8cbf9f9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripDetailRetrieveParamsTest { @@ -31,20 +32,20 @@ class TripDetailRetrieveParamsTest { .serviceDate(123L) .time(123L) .build() - val expected = mutableMapOf>() - expected.put("includeSchedule", listOf("true")) - expected.put("includeStatus", listOf("true")) - expected.put("includeTrip", listOf("true")) - expected.put("serviceDate", listOf("123")) - expected.put("time", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("includeSchedule", "true") + expected.put("includeStatus", "true") + expected.put("includeTrip", "true") + expected.put("serviceDate", "123") + expected.put("time", "123") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = TripDetailRetrieveParams.builder().tripId("tripID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt index e30e5e3..0328185 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripForVehicleRetrieveParamsTest { @@ -29,19 +30,19 @@ class TripForVehicleRetrieveParamsTest { .includeTrip(true) .time(123L) .build() - val expected = mutableMapOf>() - expected.put("includeSchedule", listOf("true")) - expected.put("includeStatus", listOf("true")) - expected.put("includeTrip", listOf("true")) - expected.put("time", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("includeSchedule", "true") + expected.put("includeStatus", "true") + expected.put("includeTrip", "true") + expected.put("time", "123") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = TripForVehicleRetrieveParams.builder().vehicleId("vehicleID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt index e92df58..a58a49d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripsForLocationListParamsTest { @@ -33,15 +34,15 @@ class TripsForLocationListParamsTest { .includeTrip(true) .time(123L) .build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("latSpan", listOf("42.23")) - expected.put("lon", listOf("42.23")) - expected.put("lonSpan", listOf("42.23")) - expected.put("includeSchedule", listOf("true")) - expected.put("includeTrip", listOf("true")) - expected.put("time", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("lat", "42.23") + expected.put("latSpan", "42.23") + expected.put("lon", "42.23") + expected.put("lonSpan", "42.23") + expected.put("includeSchedule", "true") + expected.put("includeTrip", "true") + expected.put("time", "123") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -53,11 +54,11 @@ class TripsForLocationListParamsTest { .lon(42.23) .lonSpan(42.23) .build() - val expected = mutableMapOf>() - expected.put("lat", listOf("42.23")) - expected.put("latSpan", listOf("42.23")) - expected.put("lon", listOf("42.23")) - expected.put("lonSpan", listOf("42.23")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("lat", "42.23") + expected.put("latSpan", "42.23") + expected.put("lon", "42.23") + expected.put("lonSpan", "42.23") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt index 6914198..4d3e94e 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class TripsForRouteListParamsTest { @@ -27,18 +28,18 @@ class TripsForRouteListParamsTest { .includeStatus(true) .time(123L) .build() - val expected = mutableMapOf>() - expected.put("includeSchedule", listOf("true")) - expected.put("includeStatus", listOf("true")) - expected.put("time", listOf("123")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("includeSchedule", "true") + expected.put("includeStatus", "true") + expected.put("time", "123") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = TripsForRouteListParams.builder().routeId("routeID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt index 93762bd..3adc5c3 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt @@ -4,6 +4,7 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams import org.onebusaway.models.* class VehiclesForAgencyListParamsTest { @@ -16,16 +17,16 @@ class VehiclesForAgencyListParamsTest { @Test fun getQueryParams() { val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() - val expected = mutableMapOf>() - expected.put("time", listOf("time")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("time", "time") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt index 04f50bf..728df53 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt @@ -6,21 +6,20 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.put import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import com.google.common.collect.ImmutableListMultimap -import com.google.common.collect.ListMultimap import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.assertj.core.api.InstanceOfAssertFactories -import org.assertj.guava.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient import org.onebusaway.core.JsonString +import org.onebusaway.core.http.Headers import org.onebusaway.core.jsonMapper import org.onebusaway.errors.BadRequestException import org.onebusaway.errors.InternalServerException @@ -77,7 +76,11 @@ class ErrorHandlingTest { assertThatThrownBy({ client.currentTime().retrieve(params) }) .satisfies({ e -> - assertBadRequest(e, ImmutableListMultimap.of("Foo", "Bar"), ONEBUSAWAY_SDK_ERROR) + assertBadRequest( + e, + Headers.builder().put("Foo", "Bar").build(), + ONEBUSAWAY_SDK_ERROR + ) }) } @@ -94,7 +97,11 @@ class ErrorHandlingTest { assertThatThrownBy({ client.currentTime().retrieve(params) }) .satisfies({ e -> - assertUnauthorized(e, ImmutableListMultimap.of("Foo", "Bar"), ONEBUSAWAY_SDK_ERROR) + assertUnauthorized( + e, + Headers.builder().put("Foo", "Bar").build(), + ONEBUSAWAY_SDK_ERROR + ) }) } @@ -113,7 +120,7 @@ class ErrorHandlingTest { .satisfies({ e -> assertPermissionDenied( e, - ImmutableListMultimap.of("Foo", "Bar"), + Headers.builder().put("Foo", "Bar").build(), ONEBUSAWAY_SDK_ERROR ) }) @@ -132,7 +139,7 @@ class ErrorHandlingTest { assertThatThrownBy({ client.currentTime().retrieve(params) }) .satisfies({ e -> - assertNotFound(e, ImmutableListMultimap.of("Foo", "Bar"), ONEBUSAWAY_SDK_ERROR) + assertNotFound(e, Headers.builder().put("Foo", "Bar").build(), ONEBUSAWAY_SDK_ERROR) }) } @@ -151,7 +158,7 @@ class ErrorHandlingTest { .satisfies({ e -> assertUnprocessableEntity( e, - ImmutableListMultimap.of("Foo", "Bar"), + Headers.builder().put("Foo", "Bar").build(), ONEBUSAWAY_SDK_ERROR ) }) @@ -170,7 +177,11 @@ class ErrorHandlingTest { assertThatThrownBy({ client.currentTime().retrieve(params) }) .satisfies({ e -> - assertRateLimit(e, ImmutableListMultimap.of("Foo", "Bar"), ONEBUSAWAY_SDK_ERROR) + assertRateLimit( + e, + Headers.builder().put("Foo", "Bar").build(), + ONEBUSAWAY_SDK_ERROR + ) }) } @@ -189,7 +200,7 @@ class ErrorHandlingTest { .satisfies({ e -> assertInternalServer( e, - ImmutableListMultimap.of("Foo", "Bar"), + Headers.builder().put("Foo", "Bar").build(), ONEBUSAWAY_SDK_ERROR ) }) @@ -211,7 +222,7 @@ class ErrorHandlingTest { assertUnexpectedStatusCodeException( e, 999, - ImmutableListMultimap.of("Foo", "Bar"), + Headers.builder().put("Foo", "Bar").build(), toJson(ONEBUSAWAY_SDK_ERROR) ) }) @@ -239,11 +250,7 @@ class ErrorHandlingTest { assertThatThrownBy({ client.currentTime().retrieve(params) }) .satisfies({ e -> - assertBadRequest( - e, - ImmutableListMultimap.of(), - OnebusawaySdkError.builder().build() - ) + assertBadRequest(e, Headers.builder().build(), OnebusawaySdkError.builder().build()) }) } @@ -254,7 +261,7 @@ class ErrorHandlingTest { private fun assertUnexpectedStatusCodeException( throwable: Throwable, statusCode: Int, - headers: ListMultimap, + headers: Headers, responseBody: ByteArray ) { assertThat(throwable) @@ -264,13 +271,13 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(statusCode) assertThat(e.body()).isEqualTo(String(responseBody)) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } private fun assertBadRequest( throwable: Throwable, - headers: ListMultimap, + headers: Headers, error: OnebusawaySdkError ) { assertThat(throwable) @@ -278,13 +285,13 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(400) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } private fun assertUnauthorized( throwable: Throwable, - headers: ListMultimap, + headers: Headers, error: OnebusawaySdkError ) { assertThat(throwable) @@ -292,13 +299,13 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(401) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } private fun assertPermissionDenied( throwable: Throwable, - headers: ListMultimap, + headers: Headers, error: OnebusawaySdkError ) { assertThat(throwable) @@ -308,27 +315,23 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(403) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } - private fun assertNotFound( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { + private fun assertNotFound(throwable: Throwable, headers: Headers, error: OnebusawaySdkError) { assertThat(throwable) .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(404) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } private fun assertUnprocessableEntity( throwable: Throwable, - headers: ListMultimap, + headers: Headers, error: OnebusawaySdkError ) { assertThat(throwable) @@ -338,27 +341,23 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(422) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } - private fun assertRateLimit( - throwable: Throwable, - headers: ListMultimap, - error: OnebusawaySdkError - ) { + private fun assertRateLimit(throwable: Throwable, headers: Headers, error: OnebusawaySdkError) { assertThat(throwable) .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(429) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } private fun assertInternalServer( throwable: Throwable, - headers: ListMultimap, + headers: Headers, error: OnebusawaySdkError ) { assertThat(throwable) @@ -366,7 +365,12 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(500) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } + + private fun Headers.toMap(): Map> = + mutableMapOf>().also { map -> + names().forEach { map[it] = values(it) } + } } From 9f7aadf0b9229f441f1dbfed4b64035f195c3b1e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 30 Nov 2024 07:29:25 +0000 Subject: [PATCH 02/11] chore(internal): update example values (#72) --- .../ArrivalAndDepartureListParamsTest.kt | 12 ++-- .../ArrivalAndDepartureRetrieveParamsTest.kt | 24 ++++---- .../org/onebusaway/models/ReferencesTest.kt | 57 +++++++++---------- ...ReportProblemWithStopRetrieveParamsTest.kt | 18 +++--- ...ReportProblemWithTripRetrieveParamsTest.kt | 24 ++++---- .../onebusaway/models/ResponseWrapperTest.kt | 13 ++--- .../models/RoutesForLocationListParamsTest.kt | 36 ++++++------ .../models/SearchForRouteListParamsTest.kt | 6 +- .../models/SearchForStopListParamsTest.kt | 6 +- .../models/StopsForLocationListParamsTest.kt | 36 ++++++------ .../models/TripDetailRetrieveParamsTest.kt | 12 ++-- .../TripForVehicleRetrieveParamsTest.kt | 6 +- .../models/TripsForLocationListParamsTest.kt | 45 +++++++-------- .../models/TripsForRouteListParamsTest.kt | 6 +- .../ArrivalAndDepartureServiceTest.kt | 10 ++-- .../ReportProblemWithStopServiceTest.kt | 6 +- .../ReportProblemWithTripServiceTest.kt | 8 +-- .../blocking/RoutesForLocationServiceTest.kt | 10 ++-- .../blocking/SearchForRouteServiceTest.kt | 2 +- .../blocking/SearchForStopServiceTest.kt | 2 +- .../blocking/StopsForLocationServiceTest.kt | 10 ++-- .../blocking/TripDetailServiceTest.kt | 4 +- .../blocking/TripForVehicleServiceTest.kt | 2 +- .../blocking/TripsForLocationServiceTest.kt | 10 ++-- .../blocking/TripsForRouteServiceTest.kt | 2 +- 25 files changed, 176 insertions(+), 191 deletions(-) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt index af00f65..83bf404 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt @@ -14,8 +14,8 @@ class ArrivalAndDepartureListParamsTest { fun createArrivalAndDepartureListParams() { ArrivalAndDepartureListParams.builder() .stopId("stopID") - .minutesAfter(123L) - .minutesBefore(123L) + .minutesAfter(0L) + .minutesBefore(0L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() } @@ -25,13 +25,13 @@ class ArrivalAndDepartureListParamsTest { val params = ArrivalAndDepartureListParams.builder() .stopId("stopID") - .minutesAfter(123L) - .minutesBefore(123L) + .minutesAfter(0L) + .minutesBefore(0L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() val expected = QueryParams.builder() - expected.put("minutesAfter", "123") - expected.put("minutesBefore", "123") + expected.put("minutesAfter", "0") + expected.put("minutesBefore", "0") expected.put("time", "2019-12-27T18:11:19.117Z") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt index 5cf2300..bc60d54 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt @@ -13,10 +13,10 @@ class ArrivalAndDepartureRetrieveParamsTest { fun createArrivalAndDepartureRetrieveParams() { ArrivalAndDepartureRetrieveParams.builder() .stopId("stopID") - .serviceDate(123L) + .serviceDate(0L) .tripId("tripId") - .stopSequence(123L) - .time(123L) + .stopSequence(0L) + .time(0L) .vehicleId("vehicleId") .build() } @@ -26,17 +26,17 @@ class ArrivalAndDepartureRetrieveParamsTest { val params = ArrivalAndDepartureRetrieveParams.builder() .stopId("stopID") - .serviceDate(123L) + .serviceDate(0L) .tripId("tripId") - .stopSequence(123L) - .time(123L) + .stopSequence(0L) + .time(0L) .vehicleId("vehicleId") .build() val expected = QueryParams.builder() - expected.put("serviceDate", "123") + expected.put("serviceDate", "0") expected.put("tripId", "tripId") - expected.put("stopSequence", "123") - expected.put("time", "123") + expected.put("stopSequence", "0") + expected.put("time", "0") expected.put("vehicleId", "vehicleId") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @@ -46,11 +46,11 @@ class ArrivalAndDepartureRetrieveParamsTest { val params = ArrivalAndDepartureRetrieveParams.builder() .stopId("stopID") - .serviceDate(123L) + .serviceDate(0L) .tripId("tripId") .build() val expected = QueryParams.builder() - expected.put("serviceDate", "123") + expected.put("serviceDate", "0") expected.put("tripId", "tripId") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @@ -60,7 +60,7 @@ class ArrivalAndDepartureRetrieveParamsTest { val params = ArrivalAndDepartureRetrieveParams.builder() .stopId("stopID") - .serviceDate(123L) + .serviceDate(0L) .tripId("tripId") .build() assertThat(params).isNotNull 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 85bbd9b..f21fd6b 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 @@ -32,7 +32,7 @@ class ReferencesTest { References.Route.builder() .id("id") .agencyId("agencyId") - .type(123L) + .type(0L) .color("color") .description("description") .longName("longName") @@ -47,12 +47,12 @@ class ReferencesTest { listOf( References.Situation.builder() .id("id") - .creationTime(123L) + .creationTime(0L) .activeWindows( listOf( References.Situation.ActiveWindow.builder() - .from(123L) - .to(123L) + .from(0L) + .to(0L) .build() ) ) @@ -81,7 +81,7 @@ class ReferencesTest { .ConditionDetails .DiversionPath .builder() - .length(123L) + .length(0L) .levels("levels") .points("points") .build() @@ -101,8 +101,8 @@ class ReferencesTest { .publicationWindows( listOf( References.Situation.PublicationWindow.builder() - .from(123L) - .to(123L) + .from(0L) + .to(0L) .build() ) ) @@ -127,15 +127,15 @@ class ReferencesTest { listOf( References.Stop.builder() .id("id") - .lat(42.23) - .lon(42.23) + .lat(0.0) + .lon(0.0) .name("name") .parent("parent") .routeIds(listOf("string")) .staticRouteIds(listOf("string")) .code("code") .direction("direction") - .locationType(123L) + .locationType(0L) .wheelchairBoarding("wheelchairBoarding") .build() ) @@ -143,9 +143,9 @@ class ReferencesTest { .stopTimes( listOf( References.StopTime.builder() - .arrivalTime(123L) - .departureTime(123L) - .distanceAlongTrip(42.23) + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) .historicalOccupancy("historicalOccupancy") .stopHeadsign("stopHeadsign") .stopId("stopId") @@ -160,7 +160,7 @@ class ReferencesTest { .serviceId("serviceId") .blockId("blockId") .directionId("directionId") - .peakOffpeak(123L) + .peakOffpeak(0L) .routeShortName("routeShortName") .shapeId("shapeId") .timeZone("timeZone") @@ -191,7 +191,7 @@ class ReferencesTest { References.Route.builder() .id("id") .agencyId("agencyId") - .type(123L) + .type(0L) .color("color") .description("description") .longName("longName") @@ -205,11 +205,9 @@ class ReferencesTest { .containsExactly( References.Situation.builder() .id("id") - .creationTime(123L) + .creationTime(0L) .activeWindows( - listOf( - References.Situation.ActiveWindow.builder().from(123L).to(123L).build() - ) + listOf(References.Situation.ActiveWindow.builder().from(0L).to(0L).build()) ) .allAffects( listOf( @@ -234,7 +232,7 @@ class ReferencesTest { References.Situation.Consequence.ConditionDetails .DiversionPath .builder() - .length(123L) + .length(0L) .levels("levels") .points("points") .build() @@ -253,10 +251,7 @@ class ReferencesTest { ) .publicationWindows( listOf( - References.Situation.PublicationWindow.builder() - .from(123L) - .to(123L) - .build() + References.Situation.PublicationWindow.builder().from(0L).to(0L).build() ) ) .reason(References.Situation.Reason.EQUIPMENT_REASON) @@ -271,24 +266,24 @@ class ReferencesTest { .containsExactly( References.Stop.builder() .id("id") - .lat(42.23) - .lon(42.23) + .lat(0.0) + .lon(0.0) .name("name") .parent("parent") .routeIds(listOf("string")) .staticRouteIds(listOf("string")) .code("code") .direction("direction") - .locationType(123L) + .locationType(0L) .wheelchairBoarding("wheelchairBoarding") .build() ) assertThat(references.stopTimes()) .containsExactly( References.StopTime.builder() - .arrivalTime(123L) - .departureTime(123L) - .distanceAlongTrip(42.23) + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) .historicalOccupancy("historicalOccupancy") .stopHeadsign("stopHeadsign") .stopId("stopId") @@ -302,7 +297,7 @@ class ReferencesTest { .serviceId("serviceId") .blockId("blockId") .directionId("directionId") - .peakOffpeak(123L) + .peakOffpeak(0L) .routeShortName("routeShortName") .shapeId("shapeId") .timeZone("timeZone") diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt index c072ad0..c976e33 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt @@ -15,9 +15,9 @@ class ReportProblemWithStopRetrieveParamsTest { .stopId("stopID") .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) + .userLat(0.0) + .userLocationAccuracy(0.0) + .userLon(0.0) .build() } @@ -28,16 +28,16 @@ class ReportProblemWithStopRetrieveParamsTest { .stopId("stopID") .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) + .userLat(0.0) + .userLocationAccuracy(0.0) + .userLon(0.0) .build() val expected = QueryParams.builder() expected.put("code", ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG.toString()) expected.put("userComment", "userComment") - expected.put("userLat", "42.23") - expected.put("userLocationAccuracy", "42.23") - expected.put("userLon", "42.23") + expected.put("userLat", "0.0") + expected.put("userLocationAccuracy", "0.0") + expected.put("userLon", "0.0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt index 36d0286..bfd0980 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt @@ -14,12 +14,12 @@ class ReportProblemWithTripRetrieveParamsTest { ReportProblemWithTripRetrieveParams.builder() .tripId("tripID") .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) - .serviceDate(123L) + .serviceDate(0L) .stopId("stopID") .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) + .userLat(0.0) + .userLocationAccuracy(0.0) + .userLon(0.0) .userOnVehicle(true) .userVehicleNumber("userVehicleNumber") .vehicleId("vehicleID") @@ -32,24 +32,24 @@ class ReportProblemWithTripRetrieveParamsTest { ReportProblemWithTripRetrieveParams.builder() .tripId("tripID") .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) - .serviceDate(123L) + .serviceDate(0L) .stopId("stopID") .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) + .userLat(0.0) + .userLocationAccuracy(0.0) + .userLon(0.0) .userOnVehicle(true) .userVehicleNumber("userVehicleNumber") .vehicleId("vehicleID") .build() val expected = QueryParams.builder() expected.put("code", ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME.toString()) - expected.put("serviceDate", "123") + expected.put("serviceDate", "0") expected.put("stopID", "stopID") expected.put("userComment", "userComment") - expected.put("userLat", "42.23") - expected.put("userLocationAccuracy", "42.23") - expected.put("userLon", "42.23") + expected.put("userLat", "0.0") + expected.put("userLocationAccuracy", "0.0") + expected.put("userLon", "0.0") expected.put("userOnVehicle", "true") expected.put("userVehicleNumber", "userVehicleNumber") expected.put("vehicleID", "vehicleID") diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt index c9dabeb..92b875c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt @@ -10,16 +10,11 @@ class ResponseWrapperTest { @Test fun createResponseWrapper() { val responseWrapper = - ResponseWrapper.builder() - .code(123L) - .currentTime(123L) - .text("text") - .version(123L) - .build() + ResponseWrapper.builder().code(0L).currentTime(0L).text("text").version(0L).build() assertThat(responseWrapper).isNotNull - assertThat(responseWrapper.code()).isEqualTo(123L) - assertThat(responseWrapper.currentTime()).isEqualTo(123L) + assertThat(responseWrapper.code()).isEqualTo(0L) + assertThat(responseWrapper.currentTime()).isEqualTo(0L) assertThat(responseWrapper.text()).isEqualTo("text") - assertThat(responseWrapper.version()).isEqualTo(123L) + assertThat(responseWrapper.version()).isEqualTo(0L) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt index 5f7fde3..2f0cce9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt @@ -12,12 +12,12 @@ class RoutesForLocationListParamsTest { @Test fun createRoutesForLocationListParams() { RoutesForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) .query("query") - .radius(42.23) + .radius(0.0) .build() } @@ -25,29 +25,29 @@ class RoutesForLocationListParamsTest { fun getQueryParams() { val params = RoutesForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) .query("query") - .radius(42.23) + .radius(0.0) .build() val expected = QueryParams.builder() - expected.put("lat", "42.23") - expected.put("lon", "42.23") - expected.put("latSpan", "42.23") - expected.put("lonSpan", "42.23") + expected.put("lat", "0.0") + expected.put("lon", "0.0") + expected.put("latSpan", "0.0") + expected.put("lonSpan", "0.0") expected.put("query", "query") - expected.put("radius", "42.23") + expected.put("radius", "0.0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = RoutesForLocationListParams.builder().lat(42.23).lon(42.23).build() + val params = RoutesForLocationListParams.builder().lat(0.0).lon(0.0).build() val expected = QueryParams.builder() - expected.put("lat", "42.23") - expected.put("lon", "42.23") + expected.put("lat", "0.0") + expected.put("lon", "0.0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt index 2c1e5b5..e6c1118 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt @@ -11,15 +11,15 @@ class SearchForRouteListParamsTest { @Test fun createSearchForRouteListParams() { - SearchForRouteListParams.builder().input("input").maxCount(123L).build() + SearchForRouteListParams.builder().input("input").maxCount(0L).build() } @Test fun getQueryParams() { - val params = SearchForRouteListParams.builder().input("input").maxCount(123L).build() + val params = SearchForRouteListParams.builder().input("input").maxCount(0L).build() val expected = QueryParams.builder() expected.put("input", "input") - expected.put("maxCount", "123") + expected.put("maxCount", "0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt index 2bc2eb6..2ac9d86 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt @@ -11,15 +11,15 @@ class SearchForStopListParamsTest { @Test fun createSearchForStopListParams() { - SearchForStopListParams.builder().input("input").maxCount(123L).build() + SearchForStopListParams.builder().input("input").maxCount(0L).build() } @Test fun getQueryParams() { - val params = SearchForStopListParams.builder().input("input").maxCount(123L).build() + val params = SearchForStopListParams.builder().input("input").maxCount(0L).build() val expected = QueryParams.builder() expected.put("input", "input") - expected.put("maxCount", "123") + expected.put("maxCount", "0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt index 71ad03a..0f598fe 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt @@ -12,12 +12,12 @@ class StopsForLocationListParamsTest { @Test fun createStopsForLocationListParams() { StopsForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) .query("query") - .radius(42.23) + .radius(0.0) .build() } @@ -25,29 +25,29 @@ class StopsForLocationListParamsTest { fun getQueryParams() { val params = StopsForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) .query("query") - .radius(42.23) + .radius(0.0) .build() val expected = QueryParams.builder() - expected.put("lat", "42.23") - expected.put("lon", "42.23") - expected.put("latSpan", "42.23") - expected.put("lonSpan", "42.23") + expected.put("lat", "0.0") + expected.put("lon", "0.0") + expected.put("latSpan", "0.0") + expected.put("lonSpan", "0.0") expected.put("query", "query") - expected.put("radius", "42.23") + expected.put("radius", "0.0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = StopsForLocationListParams.builder().lat(42.23).lon(42.23).build() + val params = StopsForLocationListParams.builder().lat(0.0).lon(0.0).build() val expected = QueryParams.builder() - expected.put("lat", "42.23") - expected.put("lon", "42.23") + expected.put("lat", "0.0") + expected.put("lon", "0.0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt index 8cbf9f9..34626fe 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt @@ -16,8 +16,8 @@ class TripDetailRetrieveParamsTest { .includeSchedule(true) .includeStatus(true) .includeTrip(true) - .serviceDate(123L) - .time(123L) + .serviceDate(0L) + .time(0L) .build() } @@ -29,15 +29,15 @@ class TripDetailRetrieveParamsTest { .includeSchedule(true) .includeStatus(true) .includeTrip(true) - .serviceDate(123L) - .time(123L) + .serviceDate(0L) + .time(0L) .build() val expected = QueryParams.builder() expected.put("includeSchedule", "true") expected.put("includeStatus", "true") expected.put("includeTrip", "true") - expected.put("serviceDate", "123") - expected.put("time", "123") + expected.put("serviceDate", "0") + expected.put("time", "0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt index 0328185..9f20cad 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt @@ -16,7 +16,7 @@ class TripForVehicleRetrieveParamsTest { .includeSchedule(true) .includeStatus(true) .includeTrip(true) - .time(123L) + .time(0L) .build() } @@ -28,13 +28,13 @@ class TripForVehicleRetrieveParamsTest { .includeSchedule(true) .includeStatus(true) .includeTrip(true) - .time(123L) + .time(0L) .build() val expected = QueryParams.builder() expected.put("includeSchedule", "true") expected.put("includeStatus", "true") expected.put("includeTrip", "true") - expected.put("time", "123") + expected.put("time", "0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt index a58a49d..2b4ef9b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt @@ -12,13 +12,13 @@ class TripsForLocationListParamsTest { @Test fun createTripsForLocationListParams() { TripsForLocationListParams.builder() - .lat(42.23) - .latSpan(42.23) - .lon(42.23) - .lonSpan(42.23) + .lat(0.0) + .latSpan(0.0) + .lon(0.0) + .lonSpan(0.0) .includeSchedule(true) .includeTrip(true) - .time(123L) + .time(0L) .build() } @@ -26,39 +26,34 @@ class TripsForLocationListParamsTest { fun getQueryParams() { val params = TripsForLocationListParams.builder() - .lat(42.23) - .latSpan(42.23) - .lon(42.23) - .lonSpan(42.23) + .lat(0.0) + .latSpan(0.0) + .lon(0.0) + .lonSpan(0.0) .includeSchedule(true) .includeTrip(true) - .time(123L) + .time(0L) .build() val expected = QueryParams.builder() - expected.put("lat", "42.23") - expected.put("latSpan", "42.23") - expected.put("lon", "42.23") - expected.put("lonSpan", "42.23") + expected.put("lat", "0.0") + expected.put("latSpan", "0.0") + expected.put("lon", "0.0") + expected.put("lonSpan", "0.0") expected.put("includeSchedule", "true") expected.put("includeTrip", "true") - expected.put("time", "123") + expected.put("time", "0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = - TripsForLocationListParams.builder() - .lat(42.23) - .latSpan(42.23) - .lon(42.23) - .lonSpan(42.23) - .build() + TripsForLocationListParams.builder().lat(0.0).latSpan(0.0).lon(0.0).lonSpan(0.0).build() val expected = QueryParams.builder() - expected.put("lat", "42.23") - expected.put("latSpan", "42.23") - expected.put("lon", "42.23") - expected.put("lonSpan", "42.23") + expected.put("lat", "0.0") + expected.put("latSpan", "0.0") + expected.put("lon", "0.0") + expected.put("lonSpan", "0.0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt index 4d3e94e..e7ce7f6 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt @@ -15,7 +15,7 @@ class TripsForRouteListParamsTest { .routeId("routeID") .includeSchedule(true) .includeStatus(true) - .time(123L) + .time(0L) .build() } @@ -26,12 +26,12 @@ class TripsForRouteListParamsTest { .routeId("routeID") .includeSchedule(true) .includeStatus(true) - .time(123L) + .time(0L) .build() val expected = QueryParams.builder() expected.put("includeSchedule", "true") expected.put("includeStatus", "true") - expected.put("time", "123") + expected.put("time", "0") assertThat(params.getQueryParams()).isEqualTo(expected.build()) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt index 8e0a8ee..7517806 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt @@ -24,10 +24,10 @@ class ArrivalAndDepartureServiceTest { arrivalAndDepartureService.retrieve( ArrivalAndDepartureRetrieveParams.builder() .stopId("stopID") - .serviceDate(123L) + .serviceDate(0L) .tripId("tripId") - .stopSequence(123L) - .time(123L) + .stopSequence(0L) + .time(0L) .vehicleId("vehicleId") .build() ) @@ -46,8 +46,8 @@ class ArrivalAndDepartureServiceTest { arrivalAndDepartureService.list( ArrivalAndDepartureListParams.builder() .stopId("stopID") - .minutesAfter(123L) - .minutesBefore(123L) + .minutesAfter(0L) + .minutesBefore(0L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt index c736e3d..5079042 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt @@ -25,9 +25,9 @@ class ReportProblemWithStopServiceTest { .stopId("stopID") .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) + .userLat(0.0) + .userLocationAccuracy(0.0) + .userLon(0.0) .build() ) println(responseWrapper) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt index cef72e1..4603162 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt @@ -24,12 +24,12 @@ class ReportProblemWithTripServiceTest { ReportProblemWithTripRetrieveParams.builder() .tripId("tripID") .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) - .serviceDate(123L) + .serviceDate(0L) .stopId("stopID") .userComment("userComment") - .userLat(42.23) - .userLocationAccuracy(42.23) - .userLon(42.23) + .userLat(0.0) + .userLocationAccuracy(0.0) + .userLon(0.0) .userOnVehicle(true) .userVehicleNumber("userVehicleNumber") .vehicleId("vehicleID") diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt index be1c92e..c98eb0f 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt @@ -22,12 +22,12 @@ class RoutesForLocationServiceTest { val routesForLocationListResponse = routesForLocationService.list( RoutesForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) .query("query") - .radius(42.23) + .radius(0.0) .build() ) println(routesForLocationListResponse) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt index 2c1a5fa..caa3906 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt @@ -21,7 +21,7 @@ class SearchForRouteServiceTest { val searchForRouteService = client.searchForRoute() val searchForRouteListResponse = searchForRouteService.list( - SearchForRouteListParams.builder().input("input").maxCount(123L).build() + SearchForRouteListParams.builder().input("input").maxCount(0L).build() ) println(searchForRouteListResponse) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt index b9b1a95..0ef506a 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt @@ -21,7 +21,7 @@ class SearchForStopServiceTest { val searchForStopService = client.searchForStop() val searchForStopListResponse = searchForStopService.list( - SearchForStopListParams.builder().input("input").maxCount(123L).build() + SearchForStopListParams.builder().input("input").maxCount(0L).build() ) println(searchForStopListResponse) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt index d3828a0..197d75b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt @@ -22,12 +22,12 @@ class StopsForLocationServiceTest { val stopsForLocationListResponse = stopsForLocationService.list( StopsForLocationListParams.builder() - .lat(42.23) - .lon(42.23) - .latSpan(42.23) - .lonSpan(42.23) + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) .query("query") - .radius(42.23) + .radius(0.0) .build() ) println(stopsForLocationListResponse) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt index a5e8820..fa12e4b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt @@ -26,8 +26,8 @@ class TripDetailServiceTest { .includeSchedule(true) .includeStatus(true) .includeTrip(true) - .serviceDate(123L) - .time(123L) + .serviceDate(0L) + .time(0L) .build() ) println(tripDetailRetrieveResponse) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt index c3344e5..7f6035c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt @@ -26,7 +26,7 @@ class TripForVehicleServiceTest { .includeSchedule(true) .includeStatus(true) .includeTrip(true) - .time(123L) + .time(0L) .build() ) println(tripForVehicleRetrieveResponse) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt index 7c539e8..f83e638 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt @@ -22,13 +22,13 @@ class TripsForLocationServiceTest { val tripsForLocationListResponse = tripsForLocationService.list( TripsForLocationListParams.builder() - .lat(42.23) - .latSpan(42.23) - .lon(42.23) - .lonSpan(42.23) + .lat(0.0) + .latSpan(0.0) + .lon(0.0) + .lonSpan(0.0) .includeSchedule(true) .includeTrip(true) - .time(123L) + .time(0L) .build() ) println(tripsForLocationListResponse) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt index 8568827..812ef98 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt @@ -25,7 +25,7 @@ class TripsForRouteServiceTest { .routeId("routeID") .includeSchedule(true) .includeStatus(true) - .time(123L) + .time(0L) .build() ) println(tripsForRouteListResponse) From a45c6b0bc2f45328c1365db12b9ed2fca0d85ce6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 30 Nov 2024 07:51:59 +0000 Subject: [PATCH 03/11] chore(internal): codegen related update (#73) --- .github/workflows/publish-sonatype.yml | 6 ++++-- .github/workflows/release-doctor.yml | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 1247fe9..cabf487 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -29,11 +29,13 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Publish to Sonatype - run: | + run: |- + export -- GPG_SIGNING_KEY_ID + printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" + GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" env: SONATYPE_USERNAME: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY_ID: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} GPG_SIGNING_KEY: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index f328321..fac0542 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -20,6 +20,5 @@ jobs: env: SONATYPE_USERNAME: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY_ID: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} GPG_SIGNING_KEY: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} From ddda17b7186ef701720740c946250b5fa902a4cc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 18:18:22 +0000 Subject: [PATCH 04/11] feat(api): manual updates (#74) --- README.md | 87 +- .../onebusaway/client/okhttp/OkHttpClient.kt | 15 + .../onebusaway/client/OnebusawaySdkClient.kt | 30 +- .../client/OnebusawaySdkClientAsync.kt | 30 +- .../client/OnebusawaySdkClientAsyncImpl.kt | 58 +- .../client/OnebusawaySdkClientImpl.kt | 58 +- .../main/kotlin/org/onebusaway/core/Utils.kt | 4 +- .../onebusaway/errors/OnebusawaySdkError.kt | 11 +- .../models/AgenciesWithCoverageListParams.kt | 1 - .../AgenciesWithCoverageListResponse.kt | 185 +-- .../onebusaway/models/AgencyRetrieveParams.kt | 1 - .../models/AgencyRetrieveResponse.kt | 224 ++-- .../models/ArrivalAndDepartureListParams.kt | 1 - .../models/ArrivalAndDepartureListResponse.kt | 770 ++++++------ .../ArrivalAndDepartureRetrieveParams.kt | 1 - .../ArrivalAndDepartureRetrieveResponse.kt | 730 +++++------ .../onebusaway/models/BlockRetrieveParams.kt | 1 - .../models/BlockRetrieveResponse.kt | 380 +++--- .../onebusaway/models/ConfigRetrieveParams.kt | 1 - .../models/ConfigRetrieveResponse.kt | 360 +++--- .../models/CurrentTimeRetrieveParams.kt | 1 - .../models/CurrentTimeRetrieveResponse.kt | 152 +-- .../org/onebusaway/models/References.kt | 1091 +++++++++-------- .../ReportProblemWithStopRetrieveParams.kt | 36 +- .../ReportProblemWithTripRetrieveParams.kt | 39 +- .../org/onebusaway/models/ResponseWrapper.kt | 52 +- .../models/RouteIdsForAgencyListParams.kt | 1 - .../models/RouteIdsForAgencyListResponse.kt | 120 +- .../onebusaway/models/RouteRetrieveParams.kt | 1 - .../models/RouteRetrieveResponse.kt | 216 ++-- .../models/RoutesForAgencyListParams.kt | 1 - .../models/RoutesForAgencyListResponse.kt | 224 ++-- .../models/RoutesForLocationListParams.kt | 1 - .../models/RoutesForLocationListResponse.kt | 232 ++-- .../models/ScheduleForRouteRetrieveParams.kt | 1 - .../ScheduleForRouteRetrieveResponse.kt | 596 +++++---- .../models/ScheduleForStopRetrieveParams.kt | 1 - .../models/ScheduleForStopRetrieveResponse.kt | 414 ++++--- .../models/SearchForRouteListParams.kt | 1 - .../models/SearchForRouteListResponse.kt | 232 ++-- .../models/SearchForStopListParams.kt | 1 - .../models/SearchForStopListResponse.kt | 241 ++-- .../onebusaway/models/ShapeRetrieveParams.kt | 1 - .../models/ShapeRetrieveResponse.kt | 160 +-- .../models/StopIdsForAgencyListParams.kt | 1 - .../models/StopIdsForAgencyListResponse.kt | 120 +- .../onebusaway/models/StopRetrieveParams.kt | 1 - .../onebusaway/models/StopRetrieveResponse.kt | 224 ++-- .../models/StopsForAgencyListParams.kt | 1 - .../models/StopsForAgencyListResponse.kt | 204 +-- .../models/StopsForLocationListParams.kt | 1 - .../models/StopsForLocationListResponse.kt | 241 ++-- .../models/StopsForRouteListParams.kt | 1 - .../models/StopsForRouteListResponse.kt | 366 +++--- .../models/TripDetailRetrieveParams.kt | 1 - .../models/TripDetailRetrieveResponse.kt | 639 +++++----- .../models/TripForVehicleRetrieveParams.kt | 1 - .../models/TripForVehicleRetrieveResponse.kt | 640 +++++----- .../onebusaway/models/TripRetrieveParams.kt | 1 - .../onebusaway/models/TripRetrieveResponse.kt | 224 ++-- .../models/TripsForLocationListParams.kt | 1 - .../models/TripsForLocationListResponse.kt | 657 +++++----- .../models/TripsForRouteListParams.kt | 1 - .../models/TripsForRouteListResponse.kt | 649 +++++----- .../models/VehiclesForAgencyListParams.kt | 1 - .../models/VehiclesForAgencyListResponse.kt | 596 ++++----- .../AgenciesWithCoverageListParamsTest.kt | 1 - .../models/AgencyRetrieveParamsTest.kt | 1 - .../ArrivalAndDepartureListParamsTest.kt | 11 +- .../ArrivalAndDepartureRetrieveParamsTest.kt | 11 +- .../models/BlockRetrieveParamsTest.kt | 1 - .../models/ConfigRetrieveParamsTest.kt | 1 - .../models/CurrentTimeRetrieveParamsTest.kt | 1 - ...ReportProblemWithStopRetrieveParamsTest.kt | 1 - ...ReportProblemWithTripRetrieveParamsTest.kt | 1 - .../models/RouteIdsForAgencyListParamsTest.kt | 1 - .../models/RouteRetrieveParamsTest.kt | 1 - .../models/RoutesForAgencyListParamsTest.kt | 7 +- .../models/RoutesForLocationListParamsTest.kt | 1 - .../ScheduleForRouteRetrieveParamsTest.kt | 11 +- .../ScheduleForStopRetrieveParamsTest.kt | 1 - .../models/SearchForRouteListParamsTest.kt | 1 - .../models/SearchForStopListParamsTest.kt | 1 - .../models/ShapeRetrieveParamsTest.kt | 1 - .../models/StopIdsForAgencyListParamsTest.kt | 1 - .../models/StopRetrieveParamsTest.kt | 1 - .../models/StopsForAgencyListParamsTest.kt | 1 - .../models/StopsForLocationListParamsTest.kt | 1 - .../models/StopsForRouteListParamsTest.kt | 1 - .../models/TripDetailRetrieveParamsTest.kt | 1 - .../TripForVehicleRetrieveParamsTest.kt | 1 - .../models/TripRetrieveParamsTest.kt | 1 - .../models/TripsForLocationListParamsTest.kt | 1 - .../models/TripsForRouteListParamsTest.kt | 1 - .../models/VehiclesForAgencyListParamsTest.kt | 1 - .../onebusaway/services/ErrorHandlingTest.kt | 190 ++- .../onebusaway/services/ServiceParamsTest.kt | 186 ++- .../AgenciesWithCoverageServiceTest.kt | 2 +- .../services/blocking/AgencyServiceTest.kt | 2 +- .../ArrivalAndDepartureServiceTest.kt | 7 +- .../services/blocking/BlockServiceTest.kt | 2 +- .../services/blocking/ConfigServiceTest.kt | 2 +- .../blocking/CurrentTimeServiceTest.kt | 2 +- .../ReportProblemWithStopServiceTest.kt | 2 +- .../ReportProblemWithTripServiceTest.kt | 2 +- .../blocking/RouteIdsForAgencyServiceTest.kt | 2 +- .../services/blocking/RouteServiceTest.kt | 2 +- .../blocking/RoutesForAgencyServiceTest.kt | 6 +- .../blocking/RoutesForLocationServiceTest.kt | 2 +- .../blocking/ScheduleForRouteServiceTest.kt | 4 +- .../blocking/ScheduleForStopServiceTest.kt | 2 +- .../blocking/SearchForRouteServiceTest.kt | 2 +- .../blocking/SearchForStopServiceTest.kt | 2 +- .../services/blocking/ShapeServiceTest.kt | 2 +- .../blocking/StopIdsForAgencyServiceTest.kt | 2 +- .../services/blocking/StopServiceTest.kt | 2 +- .../blocking/StopsForAgencyServiceTest.kt | 2 +- .../blocking/StopsForLocationServiceTest.kt | 2 +- .../blocking/StopsForRouteServiceTest.kt | 2 +- .../blocking/TripDetailServiceTest.kt | 2 +- .../blocking/TripForVehicleServiceTest.kt | 2 +- .../services/blocking/TripServiceTest.kt | 2 +- .../blocking/TripsForLocationServiceTest.kt | 2 +- .../blocking/TripsForRouteServiceTest.kt | 2 +- .../blocking/VehiclesForAgencyServiceTest.kt | 2 +- onebusaway-sdk-java-example/build.gradle.kts | 24 +- .../example/AgenciesWithCoverage.java | 13 +- .../java/org/onebusaway/example/Agency.java | 23 +- .../example/ArrivalAndDepartureForStop.java | 14 +- .../example/ArrivalsAndDeparturesForStop.java | 16 +- .../java/org/onebusaway/example/Block.java | 12 +- .../org/onebusaway/example/CurrentTime.java | 10 +- .../java/org/onebusaway/example/Route.java | 31 +- .../onebusaway/example/RouteForAgency.java | 26 +- .../onebusaway/example/RoutesForLocation.java | 18 +- .../onebusaway/example/ScheduleForRoute.java | 16 +- .../onebusaway/example/SearchForRoute.java | 25 +- .../org/onebusaway/example/SearchForStop.java | 15 +- .../java/org/onebusaway/example/Shape.java | 13 +- .../java/org/onebusaway/example/Stop.java | 9 +- .../onebusaway/example/StopsForLocation.java | 20 +- .../org/onebusaway/example/StopsForRoute.java | 12 +- .../onebusaway/example/StopsIdsForAgency.java | 11 +- .../java/org/onebusaway/example/Trip.java | 12 +- .../org/onebusaway/example/TripDetails.java | 27 +- .../onebusaway/example/TripForVehicle.java | 13 +- .../org/onebusaway/example/TripsForRoute.java | 11 +- .../onebusaway/example/VehiclesForAgency.java | 11 +- 148 files changed, 6809 insertions(+), 5415 deletions(-) diff --git a/README.md b/README.md index 6c33aad..a9b8ed2 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,9 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() Alternately, set the environment with `ONEBUSAWAY_API_KEY`, and use `OnebusawaySdkOkHttpClient.fromEnv()` to read from the environment. ```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); // Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties @@ -77,8 +80,7 @@ Read the documentation for more configuration options. ### Example: creating a resource -To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes, -then pass that to the `retrieve` method of the `currentTime` service. +To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes, then pass that to the `retrieve` method of the `currentTime` service. ```java import org.onebusaway.models.CurrentTimeRetrieveParams; @@ -96,14 +98,14 @@ CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(params); To make a request to the Onebusaway SDK API, you generally build an instance of the appropriate `Params` class. -In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to -the `retrieve` method of the `currentTime` service. +In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to the `retrieve` method of the `currentTime` service. -Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, -you can attach them using the `putAdditionalProperty` method. +Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using the `putAdditionalProperty` method. ```java -import org.onebusaway.models.core.JsonValue; +import org.onebusaway.core.JsonValue; +import org.onebusaway.models.CurrentTimeRetrieveParams; + CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder() // ... normal properties .putAdditionalProperty("secret_param", JsonValue.from("4242")) @@ -117,15 +119,19 @@ CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder() When receiving a response, the Onebusaway SDK Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `OnebusawaySdkInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model. ```java +import org.onebusaway.models.CurrentTimeRetrieveResponse; + CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve().validate(); ``` ### Response properties as JSON -In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by -this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value. +In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value. ```java +import java.util.Optional; +import org.onebusaway.core.JsonField; + JsonField field = responseObj._field(); if (field.isMissing()) { @@ -147,6 +153,8 @@ if (field.isMissing()) { Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method: ```java +import org.onebusaway.core.JsonValue; + JsonValue secret = references._additionalProperties().get("secret_field"); ``` @@ -160,31 +168,33 @@ This library throws exceptions in a single hierarchy for easy handling: - **`OnebusawaySdkException`** - Base exception for all exceptions - - **`OnebusawaySdkServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server. +- **`OnebusawaySdkServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server. - | 400 | BadRequestException | - | ------ | ----------------------------- | - | 401 | AuthenticationException | - | 403 | PermissionDeniedException | - | 404 | NotFoundException | - | 422 | UnprocessableEntityException | - | 429 | RateLimitException | - | 5xx | InternalServerException | - | others | UnexpectedStatusCodeException | + | 400 | BadRequestException | + | ------ | ----------------------------- | + | 401 | AuthenticationException | + | 403 | PermissionDeniedException | + | 404 | NotFoundException | + | 422 | UnprocessableEntityException | + | 429 | RateLimitException | + | 5xx | InternalServerException | + | others | UnexpectedStatusCodeException | - - **`OnebusawaySdkIoException`** - I/O networking errors - - **`OnebusawaySdkInvalidDataException`** - any other exceptions on the client side, e.g.: - - We failed to serialize the request body - - We failed to parse the response body (has access to response code and body) +- **`OnebusawaySdkIoException`** - I/O networking errors +- **`OnebusawaySdkInvalidDataException`** - any other exceptions on the client side, e.g.: + - We failed to serialize the request body + - We failed to parse the response body (has access to response code and body) ## Network options ### Retries -Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. -You can provide a `maxRetries` on the client builder to configure this: +Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. You can provide a `maxRetries` on the client builder to configure this: ```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .fromEnv() .maxRetries(4) @@ -196,6 +206,10 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() Requests time out after 1 minute by default. You can configure this on the client builder: ```java +import java.time.Duration; +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .fromEnv() .timeout(Duration.ofSeconds(30)) @@ -207,26 +221,26 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() Requests can be routed through a proxy. You can configure this on the client builder: ```java +import java.net.InetSocketAddress; +import java.net.Proxy; +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .fromEnv() - .proxy(new Proxy( - Type.HTTP, - new InetSocketAddress("proxy.com", 8080) - )) + .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("example.com", 8080))) .build(); ``` ## Making custom/undocumented requests -This library is typed for convenient access to the documented API. If you need to access undocumented -params or response properties, the library can still be used. +This library is typed for convenient access to the documented API. If you need to access undocumented params or response properties, the library can still be used. ### Undocumented request params -To make requests using undocumented parameters, you can provide or override parameters on the params object -while building it. +To make requests using undocumented parameters, you can provide or override parameters on the params object while building it. -```kotlin +```java FooCreateParams address = FooCreateParams.builder() .id("my_id") .putAdditionalProperty("secret_prop", JsonValue.from("hello")) @@ -235,10 +249,7 @@ FooCreateParams address = FooCreateParams.builder() ### Undocumented response properties -To access undocumented response properties, you can use `res._additionalProperties()` on a response object to -get a map of untyped fields of type `Map`. You can then access fields like -`._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class -to extract it to a desired type. +To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. ## Logging 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 0635f4e..08b9c51 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 @@ -9,6 +9,7 @@ import okhttp3.Call import okhttp3.Callback import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.Interceptor import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType import okhttp3.Request @@ -33,6 +34,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { val clientBuilder = okHttpClient.newBuilder() + // Custom logging interceptor for URL logging + clientBuilder.addNetworkInterceptor(LoggingInterceptor()) + val logLevel = when (System.getenv("ONEBUSAWAY_SDK_LOG")?.lowercase()) { "info" -> HttpLoggingInterceptor.Level.BASIC @@ -194,3 +198,14 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val ) } } + +// --- ✅ New class added below --- +class LoggingInterceptor : Interceptor { + override fun intercept(chain: Interceptor.Chain): Response { + val request = chain.request() + println("➡️ Sending request: ${request.method} ${request.url}") + val response = chain.proceed(request) + println("⬅️ Received response: ${response.code} ${response.request.url}") + return response + } +} 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 44afaea..085a275 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 @@ -2,8 +2,34 @@ package org.onebusaway.client -import org.onebusaway.models.* -import org.onebusaway.services.blocking.* +import org.onebusaway.services.blocking.AgenciesWithCoverageService +import org.onebusaway.services.blocking.AgencyService +import org.onebusaway.services.blocking.ArrivalAndDepartureService +import org.onebusaway.services.blocking.BlockService +import org.onebusaway.services.blocking.ConfigService +import org.onebusaway.services.blocking.CurrentTimeService +import org.onebusaway.services.blocking.ReportProblemWithStopService +import org.onebusaway.services.blocking.ReportProblemWithTripService +import org.onebusaway.services.blocking.RouteIdsForAgencyService +import org.onebusaway.services.blocking.RouteService +import org.onebusaway.services.blocking.RoutesForAgencyService +import org.onebusaway.services.blocking.RoutesForLocationService +import org.onebusaway.services.blocking.ScheduleForRouteService +import org.onebusaway.services.blocking.ScheduleForStopService +import org.onebusaway.services.blocking.SearchForRouteService +import org.onebusaway.services.blocking.SearchForStopService +import org.onebusaway.services.blocking.ShapeService +import org.onebusaway.services.blocking.StopIdsForAgencyService +import org.onebusaway.services.blocking.StopService +import org.onebusaway.services.blocking.StopsForAgencyService +import org.onebusaway.services.blocking.StopsForLocationService +import org.onebusaway.services.blocking.StopsForRouteService +import org.onebusaway.services.blocking.TripDetailService +import org.onebusaway.services.blocking.TripForVehicleService +import org.onebusaway.services.blocking.TripService +import org.onebusaway.services.blocking.TripsForLocationService +import org.onebusaway.services.blocking.TripsForRouteService +import org.onebusaway.services.blocking.VehiclesForAgencyService interface OnebusawaySdkClient { 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 0029e0f..d259172 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 @@ -2,8 +2,34 @@ package org.onebusaway.client -import org.onebusaway.models.* -import org.onebusaway.services.async.* +import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync +import org.onebusaway.services.async.AgencyServiceAsync +import org.onebusaway.services.async.ArrivalAndDepartureServiceAsync +import org.onebusaway.services.async.BlockServiceAsync +import org.onebusaway.services.async.ConfigServiceAsync +import org.onebusaway.services.async.CurrentTimeServiceAsync +import org.onebusaway.services.async.ReportProblemWithStopServiceAsync +import org.onebusaway.services.async.ReportProblemWithTripServiceAsync +import org.onebusaway.services.async.RouteIdsForAgencyServiceAsync +import org.onebusaway.services.async.RouteServiceAsync +import org.onebusaway.services.async.RoutesForAgencyServiceAsync +import org.onebusaway.services.async.RoutesForLocationServiceAsync +import org.onebusaway.services.async.ScheduleForRouteServiceAsync +import org.onebusaway.services.async.ScheduleForStopServiceAsync +import org.onebusaway.services.async.SearchForRouteServiceAsync +import org.onebusaway.services.async.SearchForStopServiceAsync +import org.onebusaway.services.async.ShapeServiceAsync +import org.onebusaway.services.async.StopIdsForAgencyServiceAsync +import org.onebusaway.services.async.StopServiceAsync +import org.onebusaway.services.async.StopsForAgencyServiceAsync +import org.onebusaway.services.async.StopsForLocationServiceAsync +import org.onebusaway.services.async.StopsForRouteServiceAsync +import org.onebusaway.services.async.TripDetailServiceAsync +import org.onebusaway.services.async.TripForVehicleServiceAsync +import org.onebusaway.services.async.TripServiceAsync +import org.onebusaway.services.async.TripsForLocationServiceAsync +import org.onebusaway.services.async.TripsForRouteServiceAsync +import org.onebusaway.services.async.VehiclesForAgencyServiceAsync interface OnebusawaySdkClientAsync { 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 cdf19c3..b319d18 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 @@ -4,8 +4,62 @@ package org.onebusaway.client import org.onebusaway.core.ClientOptions import org.onebusaway.core.getPackageVersion -import org.onebusaway.models.* -import org.onebusaway.services.async.* +import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync +import org.onebusaway.services.async.AgenciesWithCoverageServiceAsyncImpl +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.BlockServiceAsync +import org.onebusaway.services.async.BlockServiceAsyncImpl +import org.onebusaway.services.async.ConfigServiceAsync +import org.onebusaway.services.async.ConfigServiceAsyncImpl +import org.onebusaway.services.async.CurrentTimeServiceAsync +import org.onebusaway.services.async.CurrentTimeServiceAsyncImpl +import org.onebusaway.services.async.ReportProblemWithStopServiceAsync +import org.onebusaway.services.async.ReportProblemWithStopServiceAsyncImpl +import org.onebusaway.services.async.ReportProblemWithTripServiceAsync +import org.onebusaway.services.async.ReportProblemWithTripServiceAsyncImpl +import org.onebusaway.services.async.RouteIdsForAgencyServiceAsync +import org.onebusaway.services.async.RouteIdsForAgencyServiceAsyncImpl +import org.onebusaway.services.async.RouteServiceAsync +import org.onebusaway.services.async.RouteServiceAsyncImpl +import org.onebusaway.services.async.RoutesForAgencyServiceAsync +import org.onebusaway.services.async.RoutesForAgencyServiceAsyncImpl +import org.onebusaway.services.async.RoutesForLocationServiceAsync +import org.onebusaway.services.async.RoutesForLocationServiceAsyncImpl +import org.onebusaway.services.async.ScheduleForRouteServiceAsync +import org.onebusaway.services.async.ScheduleForRouteServiceAsyncImpl +import org.onebusaway.services.async.ScheduleForStopServiceAsync +import org.onebusaway.services.async.ScheduleForStopServiceAsyncImpl +import org.onebusaway.services.async.SearchForRouteServiceAsync +import org.onebusaway.services.async.SearchForRouteServiceAsyncImpl +import org.onebusaway.services.async.SearchForStopServiceAsync +import org.onebusaway.services.async.SearchForStopServiceAsyncImpl +import org.onebusaway.services.async.ShapeServiceAsync +import org.onebusaway.services.async.ShapeServiceAsyncImpl +import org.onebusaway.services.async.StopIdsForAgencyServiceAsync +import org.onebusaway.services.async.StopIdsForAgencyServiceAsyncImpl +import org.onebusaway.services.async.StopServiceAsync +import org.onebusaway.services.async.StopServiceAsyncImpl +import org.onebusaway.services.async.StopsForAgencyServiceAsync +import org.onebusaway.services.async.StopsForAgencyServiceAsyncImpl +import org.onebusaway.services.async.StopsForLocationServiceAsync +import org.onebusaway.services.async.StopsForLocationServiceAsyncImpl +import org.onebusaway.services.async.StopsForRouteServiceAsync +import org.onebusaway.services.async.StopsForRouteServiceAsyncImpl +import org.onebusaway.services.async.TripDetailServiceAsync +import org.onebusaway.services.async.TripDetailServiceAsyncImpl +import org.onebusaway.services.async.TripForVehicleServiceAsync +import org.onebusaway.services.async.TripForVehicleServiceAsyncImpl +import org.onebusaway.services.async.TripServiceAsync +import org.onebusaway.services.async.TripServiceAsyncImpl +import org.onebusaway.services.async.TripsForLocationServiceAsync +import org.onebusaway.services.async.TripsForLocationServiceAsyncImpl +import org.onebusaway.services.async.TripsForRouteServiceAsync +import org.onebusaway.services.async.TripsForRouteServiceAsyncImpl +import org.onebusaway.services.async.VehiclesForAgencyServiceAsync +import org.onebusaway.services.async.VehiclesForAgencyServiceAsyncImpl class OnebusawaySdkClientAsyncImpl constructor( 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 a5ada81..f5665e9 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 @@ -4,8 +4,62 @@ package org.onebusaway.client import org.onebusaway.core.ClientOptions import org.onebusaway.core.getPackageVersion -import org.onebusaway.models.* -import org.onebusaway.services.blocking.* +import org.onebusaway.services.blocking.AgenciesWithCoverageService +import org.onebusaway.services.blocking.AgenciesWithCoverageServiceImpl +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.BlockService +import org.onebusaway.services.blocking.BlockServiceImpl +import org.onebusaway.services.blocking.ConfigService +import org.onebusaway.services.blocking.ConfigServiceImpl +import org.onebusaway.services.blocking.CurrentTimeService +import org.onebusaway.services.blocking.CurrentTimeServiceImpl +import org.onebusaway.services.blocking.ReportProblemWithStopService +import org.onebusaway.services.blocking.ReportProblemWithStopServiceImpl +import org.onebusaway.services.blocking.ReportProblemWithTripService +import org.onebusaway.services.blocking.ReportProblemWithTripServiceImpl +import org.onebusaway.services.blocking.RouteIdsForAgencyService +import org.onebusaway.services.blocking.RouteIdsForAgencyServiceImpl +import org.onebusaway.services.blocking.RouteService +import org.onebusaway.services.blocking.RouteServiceImpl +import org.onebusaway.services.blocking.RoutesForAgencyService +import org.onebusaway.services.blocking.RoutesForAgencyServiceImpl +import org.onebusaway.services.blocking.RoutesForLocationService +import org.onebusaway.services.blocking.RoutesForLocationServiceImpl +import org.onebusaway.services.blocking.ScheduleForRouteService +import org.onebusaway.services.blocking.ScheduleForRouteServiceImpl +import org.onebusaway.services.blocking.ScheduleForStopService +import org.onebusaway.services.blocking.ScheduleForStopServiceImpl +import org.onebusaway.services.blocking.SearchForRouteService +import org.onebusaway.services.blocking.SearchForRouteServiceImpl +import org.onebusaway.services.blocking.SearchForStopService +import org.onebusaway.services.blocking.SearchForStopServiceImpl +import org.onebusaway.services.blocking.ShapeService +import org.onebusaway.services.blocking.ShapeServiceImpl +import org.onebusaway.services.blocking.StopIdsForAgencyService +import org.onebusaway.services.blocking.StopIdsForAgencyServiceImpl +import org.onebusaway.services.blocking.StopService +import org.onebusaway.services.blocking.StopServiceImpl +import org.onebusaway.services.blocking.StopsForAgencyService +import org.onebusaway.services.blocking.StopsForAgencyServiceImpl +import org.onebusaway.services.blocking.StopsForLocationService +import org.onebusaway.services.blocking.StopsForLocationServiceImpl +import org.onebusaway.services.blocking.StopsForRouteService +import org.onebusaway.services.blocking.StopsForRouteServiceImpl +import org.onebusaway.services.blocking.TripDetailService +import org.onebusaway.services.blocking.TripDetailServiceImpl +import org.onebusaway.services.blocking.TripForVehicleService +import org.onebusaway.services.blocking.TripForVehicleServiceImpl +import org.onebusaway.services.blocking.TripService +import org.onebusaway.services.blocking.TripServiceImpl +import org.onebusaway.services.blocking.TripsForLocationService +import org.onebusaway.services.blocking.TripsForLocationServiceImpl +import org.onebusaway.services.blocking.TripsForRouteService +import org.onebusaway.services.blocking.TripsForRouteServiceImpl +import org.onebusaway.services.blocking.VehiclesForAgencyService +import org.onebusaway.services.blocking.VehiclesForAgencyServiceImpl class OnebusawaySdkClientImpl constructor( 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 030a344..31e1d87 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 @@ -16,7 +16,9 @@ internal fun List.toImmutable(): List = @JvmSynthetic internal fun Map.toImmutable(): Map = - if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap()) + if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) + +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() @JvmSynthetic internal fun , V> SortedMap.toImmutable(): SortedMap = diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt index bc720ae..2b12984 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt @@ -4,19 +4,23 @@ package org.onebusaway.errors import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects +import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = OnebusawaySdkError.Builder::class) @NoAutoDetect class OnebusawaySdkError +@JsonCreator private constructor( @JsonAnyGetter + @ExcludeMissing + @JsonAnySetter @get:JvmName("additionalProperties") - val additionalProperties: Map, + val additionalProperties: Map = immutableEmptyMap(), ) { fun toBuilder() = Builder().from(this) @@ -40,7 +44,6 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { additionalProperties.put(key, value) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt index cd6b74f..4d859dc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class AgenciesWithCoverageListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt index 52b2d3a..999e26c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt @@ -4,30 +4,33 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = AgenciesWithCoverageListResponse.Builder::class) @NoAutoDetect class AgenciesWithCoverageListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -38,14 +41,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -60,6 +55,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): AgenciesWithCoverageListResponse = apply { if (!validated) { code() @@ -90,58 +95,54 @@ private constructor( @JvmSynthetic internal fun from(agenciesWithCoverageListResponse: AgenciesWithCoverageListResponse) = apply { - this.code = agenciesWithCoverageListResponse.code - this.currentTime = agenciesWithCoverageListResponse.currentTime - this.text = agenciesWithCoverageListResponse.text - this.version = agenciesWithCoverageListResponse.version - this.data = agenciesWithCoverageListResponse.data - additionalProperties(agenciesWithCoverageListResponse.additionalProperties) + code = agenciesWithCoverageListResponse.code + currentTime = agenciesWithCoverageListResponse.currentTime + text = agenciesWithCoverageListResponse.text + version = agenciesWithCoverageListResponse.version + data = agenciesWithCoverageListResponse.data + additionalProperties = + agenciesWithCoverageListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): AgenciesWithCoverageListResponse = AgenciesWithCoverageListResponse( code, @@ -153,18 +154,23 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun list(): kotlin.collections.List = list.getRequired("list") @@ -181,6 +187,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -206,48 +214,47 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -257,20 +264,29 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val agencyId: JsonField, - private val lat: JsonField, - private val latSpan: JsonField, - private val lon: JsonField, - private val lonSpan: JsonField, - private val additionalProperties: Map, + @JsonProperty("agencyId") + @ExcludeMissing + private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("latSpan") + @ExcludeMissing + private val latSpan: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonProperty("lonSpan") + @ExcludeMissing + private val lonSpan: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun agencyId(): String = agencyId.getRequired("agencyId") fun lat(): Double = lat.getRequired("lat") @@ -295,6 +311,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { agencyId() @@ -324,52 +342,41 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.agencyId = list.agencyId - this.lat = list.lat - this.latSpan = list.latSpan - this.lon = list.lon - this.lonSpan = list.lonSpan - additionalProperties(list.additionalProperties) + agencyId = list.agencyId + lat = list.lat + latSpan = list.latSpan + lon = list.lon + lonSpan = list.lonSpan + additionalProperties = list.additionalProperties.toMutableMap() } fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - @JsonProperty("agencyId") - @ExcludeMissing fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } fun lat(lat: Double) = lat(JsonField.of(lat)) - @JsonProperty("lat") - @ExcludeMissing fun lat(lat: JsonField) = apply { this.lat = lat } fun latSpan(latSpan: Double) = latSpan(JsonField.of(latSpan)) - @JsonProperty("latSpan") - @ExcludeMissing fun latSpan(latSpan: JsonField) = apply { this.latSpan = latSpan } fun lon(lon: Double) = lon(JsonField.of(lon)) - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun lonSpan(lonSpan: Double) = lonSpan(JsonField.of(lonSpan)) - @JsonProperty("lonSpan") - @ExcludeMissing fun lonSpan(lonSpan: JsonField) = apply { this.lonSpan = lonSpan } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -377,6 +384,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( agencyId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt index 69a633c..9958aee 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class AgencyRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt index a4c9fa4..599e05e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = AgencyRetrieveResponse.Builder::class) @NoAutoDetect class AgencyRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): AgencyRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(agencyRetrieveResponse: AgencyRetrieveResponse) = apply { - this.code = agencyRetrieveResponse.code - this.currentTime = agencyRetrieveResponse.currentTime - this.text = agencyRetrieveResponse.text - this.version = agencyRetrieveResponse.version - this.data = agencyRetrieveResponse.data - additionalProperties(agencyRetrieveResponse.additionalProperties) + code = agencyRetrieveResponse.code + currentTime = agencyRetrieveResponse.currentTime + text = agencyRetrieveResponse.text + version = agencyRetrieveResponse.version + data = agencyRetrieveResponse.data + additionalProperties = agencyRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): AgencyRetrieveResponse = AgencyRetrieveResponse( code, @@ -153,18 +153,23 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun entry(): Entry = entry.getRequired("entry") @@ -181,6 +186,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -206,48 +213,47 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -257,25 +263,44 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val disclaimer: JsonField, - private val email: JsonField, - private val fareUrl: JsonField, - private val id: JsonField, - private val lang: JsonField, - private val name: JsonField, - private val phone: JsonField, - private val privateService: JsonField, - private val timezone: JsonField, - private val url: JsonField, - private val additionalProperties: Map, + @JsonProperty("disclaimer") + @ExcludeMissing + private val disclaimer: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + private val email: JsonField = JsonMissing.of(), + @JsonProperty("fareUrl") + @ExcludeMissing + private val fareUrl: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("lang") + @ExcludeMissing + private val lang: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("phone") + @ExcludeMissing + private val phone: JsonField = JsonMissing.of(), + @JsonProperty("privateService") + @ExcludeMissing + private val privateService: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + private val timezone: JsonField = JsonMissing.of(), + @JsonProperty("url") + @ExcludeMissing + private val url: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun disclaimer(): Optional = Optional.ofNullable(disclaimer.getNullable("disclaimer")) @@ -322,6 +347,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { disclaimer() @@ -361,92 +388,71 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.disclaimer = entry.disclaimer - this.email = entry.email - this.fareUrl = entry.fareUrl - this.id = entry.id - this.lang = entry.lang - this.name = entry.name - this.phone = entry.phone - this.privateService = entry.privateService - this.timezone = entry.timezone - this.url = entry.url - additionalProperties(entry.additionalProperties) + disclaimer = entry.disclaimer + email = entry.email + fareUrl = entry.fareUrl + id = entry.id + lang = entry.lang + name = entry.name + phone = entry.phone + privateService = entry.privateService + timezone = entry.timezone + url = entry.url + additionalProperties = entry.additionalProperties.toMutableMap() } fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) - @JsonProperty("disclaimer") - @ExcludeMissing fun disclaimer(disclaimer: JsonField) = apply { this.disclaimer = disclaimer } fun email(email: String) = email(JsonField.of(email)) - @JsonProperty("email") - @ExcludeMissing fun email(email: JsonField) = apply { this.email = email } fun fareUrl(fareUrl: String) = fareUrl(JsonField.of(fareUrl)) - @JsonProperty("fareUrl") - @ExcludeMissing fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun lang(lang: String) = lang(JsonField.of(lang)) - @JsonProperty("lang") - @ExcludeMissing fun lang(lang: JsonField) = apply { this.lang = lang } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun phone(phone: String) = phone(JsonField.of(phone)) - @JsonProperty("phone") - @ExcludeMissing fun phone(phone: JsonField) = apply { this.phone = phone } fun privateService(privateService: Boolean) = privateService(JsonField.of(privateService)) - @JsonProperty("privateService") - @ExcludeMissing fun privateService(privateService: JsonField) = apply { this.privateService = privateService } fun timezone(timezone: String) = timezone(JsonField.of(timezone)) - @JsonProperty("timezone") - @ExcludeMissing fun timezone(timezone: JsonField) = apply { this.timezone = timezone } fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -454,6 +460,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( disclaimer, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt index 9bdb475..b322956 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt @@ -9,7 +9,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ArrivalAndDepartureListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt index 9db8dcc..584beee 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = ArrivalAndDepartureListResponse.Builder::class) @NoAutoDetect class ArrivalAndDepartureListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): ArrivalAndDepartureListResponse = apply { if (!validated) { code() @@ -91,58 +96,54 @@ private constructor( @JvmSynthetic internal fun from(arrivalAndDepartureListResponse: ArrivalAndDepartureListResponse) = apply { - this.code = arrivalAndDepartureListResponse.code - this.currentTime = arrivalAndDepartureListResponse.currentTime - this.text = arrivalAndDepartureListResponse.text - this.version = arrivalAndDepartureListResponse.version - this.data = arrivalAndDepartureListResponse.data - additionalProperties(arrivalAndDepartureListResponse.additionalProperties) + code = arrivalAndDepartureListResponse.code + currentTime = arrivalAndDepartureListResponse.currentTime + text = arrivalAndDepartureListResponse.text + version = arrivalAndDepartureListResponse.version + data = arrivalAndDepartureListResponse.data + additionalProperties = + arrivalAndDepartureListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ArrivalAndDepartureListResponse = ArrivalAndDepartureListResponse( code, @@ -154,17 +155,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -177,6 +181,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -200,39 +206,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -241,16 +248,18 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val arrivalsAndDepartures: JsonField>, - private val additionalProperties: Map, + @JsonProperty("arrivalsAndDepartures") + @ExcludeMissing + private val arrivalsAndDepartures: JsonField> = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arrivalsAndDepartures(): List = arrivalsAndDepartures.getRequired("arrivalsAndDepartures") @@ -262,6 +271,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { arrivalsAndDepartures().forEach { it.validate() } @@ -284,27 +295,24 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.arrivalsAndDepartures = entry.arrivalsAndDepartures - additionalProperties(entry.additionalProperties) + arrivalsAndDepartures = entry.arrivalsAndDepartures + additionalProperties = entry.additionalProperties.toMutableMap() } fun arrivalsAndDepartures(arrivalsAndDepartures: List) = arrivalsAndDepartures(JsonField.of(arrivalsAndDepartures)) - @JsonProperty("arrivalsAndDepartures") - @ExcludeMissing fun arrivalsAndDepartures( arrivalsAndDepartures: JsonField> ) = apply { this.arrivalsAndDepartures = arrivalsAndDepartures } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -312,6 +320,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( arrivalsAndDepartures.map { it.toImmutable() }, @@ -319,49 +335,116 @@ private constructor( ) } - @JsonDeserialize(builder = ArrivalsAndDeparture.Builder::class) @NoAutoDetect class ArrivalsAndDeparture + @JsonCreator private constructor( - private val actualTrack: JsonField, - private val arrivalEnabled: JsonField, - private val blockTripSequence: JsonField, - private val departureEnabled: JsonField, - private val distanceFromStop: JsonField, - private val frequency: JsonField, - private val historicalOccupancy: JsonField, - private val lastUpdateTime: JsonField, - private val numberOfStopsAway: JsonField, - private val occupancyStatus: JsonField, - private val predicted: JsonField, - private val predictedArrivalInterval: JsonField, - private val predictedArrivalTime: JsonField, - private val predictedDepartureInterval: JsonField, - private val predictedDepartureTime: JsonField, - private val predictedOccupancy: JsonField, - private val routeId: JsonField, - private val routeLongName: JsonField, - private val routeShortName: JsonField, - private val scheduledArrivalInterval: JsonField, - private val scheduledArrivalTime: JsonField, - private val scheduledDepartureInterval: JsonField, - private val scheduledDepartureTime: JsonField, - private val scheduledTrack: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val stopId: JsonField, - private val stopSequence: JsonField, - private val totalStopsInTrip: JsonField, - private val tripHeadsign: JsonField, - private val tripId: JsonField, - private val tripStatus: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("actualTrack") + @ExcludeMissing + private val actualTrack: JsonField = JsonMissing.of(), + @JsonProperty("arrivalEnabled") + @ExcludeMissing + private val arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + private val departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("distanceFromStop") + @ExcludeMissing + private val distanceFromStop: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + private val historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + private val numberOfStopsAway: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + private val predictedArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + private val predictedArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + private val predictedDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + private val predictedDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedOccupancy") + @ExcludeMissing + private val predictedOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("routeLongName") + @ExcludeMissing + private val routeLongName: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + private val routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + private val scheduledArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + private val scheduledArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + private val scheduledDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + private val scheduledDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledTrack") + @ExcludeMissing + private val scheduledTrack: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopSequence") + @ExcludeMissing + private val stopSequence: JsonField = JsonMissing.of(), + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + private val totalStopsInTrip: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + private val tripStatus: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The actual track information of the arriving transit vehicle. */ fun actualTrack(): Optional = Optional.ofNullable(actualTrack.getNullable("actualTrack")) @@ -687,6 +770,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ArrivalsAndDeparture = apply { if (!validated) { actualTrack() @@ -774,53 +859,48 @@ private constructor( @JvmSynthetic internal fun from(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { - this.actualTrack = arrivalsAndDeparture.actualTrack - this.arrivalEnabled = arrivalsAndDeparture.arrivalEnabled - this.blockTripSequence = arrivalsAndDeparture.blockTripSequence - this.departureEnabled = arrivalsAndDeparture.departureEnabled - this.distanceFromStop = arrivalsAndDeparture.distanceFromStop - this.frequency = arrivalsAndDeparture.frequency - this.historicalOccupancy = arrivalsAndDeparture.historicalOccupancy - this.lastUpdateTime = arrivalsAndDeparture.lastUpdateTime - this.numberOfStopsAway = arrivalsAndDeparture.numberOfStopsAway - this.occupancyStatus = arrivalsAndDeparture.occupancyStatus - this.predicted = arrivalsAndDeparture.predicted - this.predictedArrivalInterval = - arrivalsAndDeparture.predictedArrivalInterval - this.predictedArrivalTime = arrivalsAndDeparture.predictedArrivalTime - this.predictedDepartureInterval = - arrivalsAndDeparture.predictedDepartureInterval - this.predictedDepartureTime = arrivalsAndDeparture.predictedDepartureTime - this.predictedOccupancy = arrivalsAndDeparture.predictedOccupancy - this.routeId = arrivalsAndDeparture.routeId - this.routeLongName = arrivalsAndDeparture.routeLongName - this.routeShortName = arrivalsAndDeparture.routeShortName - this.scheduledArrivalInterval = - arrivalsAndDeparture.scheduledArrivalInterval - this.scheduledArrivalTime = arrivalsAndDeparture.scheduledArrivalTime - this.scheduledDepartureInterval = - arrivalsAndDeparture.scheduledDepartureInterval - this.scheduledDepartureTime = arrivalsAndDeparture.scheduledDepartureTime - this.scheduledTrack = arrivalsAndDeparture.scheduledTrack - this.serviceDate = arrivalsAndDeparture.serviceDate - this.situationIds = arrivalsAndDeparture.situationIds - this.status = arrivalsAndDeparture.status - this.stopId = arrivalsAndDeparture.stopId - this.stopSequence = arrivalsAndDeparture.stopSequence - this.totalStopsInTrip = arrivalsAndDeparture.totalStopsInTrip - this.tripHeadsign = arrivalsAndDeparture.tripHeadsign - this.tripId = arrivalsAndDeparture.tripId - this.tripStatus = arrivalsAndDeparture.tripStatus - this.vehicleId = arrivalsAndDeparture.vehicleId - additionalProperties(arrivalsAndDeparture.additionalProperties) + actualTrack = arrivalsAndDeparture.actualTrack + arrivalEnabled = arrivalsAndDeparture.arrivalEnabled + blockTripSequence = arrivalsAndDeparture.blockTripSequence + departureEnabled = arrivalsAndDeparture.departureEnabled + distanceFromStop = arrivalsAndDeparture.distanceFromStop + frequency = arrivalsAndDeparture.frequency + historicalOccupancy = arrivalsAndDeparture.historicalOccupancy + lastUpdateTime = arrivalsAndDeparture.lastUpdateTime + numberOfStopsAway = arrivalsAndDeparture.numberOfStopsAway + occupancyStatus = arrivalsAndDeparture.occupancyStatus + predicted = arrivalsAndDeparture.predicted + predictedArrivalInterval = arrivalsAndDeparture.predictedArrivalInterval + predictedArrivalTime = arrivalsAndDeparture.predictedArrivalTime + predictedDepartureInterval = arrivalsAndDeparture.predictedDepartureInterval + predictedDepartureTime = arrivalsAndDeparture.predictedDepartureTime + predictedOccupancy = arrivalsAndDeparture.predictedOccupancy + routeId = arrivalsAndDeparture.routeId + routeLongName = arrivalsAndDeparture.routeLongName + routeShortName = arrivalsAndDeparture.routeShortName + scheduledArrivalInterval = arrivalsAndDeparture.scheduledArrivalInterval + scheduledArrivalTime = arrivalsAndDeparture.scheduledArrivalTime + scheduledDepartureInterval = arrivalsAndDeparture.scheduledDepartureInterval + scheduledDepartureTime = arrivalsAndDeparture.scheduledDepartureTime + scheduledTrack = arrivalsAndDeparture.scheduledTrack + serviceDate = arrivalsAndDeparture.serviceDate + situationIds = arrivalsAndDeparture.situationIds + status = arrivalsAndDeparture.status + stopId = arrivalsAndDeparture.stopId + stopSequence = arrivalsAndDeparture.stopSequence + totalStopsInTrip = arrivalsAndDeparture.totalStopsInTrip + tripHeadsign = arrivalsAndDeparture.tripHeadsign + tripId = arrivalsAndDeparture.tripId + tripStatus = arrivalsAndDeparture.tripStatus + vehicleId = arrivalsAndDeparture.vehicleId + additionalProperties = + arrivalsAndDeparture.additionalProperties.toMutableMap() } /** The actual track information of the arriving transit vehicle. */ fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") - @ExcludeMissing fun actualTrack(actualTrack: JsonField) = apply { this.actualTrack = actualTrack } @@ -830,8 +910,6 @@ private constructor( arrivalEnabled(JsonField.of(arrivalEnabled)) /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") - @ExcludeMissing fun arrivalEnabled(arrivalEnabled: JsonField) = apply { this.arrivalEnabled = arrivalEnabled } @@ -845,8 +923,6 @@ private constructor( /** * Index of this arrival’s trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -856,8 +932,6 @@ private constructor( departureEnabled(JsonField.of(departureEnabled)) /** Indicates if riders can depart from this transit vehicle. */ - @JsonProperty("departureEnabled") - @ExcludeMissing fun departureEnabled(departureEnabled: JsonField) = apply { this.departureEnabled = departureEnabled } @@ -867,8 +941,6 @@ private constructor( distanceFromStop(JsonField.of(distanceFromStop)) /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing fun distanceFromStop(distanceFromStop: JsonField) = apply { this.distanceFromStop = distanceFromStop } @@ -877,8 +949,6 @@ private constructor( fun frequency(frequency: String) = frequency(JsonField.of(frequency)) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -888,8 +958,6 @@ private constructor( historicalOccupancy(JsonField.of(historicalOccupancy)) /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing fun historicalOccupancy(historicalOccupancy: JsonField) = apply { this.historicalOccupancy = historicalOccupancy } @@ -899,8 +967,6 @@ private constructor( lastUpdateTime(JsonField.of(lastUpdateTime)) /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -916,8 +982,6 @@ private constructor( * Number of stops between the arriving transit vehicle and the current stop * (excluding the current stop). */ - @JsonProperty("numberOfStopsAway") - @ExcludeMissing fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { this.numberOfStopsAway = numberOfStopsAway } @@ -927,8 +991,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -937,8 +999,6 @@ private constructor( fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } @@ -948,8 +1008,6 @@ private constructor( predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = apply { this.predictedArrivalInterval = predictedArrivalInterval @@ -966,8 +1024,6 @@ private constructor( * Predicted arrival time, in milliseconds since Unix epoch (zero if no * real-time available). */ - @JsonProperty("predictedArrivalTime") - @ExcludeMissing fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { this.predictedArrivalTime = predictedArrivalTime } @@ -977,8 +1033,6 @@ private constructor( predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = apply { this.predictedDepartureInterval = predictedDepartureInterval @@ -995,8 +1049,6 @@ private constructor( * Predicted departure time, in milliseconds since Unix epoch (zero if no * real-time available). */ - @JsonProperty("predictedDepartureTime") - @ExcludeMissing fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { this.predictedDepartureTime = predictedDepartureTime } @@ -1006,8 +1058,6 @@ private constructor( predictedOccupancy(JsonField.of(predictedOccupancy)) /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing fun predictedOccupancy(predictedOccupancy: JsonField) = apply { this.predictedOccupancy = predictedOccupancy } @@ -1016,8 +1066,6 @@ private constructor( fun routeId(routeId: String) = routeId(JsonField.of(routeId)) /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } /** @@ -1031,8 +1079,6 @@ private constructor( * Optional route long name that potentially overrides the route long name in * the referenced route element. */ - @JsonProperty("routeLongName") - @ExcludeMissing fun routeLongName(routeLongName: JsonField) = apply { this.routeLongName = routeLongName } @@ -1048,8 +1094,6 @@ private constructor( * Optional route short name that potentially overrides the route short name in * the referenced route element. */ - @JsonProperty("routeShortName") - @ExcludeMissing fun routeShortName(routeShortName: JsonField) = apply { this.routeShortName = routeShortName } @@ -1059,8 +1103,6 @@ private constructor( scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = apply { this.scheduledArrivalInterval = scheduledArrivalInterval @@ -1071,8 +1113,6 @@ private constructor( scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) /** Scheduled arrival time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { this.scheduledArrivalTime = scheduledArrivalTime } @@ -1082,8 +1122,6 @@ private constructor( scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = apply { this.scheduledDepartureInterval = scheduledDepartureInterval @@ -1094,8 +1132,6 @@ private constructor( scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) /** Scheduled departure time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { this.scheduledDepartureTime = scheduledDepartureTime } @@ -1105,8 +1141,6 @@ private constructor( scheduledTrack(JsonField.of(scheduledTrack)) /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") - @ExcludeMissing fun scheduledTrack(scheduledTrack: JsonField) = apply { this.scheduledTrack = scheduledTrack } @@ -1121,8 +1155,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -1132,8 +1164,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } @@ -1142,16 +1172,12 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status of the arrival. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** The ID of the stop the vehicle is arriving at. */ fun stopId(stopId: String) = stopId(JsonField.of(stopId)) /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } /** @@ -1164,8 +1190,6 @@ private constructor( * Index of the stop into the sequence of stops that make up the trip for this * arrival. */ - @JsonProperty("stopSequence") - @ExcludeMissing fun stopSequence(stopSequence: JsonField) = apply { this.stopSequence = stopSequence } @@ -1175,8 +1199,6 @@ private constructor( totalStopsInTrip(JsonField.of(totalStopsInTrip)) /** Total number of stops visited on the trip for this arrival. */ - @JsonProperty("totalStopsInTrip") - @ExcludeMissing fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { this.totalStopsInTrip = totalStopsInTrip } @@ -1192,8 +1214,6 @@ private constructor( * Optional trip headsign that potentially overrides the trip headsign in the * referenced trip element. */ - @JsonProperty("tripHeadsign") - @ExcludeMissing fun tripHeadsign(tripHeadsign: JsonField) = apply { this.tripHeadsign = tripHeadsign } @@ -1202,16 +1222,12 @@ private constructor( fun tripId(tripId: String) = tripId(JsonField.of(tripId)) /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } /** Trip-specific status for the arriving transit vehicle. */ fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") - @ExcludeMissing fun tripStatus(tripStatus: JsonField) = apply { this.tripStatus = tripStatus } @@ -1220,20 +1236,17 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1241,6 +1254,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ArrivalsAndDeparture = ArrivalsAndDeparture( actualTrack, @@ -1282,42 +1303,95 @@ private constructor( } /** Trip-specific status for the arriving transit vehicle. */ - @JsonDeserialize(builder = TripStatus.Builder::class) @NoAutoDetect class TripStatus + @JsonCreator private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("activeTripId") + @ExcludeMissing + private val activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + private val closestStop: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + private val occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + private val occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + private val scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Trip ID of the trip the vehicle is actively serving. */ fun activeTripId(): String = activeTripId.getRequired("activeTripId") @@ -1590,6 +1664,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): TripStatus = apply { if (!validated) { activeTripId() @@ -1665,34 +1741,34 @@ private constructor( @JvmSynthetic internal fun from(tripStatus: TripStatus) = apply { - this.activeTripId = tripStatus.activeTripId - this.blockTripSequence = tripStatus.blockTripSequence - this.closestStop = tripStatus.closestStop - this.closestStopTimeOffset = tripStatus.closestStopTimeOffset - this.distanceAlongTrip = tripStatus.distanceAlongTrip - this.frequency = tripStatus.frequency - this.lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - this.lastKnownLocation = tripStatus.lastKnownLocation - this.lastKnownOrientation = tripStatus.lastKnownOrientation - this.lastLocationUpdateTime = tripStatus.lastLocationUpdateTime - this.lastUpdateTime = tripStatus.lastUpdateTime - this.nextStop = tripStatus.nextStop - this.nextStopTimeOffset = tripStatus.nextStopTimeOffset - this.occupancyCapacity = tripStatus.occupancyCapacity - this.occupancyCount = tripStatus.occupancyCount - this.occupancyStatus = tripStatus.occupancyStatus - this.orientation = tripStatus.orientation - this.phase = tripStatus.phase - this.position = tripStatus.position - this.predicted = tripStatus.predicted - this.scheduleDeviation = tripStatus.scheduleDeviation - this.scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip - this.serviceDate = tripStatus.serviceDate - this.situationIds = tripStatus.situationIds - this.status = tripStatus.status - this.totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip - this.vehicleId = tripStatus.vehicleId - additionalProperties(tripStatus.additionalProperties) + activeTripId = tripStatus.activeTripId + blockTripSequence = tripStatus.blockTripSequence + closestStop = tripStatus.closestStop + closestStopTimeOffset = tripStatus.closestStopTimeOffset + distanceAlongTrip = tripStatus.distanceAlongTrip + frequency = tripStatus.frequency + lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip + lastKnownLocation = tripStatus.lastKnownLocation + lastKnownOrientation = tripStatus.lastKnownOrientation + lastLocationUpdateTime = tripStatus.lastLocationUpdateTime + lastUpdateTime = tripStatus.lastUpdateTime + nextStop = tripStatus.nextStop + nextStopTimeOffset = tripStatus.nextStopTimeOffset + occupancyCapacity = tripStatus.occupancyCapacity + occupancyCount = tripStatus.occupancyCount + occupancyStatus = tripStatus.occupancyStatus + orientation = tripStatus.orientation + phase = tripStatus.phase + position = tripStatus.position + predicted = tripStatus.predicted + scheduleDeviation = tripStatus.scheduleDeviation + scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip + serviceDate = tripStatus.serviceDate + situationIds = tripStatus.situationIds + status = tripStatus.status + totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip + vehicleId = tripStatus.vehicleId + additionalProperties = tripStatus.additionalProperties.toMutableMap() } /** Trip ID of the trip the vehicle is actively serving. */ @@ -1700,8 +1776,6 @@ private constructor( activeTripId(JsonField.of(activeTripId)) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing fun activeTripId(activeTripId: JsonField) = apply { this.activeTripId = activeTripId } @@ -1715,8 +1789,6 @@ private constructor( /** * Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -1730,8 +1802,6 @@ private constructor( /** * ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing fun closestStop(closestStop: JsonField) = apply { this.closestStop = closestStop } @@ -1747,8 +1817,6 @@ private constructor( * Time offset from the closest stop to the current position of the transit * vehicle (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { this.closestStopTimeOffset = closestStopTimeOffset } @@ -1764,8 +1832,6 @@ private constructor( * Distance, in meters, the transit vehicle has progressed along the active * trip. */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -1778,8 +1844,6 @@ private constructor( /** * Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -1795,8 +1859,6 @@ private constructor( * Last known distance along the trip received in real-time from the transit * vehicle. */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing fun lastKnownDistanceAlongTrip( lastKnownDistanceAlongTrip: JsonField ) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } @@ -1806,8 +1868,6 @@ private constructor( lastKnownLocation(JsonField.of(lastKnownLocation)) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing fun lastKnownLocation(lastKnownLocation: JsonField) = apply { this.lastKnownLocation = lastKnownLocation @@ -1824,8 +1884,6 @@ private constructor( * Last known orientation value received in real-time from the transit * vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { this.lastKnownOrientation = lastKnownOrientation } @@ -1841,8 +1899,6 @@ private constructor( * Timestamp of the last known real-time location update from the transit * vehicle. */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { this.lastLocationUpdateTime = lastLocationUpdateTime @@ -1857,8 +1913,6 @@ private constructor( /** * Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -1867,8 +1921,6 @@ private constructor( fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } @@ -1884,8 +1936,6 @@ private constructor( * Time offset from the next stop to the current position of the transit * vehicle (in seconds). */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { this.nextStopTimeOffset = nextStopTimeOffset } @@ -1895,8 +1945,6 @@ private constructor( occupancyCapacity(JsonField.of(occupancyCapacity)) /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing fun occupancyCapacity(occupancyCapacity: JsonField) = apply { this.occupancyCapacity = occupancyCapacity } @@ -1906,8 +1954,6 @@ private constructor( occupancyCount(JsonField.of(occupancyCount)) /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing fun occupancyCount(occupancyCount: JsonField) = apply { this.occupancyCount = occupancyCount } @@ -1917,8 +1963,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -1932,8 +1976,6 @@ private constructor( /** * Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing fun orientation(orientation: JsonField) = apply { this.orientation = orientation } @@ -1942,16 +1984,12 @@ private constructor( fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing fun phase(phase: JsonField) = apply { this.phase = phase } /** Current position of the transit vehicle. */ fun position(position: Position) = position(JsonField.of(position)) /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } @@ -1960,8 +1998,6 @@ private constructor( fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } @@ -1977,8 +2013,6 @@ private constructor( * Deviation from the schedule in seconds (positive for late, negative for * early). */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing fun scheduleDeviation(scheduleDeviation: JsonField) = apply { this.scheduleDeviation = scheduleDeviation } @@ -1994,8 +2028,6 @@ private constructor( * Distance, in meters, the transit vehicle is scheduled to have progressed * along the active trip. */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing fun scheduledDistanceAlongTrip( scheduledDistanceAlongTrip: JsonField ) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip } @@ -2010,8 +2042,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of * the service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -2021,8 +2051,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } @@ -2031,8 +2059,6 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** Total length of the trip, in meters. */ @@ -2040,8 +2066,6 @@ private constructor( totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { this.totalDistanceAlongTrip = totalDistanceAlongTrip @@ -2051,8 +2075,6 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } @@ -2060,18 +2082,25 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): TripStatus = TripStatus( activeTripId, @@ -2106,17 +2135,21 @@ private constructor( } /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) @NoAutoDetect class LastKnownLocation + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the last known location of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -2133,6 +2166,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): LastKnownLocation = apply { if (!validated) { lat() @@ -2157,42 +2192,46 @@ private constructor( @JvmSynthetic internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) + 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)) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): LastKnownLocation = LastKnownLocation( lat, @@ -2220,17 +2259,21 @@ private constructor( } /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) @NoAutoDetect class Position + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the current position of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -2247,6 +2290,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Position = apply { if (!validated) { lat() @@ -2271,42 +2316,45 @@ private constructor( @JvmSynthetic internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) + 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)) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Position = Position( lat, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt index e84785b..427be87 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ArrivalAndDepartureRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt index 4db9cf3..9d491fe 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = ArrivalAndDepartureRetrieveResponse.Builder::class) @NoAutoDetect class ArrivalAndDepartureRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): ArrivalAndDepartureRetrieveResponse = apply { if (!validated) { code() @@ -92,58 +97,54 @@ private constructor( internal fun from( arrivalAndDepartureRetrieveResponse: ArrivalAndDepartureRetrieveResponse ) = apply { - this.code = arrivalAndDepartureRetrieveResponse.code - this.currentTime = arrivalAndDepartureRetrieveResponse.currentTime - this.text = arrivalAndDepartureRetrieveResponse.text - this.version = arrivalAndDepartureRetrieveResponse.version - this.data = arrivalAndDepartureRetrieveResponse.data - additionalProperties(arrivalAndDepartureRetrieveResponse.additionalProperties) + code = arrivalAndDepartureRetrieveResponse.code + currentTime = arrivalAndDepartureRetrieveResponse.currentTime + text = arrivalAndDepartureRetrieveResponse.text + version = arrivalAndDepartureRetrieveResponse.version + data = arrivalAndDepartureRetrieveResponse.data + additionalProperties = + arrivalAndDepartureRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ArrivalAndDepartureRetrieveResponse = ArrivalAndDepartureRetrieveResponse( code, @@ -155,17 +156,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -178,6 +182,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -201,39 +207,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -242,49 +249,116 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val actualTrack: JsonField, - private val arrivalEnabled: JsonField, - private val blockTripSequence: JsonField, - private val departureEnabled: JsonField, - private val distanceFromStop: JsonField, - private val frequency: JsonField, - private val historicalOccupancy: JsonField, - private val lastUpdateTime: JsonField, - private val numberOfStopsAway: JsonField, - private val occupancyStatus: JsonField, - private val predicted: JsonField, - private val predictedArrivalInterval: JsonField, - private val predictedArrivalTime: JsonField, - private val predictedDepartureInterval: JsonField, - private val predictedDepartureTime: JsonField, - private val predictedOccupancy: JsonField, - private val routeId: JsonField, - private val routeLongName: JsonField, - private val routeShortName: JsonField, - private val scheduledArrivalInterval: JsonField, - private val scheduledArrivalTime: JsonField, - private val scheduledDepartureInterval: JsonField, - private val scheduledDepartureTime: JsonField, - private val scheduledTrack: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val stopId: JsonField, - private val stopSequence: JsonField, - private val totalStopsInTrip: JsonField, - private val tripHeadsign: JsonField, - private val tripId: JsonField, - private val tripStatus: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("actualTrack") + @ExcludeMissing + private val actualTrack: JsonField = JsonMissing.of(), + @JsonProperty("arrivalEnabled") + @ExcludeMissing + private val arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + private val departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("distanceFromStop") + @ExcludeMissing + private val distanceFromStop: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + private val historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + private val numberOfStopsAway: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + private val predictedArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + private val predictedArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + private val predictedDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + private val predictedDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedOccupancy") + @ExcludeMissing + private val predictedOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("routeLongName") + @ExcludeMissing + private val routeLongName: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + private val routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + private val scheduledArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + private val scheduledArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + private val scheduledDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + private val scheduledDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledTrack") + @ExcludeMissing + private val scheduledTrack: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopSequence") + @ExcludeMissing + private val stopSequence: JsonField = JsonMissing.of(), + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + private val totalStopsInTrip: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + private val tripStatus: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The actual track information of the arriving transit vehicle. */ fun actualTrack(): Optional = Optional.ofNullable(actualTrack.getNullable("actualTrack")) @@ -600,6 +674,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { actualTrack() @@ -687,49 +763,47 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.actualTrack = entry.actualTrack - this.arrivalEnabled = entry.arrivalEnabled - this.blockTripSequence = entry.blockTripSequence - this.departureEnabled = entry.departureEnabled - this.distanceFromStop = entry.distanceFromStop - this.frequency = entry.frequency - this.historicalOccupancy = entry.historicalOccupancy - this.lastUpdateTime = entry.lastUpdateTime - this.numberOfStopsAway = entry.numberOfStopsAway - this.occupancyStatus = entry.occupancyStatus - this.predicted = entry.predicted - this.predictedArrivalInterval = entry.predictedArrivalInterval - this.predictedArrivalTime = entry.predictedArrivalTime - this.predictedDepartureInterval = entry.predictedDepartureInterval - this.predictedDepartureTime = entry.predictedDepartureTime - this.predictedOccupancy = entry.predictedOccupancy - this.routeId = entry.routeId - this.routeLongName = entry.routeLongName - this.routeShortName = entry.routeShortName - this.scheduledArrivalInterval = entry.scheduledArrivalInterval - this.scheduledArrivalTime = entry.scheduledArrivalTime - this.scheduledDepartureInterval = entry.scheduledDepartureInterval - this.scheduledDepartureTime = entry.scheduledDepartureTime - this.scheduledTrack = entry.scheduledTrack - this.serviceDate = entry.serviceDate - this.situationIds = entry.situationIds - this.status = entry.status - this.stopId = entry.stopId - this.stopSequence = entry.stopSequence - this.totalStopsInTrip = entry.totalStopsInTrip - this.tripHeadsign = entry.tripHeadsign - this.tripId = entry.tripId - this.tripStatus = entry.tripStatus - this.vehicleId = entry.vehicleId - additionalProperties(entry.additionalProperties) + actualTrack = entry.actualTrack + arrivalEnabled = entry.arrivalEnabled + blockTripSequence = entry.blockTripSequence + departureEnabled = entry.departureEnabled + distanceFromStop = entry.distanceFromStop + frequency = entry.frequency + historicalOccupancy = entry.historicalOccupancy + lastUpdateTime = entry.lastUpdateTime + numberOfStopsAway = entry.numberOfStopsAway + occupancyStatus = entry.occupancyStatus + predicted = entry.predicted + predictedArrivalInterval = entry.predictedArrivalInterval + predictedArrivalTime = entry.predictedArrivalTime + predictedDepartureInterval = entry.predictedDepartureInterval + predictedDepartureTime = entry.predictedDepartureTime + predictedOccupancy = entry.predictedOccupancy + routeId = entry.routeId + routeLongName = entry.routeLongName + routeShortName = entry.routeShortName + scheduledArrivalInterval = entry.scheduledArrivalInterval + scheduledArrivalTime = entry.scheduledArrivalTime + scheduledDepartureInterval = entry.scheduledDepartureInterval + scheduledDepartureTime = entry.scheduledDepartureTime + scheduledTrack = entry.scheduledTrack + serviceDate = entry.serviceDate + situationIds = entry.situationIds + status = entry.status + stopId = entry.stopId + stopSequence = entry.stopSequence + totalStopsInTrip = entry.totalStopsInTrip + tripHeadsign = entry.tripHeadsign + tripId = entry.tripId + tripStatus = entry.tripStatus + vehicleId = entry.vehicleId + additionalProperties = entry.additionalProperties.toMutableMap() } /** The actual track information of the arriving transit vehicle. */ fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") - @ExcludeMissing fun actualTrack(actualTrack: JsonField) = apply { this.actualTrack = actualTrack } @@ -739,8 +813,6 @@ private constructor( arrivalEnabled(JsonField.of(arrivalEnabled)) /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") - @ExcludeMissing fun arrivalEnabled(arrivalEnabled: JsonField) = apply { this.arrivalEnabled = arrivalEnabled } @@ -750,8 +822,6 @@ private constructor( blockTripSequence(JsonField.of(blockTripSequence)) /** Index of this arrival’s trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -761,8 +831,6 @@ private constructor( departureEnabled(JsonField.of(departureEnabled)) /** Indicates if riders can depart from this transit vehicle. */ - @JsonProperty("departureEnabled") - @ExcludeMissing fun departureEnabled(departureEnabled: JsonField) = apply { this.departureEnabled = departureEnabled } @@ -772,8 +840,6 @@ private constructor( distanceFromStop(JsonField.of(distanceFromStop)) /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing fun distanceFromStop(distanceFromStop: JsonField) = apply { this.distanceFromStop = distanceFromStop } @@ -782,8 +848,6 @@ private constructor( fun frequency(frequency: String) = frequency(JsonField.of(frequency)) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } /** Historical occupancy information of the transit vehicle. */ @@ -791,8 +855,6 @@ private constructor( historicalOccupancy(JsonField.of(historicalOccupancy)) /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing fun historicalOccupancy(historicalOccupancy: JsonField) = apply { this.historicalOccupancy = historicalOccupancy } @@ -802,8 +864,6 @@ private constructor( lastUpdateTime(JsonField.of(lastUpdateTime)) /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -819,8 +879,6 @@ private constructor( * Number of stops between the arriving transit vehicle and the current stop * (excluding the current stop). */ - @JsonProperty("numberOfStopsAway") - @ExcludeMissing fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { this.numberOfStopsAway = numberOfStopsAway } @@ -830,8 +888,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -840,8 +896,6 @@ private constructor( fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } /** Interval for predicted arrival time, if available. */ @@ -849,8 +903,6 @@ private constructor( predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = apply { this.predictedArrivalInterval = predictedArrivalInterval } @@ -866,8 +918,6 @@ private constructor( * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time * available). */ - @JsonProperty("predictedArrivalTime") - @ExcludeMissing fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { this.predictedArrivalTime = predictedArrivalTime } @@ -877,8 +927,6 @@ private constructor( predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = apply { this.predictedDepartureInterval = predictedDepartureInterval @@ -895,8 +943,6 @@ private constructor( * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time * available). */ - @JsonProperty("predictedDepartureTime") - @ExcludeMissing fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { this.predictedDepartureTime = predictedDepartureTime } @@ -906,8 +952,6 @@ private constructor( predictedOccupancy(JsonField.of(predictedOccupancy)) /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing fun predictedOccupancy(predictedOccupancy: JsonField) = apply { this.predictedOccupancy = predictedOccupancy } @@ -916,8 +960,6 @@ private constructor( fun routeId(routeId: String) = routeId(JsonField.of(routeId)) /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } /** @@ -931,8 +973,6 @@ private constructor( * Optional route long name that potentially overrides the route long name in the * referenced route element. */ - @JsonProperty("routeLongName") - @ExcludeMissing fun routeLongName(routeLongName: JsonField) = apply { this.routeLongName = routeLongName } @@ -948,8 +988,6 @@ private constructor( * Optional route short name that potentially overrides the route short name in the * referenced route element. */ - @JsonProperty("routeShortName") - @ExcludeMissing fun routeShortName(routeShortName: JsonField) = apply { this.routeShortName = routeShortName } @@ -959,8 +997,6 @@ private constructor( scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = apply { this.scheduledArrivalInterval = scheduledArrivalInterval } @@ -970,8 +1006,6 @@ private constructor( scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) /** Scheduled arrival time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { this.scheduledArrivalTime = scheduledArrivalTime } @@ -981,8 +1015,6 @@ private constructor( scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = apply { this.scheduledDepartureInterval = scheduledDepartureInterval @@ -993,8 +1025,6 @@ private constructor( scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) /** Scheduled departure time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { this.scheduledDepartureTime = scheduledDepartureTime } @@ -1004,8 +1034,6 @@ private constructor( scheduledTrack(JsonField.of(scheduledTrack)) /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") - @ExcludeMissing fun scheduledTrack(scheduledTrack: JsonField) = apply { this.scheduledTrack = scheduledTrack } @@ -1020,8 +1048,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -1031,8 +1057,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } @@ -1041,16 +1065,12 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status of the arrival. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** The ID of the stop the vehicle is arriving at. */ fun stopId(stopId: String) = stopId(JsonField.of(stopId)) /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } /** @@ -1063,8 +1083,6 @@ private constructor( * Index of the stop into the sequence of stops that make up the trip for this * arrival. */ - @JsonProperty("stopSequence") - @ExcludeMissing fun stopSequence(stopSequence: JsonField) = apply { this.stopSequence = stopSequence } @@ -1074,8 +1092,6 @@ private constructor( totalStopsInTrip(JsonField.of(totalStopsInTrip)) /** Total number of stops visited on the trip for this arrival. */ - @JsonProperty("totalStopsInTrip") - @ExcludeMissing fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { this.totalStopsInTrip = totalStopsInTrip } @@ -1090,8 +1106,6 @@ private constructor( * Optional trip headsign that potentially overrides the trip headsign in the * referenced trip element. */ - @JsonProperty("tripHeadsign") - @ExcludeMissing fun tripHeadsign(tripHeadsign: JsonField) = apply { this.tripHeadsign = tripHeadsign } @@ -1100,16 +1114,12 @@ private constructor( fun tripId(tripId: String) = tripId(JsonField.of(tripId)) /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } /** Trip-specific status for the arriving transit vehicle. */ fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") - @ExcludeMissing fun tripStatus(tripStatus: JsonField) = apply { this.tripStatus = tripStatus } @@ -1118,18 +1128,15 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1137,6 +1144,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( actualTrack, @@ -1178,42 +1193,95 @@ private constructor( } /** Trip-specific status for the arriving transit vehicle. */ - @JsonDeserialize(builder = TripStatus.Builder::class) @NoAutoDetect class TripStatus + @JsonCreator private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("activeTripId") + @ExcludeMissing + private val activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + private val closestStop: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + private val occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + private val occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + private val scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Trip ID of the trip the vehicle is actively serving. */ fun activeTripId(): String = activeTripId.getRequired("activeTripId") @@ -1468,6 +1536,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): TripStatus = apply { if (!validated) { activeTripId() @@ -1541,34 +1611,34 @@ private constructor( @JvmSynthetic internal fun from(tripStatus: TripStatus) = apply { - this.activeTripId = tripStatus.activeTripId - this.blockTripSequence = tripStatus.blockTripSequence - this.closestStop = tripStatus.closestStop - this.closestStopTimeOffset = tripStatus.closestStopTimeOffset - this.distanceAlongTrip = tripStatus.distanceAlongTrip - this.frequency = tripStatus.frequency - this.lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - this.lastKnownLocation = tripStatus.lastKnownLocation - this.lastKnownOrientation = tripStatus.lastKnownOrientation - this.lastLocationUpdateTime = tripStatus.lastLocationUpdateTime - this.lastUpdateTime = tripStatus.lastUpdateTime - this.nextStop = tripStatus.nextStop - this.nextStopTimeOffset = tripStatus.nextStopTimeOffset - this.occupancyCapacity = tripStatus.occupancyCapacity - this.occupancyCount = tripStatus.occupancyCount - this.occupancyStatus = tripStatus.occupancyStatus - this.orientation = tripStatus.orientation - this.phase = tripStatus.phase - this.position = tripStatus.position - this.predicted = tripStatus.predicted - this.scheduleDeviation = tripStatus.scheduleDeviation - this.scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip - this.serviceDate = tripStatus.serviceDate - this.situationIds = tripStatus.situationIds - this.status = tripStatus.status - this.totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip - this.vehicleId = tripStatus.vehicleId - additionalProperties(tripStatus.additionalProperties) + activeTripId = tripStatus.activeTripId + blockTripSequence = tripStatus.blockTripSequence + closestStop = tripStatus.closestStop + closestStopTimeOffset = tripStatus.closestStopTimeOffset + distanceAlongTrip = tripStatus.distanceAlongTrip + frequency = tripStatus.frequency + lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip + lastKnownLocation = tripStatus.lastKnownLocation + lastKnownOrientation = tripStatus.lastKnownOrientation + lastLocationUpdateTime = tripStatus.lastLocationUpdateTime + lastUpdateTime = tripStatus.lastUpdateTime + nextStop = tripStatus.nextStop + nextStopTimeOffset = tripStatus.nextStopTimeOffset + occupancyCapacity = tripStatus.occupancyCapacity + occupancyCount = tripStatus.occupancyCount + occupancyStatus = tripStatus.occupancyStatus + orientation = tripStatus.orientation + phase = tripStatus.phase + position = tripStatus.position + predicted = tripStatus.predicted + scheduleDeviation = tripStatus.scheduleDeviation + scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip + serviceDate = tripStatus.serviceDate + situationIds = tripStatus.situationIds + status = tripStatus.status + totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip + vehicleId = tripStatus.vehicleId + additionalProperties = tripStatus.additionalProperties.toMutableMap() } /** Trip ID of the trip the vehicle is actively serving. */ @@ -1576,8 +1646,6 @@ private constructor( activeTripId(JsonField.of(activeTripId)) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing fun activeTripId(activeTripId: JsonField) = apply { this.activeTripId = activeTripId } @@ -1587,8 +1655,6 @@ private constructor( blockTripSequence(JsonField.of(blockTripSequence)) /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -1597,8 +1663,6 @@ private constructor( fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing fun closestStop(closestStop: JsonField) = apply { this.closestStop = closestStop } @@ -1614,8 +1678,6 @@ private constructor( * Time offset from the closest stop to the current position of the transit * vehicle (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { this.closestStopTimeOffset = closestStopTimeOffset } @@ -1631,8 +1693,6 @@ private constructor( * Distance, in meters, the transit vehicle has progressed along the active * trip. */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -1641,8 +1701,6 @@ private constructor( fun frequency(frequency: String) = frequency(JsonField.of(frequency)) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -1658,8 +1716,6 @@ private constructor( * Last known distance along the trip received in real-time from the transit * vehicle. */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip @@ -1670,8 +1726,6 @@ private constructor( lastKnownLocation(JsonField.of(lastKnownLocation)) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing fun lastKnownLocation(lastKnownLocation: JsonField) = apply { this.lastKnownLocation = lastKnownLocation } @@ -1685,8 +1739,6 @@ private constructor( /** * Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { this.lastKnownOrientation = lastKnownOrientation } @@ -1702,8 +1754,6 @@ private constructor( * Timestamp of the last known real-time location update from the transit * vehicle. */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { this.lastLocationUpdateTime = lastLocationUpdateTime } @@ -1713,8 +1763,6 @@ private constructor( lastUpdateTime(JsonField.of(lastUpdateTime)) /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -1723,8 +1771,6 @@ private constructor( fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } /** @@ -1738,8 +1784,6 @@ private constructor( * Time offset from the next stop to the current position of the transit vehicle * (in seconds). */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { this.nextStopTimeOffset = nextStopTimeOffset } @@ -1749,8 +1793,6 @@ private constructor( occupancyCapacity(JsonField.of(occupancyCapacity)) /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing fun occupancyCapacity(occupancyCapacity: JsonField) = apply { this.occupancyCapacity = occupancyCapacity } @@ -1760,8 +1802,6 @@ private constructor( occupancyCount(JsonField.of(occupancyCount)) /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing fun occupancyCount(occupancyCount: JsonField) = apply { this.occupancyCount = occupancyCount } @@ -1771,8 +1811,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -1781,8 +1819,6 @@ private constructor( fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing fun orientation(orientation: JsonField) = apply { this.orientation = orientation } @@ -1791,24 +1827,18 @@ private constructor( fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing fun phase(phase: JsonField) = apply { this.phase = phase } /** Current position of the transit vehicle. */ fun position(position: Position) = position(JsonField.of(position)) /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } @@ -1824,8 +1854,6 @@ private constructor( * Deviation from the schedule in seconds (positive for late, negative for * early). */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing fun scheduleDeviation(scheduleDeviation: JsonField) = apply { this.scheduleDeviation = scheduleDeviation } @@ -1841,8 +1869,6 @@ private constructor( * Distance, in meters, the transit vehicle is scheduled to have progressed * along the active trip. */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip @@ -1858,8 +1884,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -1869,8 +1893,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } @@ -1879,8 +1901,6 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** Total length of the trip, in meters. */ @@ -1888,8 +1908,6 @@ private constructor( totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { this.totalDistanceAlongTrip = totalDistanceAlongTrip } @@ -1898,20 +1916,17 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1919,6 +1934,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): TripStatus = TripStatus( activeTripId, @@ -1953,17 +1976,20 @@ private constructor( } /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) @NoAutoDetect class LastKnownLocation + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the last known location of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1980,6 +2006,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): LastKnownLocation = apply { if (!validated) { lat() @@ -2004,42 +2032,46 @@ private constructor( @JvmSynthetic internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) + 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)) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): LastKnownLocation = LastKnownLocation( lat, @@ -2067,17 +2099,20 @@ private constructor( } /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) @NoAutoDetect class Position + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the current position of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -2094,6 +2129,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Position = apply { if (!validated) { lat() @@ -2118,42 +2155,45 @@ private constructor( @JvmSynthetic internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) + 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)) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Position = Position( lat, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt index a670734..ab76562 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class BlockRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt index 8b9b6b4..cbeff5f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = BlockRetrieveResponse.Builder::class) @NoAutoDetect class BlockRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): BlockRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(blockRetrieveResponse: BlockRetrieveResponse) = apply { - this.code = blockRetrieveResponse.code - this.currentTime = blockRetrieveResponse.currentTime - this.text = blockRetrieveResponse.text - this.version = blockRetrieveResponse.version - this.data = blockRetrieveResponse.data - additionalProperties(blockRetrieveResponse.additionalProperties) + code = blockRetrieveResponse.code + currentTime = blockRetrieveResponse.currentTime + text = blockRetrieveResponse.text + version = blockRetrieveResponse.version + data = blockRetrieveResponse.data + additionalProperties = blockRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): BlockRetrieveResponse = BlockRetrieveResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,17 +246,20 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val id: JsonField, - private val configurations: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("configurations") + @ExcludeMissing + private val configurations: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun id(): String = id.getRequired("id") fun configurations(): List = configurations.getRequired("configurations") @@ -263,6 +272,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { id() @@ -286,34 +297,29 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.id = entry.id - this.configurations = entry.configurations - additionalProperties(entry.additionalProperties) + id = entry.id + configurations = entry.configurations + additionalProperties = entry.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun configurations(configurations: List) = configurations(JsonField.of(configurations)) - @JsonProperty("configurations") - @ExcludeMissing fun configurations(configurations: JsonField>) = apply { this.configurations = configurations } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -321,6 +327,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( id, @@ -329,18 +343,23 @@ private constructor( ) } - @JsonDeserialize(builder = Configuration.Builder::class) @NoAutoDetect class Configuration + @JsonCreator private constructor( - private val activeServiceIds: JsonField>, - private val inactiveServiceIds: JsonField>, - private val trips: JsonField>, - private val additionalProperties: Map, + @JsonProperty("activeServiceIds") + @ExcludeMissing + private val activeServiceIds: JsonField> = JsonMissing.of(), + @JsonProperty("inactiveServiceIds") + @ExcludeMissing + private val inactiveServiceIds: JsonField> = JsonMissing.of(), + @JsonProperty("trips") + @ExcludeMissing + private val trips: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun activeServiceIds(): List = activeServiceIds.getRequired("activeServiceIds") @@ -363,6 +382,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Configuration = apply { if (!validated) { activeServiceIds() @@ -388,17 +409,15 @@ private constructor( @JvmSynthetic internal fun from(configuration: Configuration) = apply { - this.activeServiceIds = configuration.activeServiceIds - this.inactiveServiceIds = configuration.inactiveServiceIds - this.trips = configuration.trips - additionalProperties(configuration.additionalProperties) + activeServiceIds = configuration.activeServiceIds + inactiveServiceIds = configuration.inactiveServiceIds + trips = configuration.trips + additionalProperties = configuration.additionalProperties.toMutableMap() } fun activeServiceIds(activeServiceIds: List) = activeServiceIds(JsonField.of(activeServiceIds)) - @JsonProperty("activeServiceIds") - @ExcludeMissing fun activeServiceIds(activeServiceIds: JsonField>) = apply { this.activeServiceIds = activeServiceIds } @@ -406,26 +425,21 @@ private constructor( fun inactiveServiceIds(inactiveServiceIds: List) = inactiveServiceIds(JsonField.of(inactiveServiceIds)) - @JsonProperty("inactiveServiceIds") - @ExcludeMissing fun inactiveServiceIds(inactiveServiceIds: JsonField>) = apply { this.inactiveServiceIds = inactiveServiceIds } fun trips(trips: List) = trips(JsonField.of(trips)) - @JsonProperty("trips") - @ExcludeMissing fun trips(trips: JsonField>) = apply { this.trips = trips } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -433,6 +447,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Configuration = Configuration( activeServiceIds.map { it.toImmutable() }, @@ -442,19 +464,26 @@ private constructor( ) } - @JsonDeserialize(builder = Trip.Builder::class) @NoAutoDetect class Trip + @JsonCreator private constructor( - private val tripId: JsonField, - private val distanceAlongBlock: JsonField, - private val accumulatedSlackTime: JsonField, - private val blockStopTimes: JsonField>, - private val additionalProperties: Map, + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + private val distanceAlongBlock: JsonField = JsonMissing.of(), + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + private val accumulatedSlackTime: JsonField = JsonMissing.of(), + @JsonProperty("blockStopTimes") + @ExcludeMissing + private val blockStopTimes: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun tripId(): String = tripId.getRequired("tripId") fun distanceAlongBlock(): Double = @@ -484,6 +513,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Trip = apply { if (!validated) { tripId() @@ -513,24 +544,20 @@ private constructor( @JvmSynthetic internal fun from(trip: Trip) = apply { - this.tripId = trip.tripId - this.distanceAlongBlock = trip.distanceAlongBlock - this.accumulatedSlackTime = trip.accumulatedSlackTime - this.blockStopTimes = trip.blockStopTimes - additionalProperties(trip.additionalProperties) + tripId = trip.tripId + distanceAlongBlock = trip.distanceAlongBlock + accumulatedSlackTime = trip.accumulatedSlackTime + blockStopTimes = trip.blockStopTimes + additionalProperties = trip.additionalProperties.toMutableMap() } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun distanceAlongBlock(distanceAlongBlock: Double) = distanceAlongBlock(JsonField.of(distanceAlongBlock)) - @JsonProperty("distanceAlongBlock") - @ExcludeMissing fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { this.distanceAlongBlock = distanceAlongBlock } @@ -538,8 +565,6 @@ private constructor( fun accumulatedSlackTime(accumulatedSlackTime: Double) = accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = apply { this.accumulatedSlackTime = accumulatedSlackTime } @@ -547,8 +572,6 @@ private constructor( fun blockStopTimes(blockStopTimes: List) = blockStopTimes(JsonField.of(blockStopTimes)) - @JsonProperty("blockStopTimes") - @ExcludeMissing fun blockStopTimes(blockStopTimes: JsonField>) = apply { this.blockStopTimes = blockStopTimes } @@ -556,18 +579,25 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Trip = Trip( tripId, @@ -578,19 +608,27 @@ private constructor( ) } - @JsonDeserialize(builder = BlockStopTime.Builder::class) @NoAutoDetect class BlockStopTime + @JsonCreator private constructor( - private val blockSequence: JsonField, - private val distanceAlongBlock: JsonField, - private val accumulatedSlackTime: JsonField, - private val stopTime: JsonField, - private val additionalProperties: Map, + @JsonProperty("blockSequence") + @ExcludeMissing + private val blockSequence: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + private val distanceAlongBlock: JsonField = JsonMissing.of(), + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + private val accumulatedSlackTime: JsonField = JsonMissing.of(), + @JsonProperty("stopTime") + @ExcludeMissing + private val stopTime: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun blockSequence(): Long = blockSequence.getRequired("blockSequence") fun distanceAlongBlock(): Double = @@ -619,6 +657,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): BlockStopTime = apply { if (!validated) { blockSequence() @@ -647,18 +687,17 @@ private constructor( @JvmSynthetic internal fun from(blockStopTime: BlockStopTime) = apply { - this.blockSequence = blockStopTime.blockSequence - this.distanceAlongBlock = blockStopTime.distanceAlongBlock - this.accumulatedSlackTime = blockStopTime.accumulatedSlackTime - this.stopTime = blockStopTime.stopTime - additionalProperties(blockStopTime.additionalProperties) + blockSequence = blockStopTime.blockSequence + distanceAlongBlock = blockStopTime.distanceAlongBlock + accumulatedSlackTime = blockStopTime.accumulatedSlackTime + stopTime = blockStopTime.stopTime + additionalProperties = + blockStopTime.additionalProperties.toMutableMap() } fun blockSequence(blockSequence: Long) = blockSequence(JsonField.of(blockSequence)) - @JsonProperty("blockSequence") - @ExcludeMissing fun blockSequence(blockSequence: JsonField) = apply { this.blockSequence = blockSequence } @@ -666,8 +705,6 @@ private constructor( fun distanceAlongBlock(distanceAlongBlock: Double) = distanceAlongBlock(JsonField.of(distanceAlongBlock)) - @JsonProperty("distanceAlongBlock") - @ExcludeMissing fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { this.distanceAlongBlock = distanceAlongBlock } @@ -675,8 +712,6 @@ private constructor( fun accumulatedSlackTime(accumulatedSlackTime: Double) = accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = apply { this.accumulatedSlackTime = accumulatedSlackTime @@ -684,8 +719,6 @@ private constructor( fun stopTime(stopTime: StopTime) = stopTime(JsonField.of(stopTime)) - @JsonProperty("stopTime") - @ExcludeMissing fun stopTime(stopTime: JsonField) = apply { this.stopTime = stopTime } @@ -693,18 +726,25 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): BlockStopTime = BlockStopTime( blockSequence, @@ -715,20 +755,30 @@ private constructor( ) } - @JsonDeserialize(builder = StopTime.Builder::class) @NoAutoDetect class StopTime + @JsonCreator private constructor( - private val stopId: JsonField, - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val pickupType: JsonField, - private val dropOffType: JsonField, - private val additionalProperties: Map, + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonProperty("arrivalTime") + @ExcludeMissing + private val arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + private val departureTime: JsonField = JsonMissing.of(), + @JsonProperty("pickupType") + @ExcludeMissing + private val pickupType: JsonField = JsonMissing.of(), + @JsonProperty("dropOffType") + @ExcludeMissing + private val dropOffType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun stopId(): String = stopId.getRequired("stopId") fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") @@ -764,6 +814,8 @@ private constructor( fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopTime = apply { if (!validated) { stopId() @@ -794,18 +846,17 @@ private constructor( @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - this.stopId = stopTime.stopId - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.pickupType = stopTime.pickupType - this.dropOffType = stopTime.dropOffType - additionalProperties(stopTime.additionalProperties) + stopId = stopTime.stopId + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + pickupType = stopTime.pickupType + dropOffType = stopTime.dropOffType + additionalProperties = + stopTime.additionalProperties.toMutableMap() } fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } @@ -813,8 +864,6 @@ private constructor( fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing fun arrivalTime(arrivalTime: JsonField) = apply { this.arrivalTime = arrivalTime } @@ -822,8 +871,6 @@ private constructor( fun departureTime(departureTime: Long) = departureTime(JsonField.of(departureTime)) - @JsonProperty("departureTime") - @ExcludeMissing fun departureTime(departureTime: JsonField) = apply { this.departureTime = departureTime } @@ -831,8 +878,6 @@ private constructor( fun pickupType(pickupType: Long) = pickupType(JsonField.of(pickupType)) - @JsonProperty("pickupType") - @ExcludeMissing fun pickupType(pickupType: JsonField) = apply { this.pickupType = pickupType } @@ -840,8 +885,6 @@ private constructor( fun dropOffType(dropOffType: Long) = dropOffType(JsonField.of(dropOffType)) - @JsonProperty("dropOffType") - @ExcludeMissing fun dropOffType(dropOffType: JsonField) = apply { this.dropOffType = dropOffType } @@ -850,18 +893,25 @@ private constructor( additionalProperties: Map ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopTime = StopTime( stopId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt index 92577ea..7c58fdd 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ConfigRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt index dc1d823..c103b8d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = ConfigRetrieveResponse.Builder::class) @NoAutoDetect class ConfigRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): ConfigRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(configRetrieveResponse: ConfigRetrieveResponse) = apply { - this.code = configRetrieveResponse.code - this.currentTime = configRetrieveResponse.currentTime - this.text = configRetrieveResponse.text - this.version = configRetrieveResponse.version - this.data = configRetrieveResponse.data - additionalProperties(configRetrieveResponse.additionalProperties) + code = configRetrieveResponse.code + currentTime = configRetrieveResponse.currentTime + text = configRetrieveResponse.text + version = configRetrieveResponse.version + data = configRetrieveResponse.data + additionalProperties = configRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ConfigRetrieveResponse = ConfigRetrieveResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,20 +246,29 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val gitProperties: JsonField, - private val id: JsonField, - private val name: JsonField, - private val serviceDateFrom: JsonField, - private val serviceDateTo: JsonField, - private val additionalProperties: Map, + @JsonProperty("gitProperties") + @ExcludeMissing + private val gitProperties: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("serviceDateFrom") + @ExcludeMissing + private val serviceDateFrom: JsonField = JsonMissing.of(), + @JsonProperty("serviceDateTo") + @ExcludeMissing + private val serviceDateTo: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun gitProperties(): Optional = Optional.ofNullable(gitProperties.getNullable("gitProperties")) @@ -283,6 +298,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { gitProperties().map { it.validate() } @@ -312,40 +329,32 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.gitProperties = entry.gitProperties - this.id = entry.id - this.name = entry.name - this.serviceDateFrom = entry.serviceDateFrom - this.serviceDateTo = entry.serviceDateTo - additionalProperties(entry.additionalProperties) + gitProperties = entry.gitProperties + id = entry.id + name = entry.name + serviceDateFrom = entry.serviceDateFrom + serviceDateTo = entry.serviceDateTo + additionalProperties = entry.additionalProperties.toMutableMap() } fun gitProperties(gitProperties: GitProperties) = gitProperties(JsonField.of(gitProperties)) - @JsonProperty("gitProperties") - @ExcludeMissing fun gitProperties(gitProperties: JsonField) = apply { this.gitProperties = gitProperties } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun serviceDateFrom(serviceDateFrom: String) = serviceDateFrom(JsonField.of(serviceDateFrom)) - @JsonProperty("serviceDateFrom") - @ExcludeMissing fun serviceDateFrom(serviceDateFrom: JsonField) = apply { this.serviceDateFrom = serviceDateFrom } @@ -353,20 +362,17 @@ private constructor( fun serviceDateTo(serviceDateTo: String) = serviceDateTo(JsonField.of(serviceDateTo)) - @JsonProperty("serviceDateTo") - @ExcludeMissing fun serviceDateTo(serviceDateTo: JsonField) = apply { this.serviceDateTo = serviceDateTo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -374,6 +380,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( gitProperties, @@ -385,35 +399,74 @@ private constructor( ) } - @JsonDeserialize(builder = GitProperties.Builder::class) @NoAutoDetect class GitProperties + @JsonCreator private constructor( - private val gitBranch: JsonField, - private val gitBuildHost: JsonField, - private val gitBuildTime: JsonField, - private val gitBuildUserEmail: JsonField, - private val gitBuildUserName: JsonField, - private val gitBuildVersion: JsonField, - private val gitClosestTagCommitCount: JsonField, - private val gitClosestTagName: JsonField, - private val gitCommitId: JsonField, - private val gitCommitIdAbbrev: JsonField, - private val gitCommitIdDescribe: JsonField, - private val gitCommitIdDescribeShort: JsonField, - private val gitCommitMessageFull: JsonField, - private val gitCommitMessageShort: JsonField, - private val gitCommitTime: JsonField, - private val gitCommitUserEmail: JsonField, - private val gitCommitUserName: JsonField, - private val gitDirty: JsonField, - private val gitRemoteOriginUrl: JsonField, - private val gitTags: JsonField, - private val additionalProperties: Map, + @JsonProperty("git.branch") + @ExcludeMissing + private val gitBranch: JsonField = JsonMissing.of(), + @JsonProperty("git.build.host") + @ExcludeMissing + private val gitBuildHost: JsonField = JsonMissing.of(), + @JsonProperty("git.build.time") + @ExcludeMissing + private val gitBuildTime: JsonField = JsonMissing.of(), + @JsonProperty("git.build.user.email") + @ExcludeMissing + private val gitBuildUserEmail: JsonField = JsonMissing.of(), + @JsonProperty("git.build.user.name") + @ExcludeMissing + private val gitBuildUserName: JsonField = JsonMissing.of(), + @JsonProperty("git.build.version") + @ExcludeMissing + private val gitBuildVersion: JsonField = JsonMissing.of(), + @JsonProperty("git.closest.tag.commit.count") + @ExcludeMissing + private val gitClosestTagCommitCount: JsonField = JsonMissing.of(), + @JsonProperty("git.closest.tag.name") + @ExcludeMissing + private val gitClosestTagName: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id") + @ExcludeMissing + private val gitCommitId: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.abbrev") + @ExcludeMissing + private val gitCommitIdAbbrev: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.describe") + @ExcludeMissing + private val gitCommitIdDescribe: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.describe-short") + @ExcludeMissing + private val gitCommitIdDescribeShort: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.message.full") + @ExcludeMissing + private val gitCommitMessageFull: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.message.short") + @ExcludeMissing + private val gitCommitMessageShort: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.time") + @ExcludeMissing + private val gitCommitTime: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.user.email") + @ExcludeMissing + private val gitCommitUserEmail: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.user.name") + @ExcludeMissing + private val gitCommitUserName: JsonField = JsonMissing.of(), + @JsonProperty("git.dirty") + @ExcludeMissing + private val gitDirty: JsonField = JsonMissing.of(), + @JsonProperty("git.remote.origin.url") + @ExcludeMissing + private val gitRemoteOriginUrl: JsonField = JsonMissing.of(), + @JsonProperty("git.tags") + @ExcludeMissing + private val gitTags: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun gitBranch(): Optional = Optional.ofNullable(gitBranch.getNullable("git.branch")) @@ -552,6 +605,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): GitProperties = apply { if (!validated) { gitBranch() @@ -611,33 +666,31 @@ private constructor( @JvmSynthetic internal fun from(gitProperties: GitProperties) = apply { - this.gitBranch = gitProperties.gitBranch - this.gitBuildHost = gitProperties.gitBuildHost - this.gitBuildTime = gitProperties.gitBuildTime - this.gitBuildUserEmail = gitProperties.gitBuildUserEmail - this.gitBuildUserName = gitProperties.gitBuildUserName - this.gitBuildVersion = gitProperties.gitBuildVersion - this.gitClosestTagCommitCount = gitProperties.gitClosestTagCommitCount - this.gitClosestTagName = gitProperties.gitClosestTagName - this.gitCommitId = gitProperties.gitCommitId - this.gitCommitIdAbbrev = gitProperties.gitCommitIdAbbrev - this.gitCommitIdDescribe = gitProperties.gitCommitIdDescribe - this.gitCommitIdDescribeShort = gitProperties.gitCommitIdDescribeShort - this.gitCommitMessageFull = gitProperties.gitCommitMessageFull - this.gitCommitMessageShort = gitProperties.gitCommitMessageShort - this.gitCommitTime = gitProperties.gitCommitTime - this.gitCommitUserEmail = gitProperties.gitCommitUserEmail - this.gitCommitUserName = gitProperties.gitCommitUserName - this.gitDirty = gitProperties.gitDirty - this.gitRemoteOriginUrl = gitProperties.gitRemoteOriginUrl - this.gitTags = gitProperties.gitTags - additionalProperties(gitProperties.additionalProperties) + gitBranch = gitProperties.gitBranch + gitBuildHost = gitProperties.gitBuildHost + gitBuildTime = gitProperties.gitBuildTime + gitBuildUserEmail = gitProperties.gitBuildUserEmail + gitBuildUserName = gitProperties.gitBuildUserName + gitBuildVersion = gitProperties.gitBuildVersion + gitClosestTagCommitCount = gitProperties.gitClosestTagCommitCount + gitClosestTagName = gitProperties.gitClosestTagName + gitCommitId = gitProperties.gitCommitId + gitCommitIdAbbrev = gitProperties.gitCommitIdAbbrev + gitCommitIdDescribe = gitProperties.gitCommitIdDescribe + gitCommitIdDescribeShort = gitProperties.gitCommitIdDescribeShort + gitCommitMessageFull = gitProperties.gitCommitMessageFull + gitCommitMessageShort = gitProperties.gitCommitMessageShort + gitCommitTime = gitProperties.gitCommitTime + gitCommitUserEmail = gitProperties.gitCommitUserEmail + gitCommitUserName = gitProperties.gitCommitUserName + gitDirty = gitProperties.gitDirty + gitRemoteOriginUrl = gitProperties.gitRemoteOriginUrl + gitTags = gitProperties.gitTags + additionalProperties = gitProperties.additionalProperties.toMutableMap() } fun gitBranch(gitBranch: String) = gitBranch(JsonField.of(gitBranch)) - @JsonProperty("git.branch") - @ExcludeMissing fun gitBranch(gitBranch: JsonField) = apply { this.gitBranch = gitBranch } @@ -645,8 +698,6 @@ private constructor( fun gitBuildHost(gitBuildHost: String) = gitBuildHost(JsonField.of(gitBuildHost)) - @JsonProperty("git.build.host") - @ExcludeMissing fun gitBuildHost(gitBuildHost: JsonField) = apply { this.gitBuildHost = gitBuildHost } @@ -654,8 +705,6 @@ private constructor( fun gitBuildTime(gitBuildTime: String) = gitBuildTime(JsonField.of(gitBuildTime)) - @JsonProperty("git.build.time") - @ExcludeMissing fun gitBuildTime(gitBuildTime: JsonField) = apply { this.gitBuildTime = gitBuildTime } @@ -663,8 +712,6 @@ private constructor( fun gitBuildUserEmail(gitBuildUserEmail: String) = gitBuildUserEmail(JsonField.of(gitBuildUserEmail)) - @JsonProperty("git.build.user.email") - @ExcludeMissing fun gitBuildUserEmail(gitBuildUserEmail: JsonField) = apply { this.gitBuildUserEmail = gitBuildUserEmail } @@ -672,8 +719,6 @@ private constructor( fun gitBuildUserName(gitBuildUserName: String) = gitBuildUserName(JsonField.of(gitBuildUserName)) - @JsonProperty("git.build.user.name") - @ExcludeMissing fun gitBuildUserName(gitBuildUserName: JsonField) = apply { this.gitBuildUserName = gitBuildUserName } @@ -681,8 +726,6 @@ private constructor( fun gitBuildVersion(gitBuildVersion: String) = gitBuildVersion(JsonField.of(gitBuildVersion)) - @JsonProperty("git.build.version") - @ExcludeMissing fun gitBuildVersion(gitBuildVersion: JsonField) = apply { this.gitBuildVersion = gitBuildVersion } @@ -690,8 +733,6 @@ private constructor( fun gitClosestTagCommitCount(gitClosestTagCommitCount: String) = gitClosestTagCommitCount(JsonField.of(gitClosestTagCommitCount)) - @JsonProperty("git.closest.tag.commit.count") - @ExcludeMissing fun gitClosestTagCommitCount(gitClosestTagCommitCount: JsonField) = apply { this.gitClosestTagCommitCount = gitClosestTagCommitCount @@ -700,16 +741,12 @@ private constructor( fun gitClosestTagName(gitClosestTagName: String) = gitClosestTagName(JsonField.of(gitClosestTagName)) - @JsonProperty("git.closest.tag.name") - @ExcludeMissing fun gitClosestTagName(gitClosestTagName: JsonField) = apply { this.gitClosestTagName = gitClosestTagName } fun gitCommitId(gitCommitId: String) = gitCommitId(JsonField.of(gitCommitId)) - @JsonProperty("git.commit.id") - @ExcludeMissing fun gitCommitId(gitCommitId: JsonField) = apply { this.gitCommitId = gitCommitId } @@ -717,8 +754,6 @@ private constructor( fun gitCommitIdAbbrev(gitCommitIdAbbrev: String) = gitCommitIdAbbrev(JsonField.of(gitCommitIdAbbrev)) - @JsonProperty("git.commit.id.abbrev") - @ExcludeMissing fun gitCommitIdAbbrev(gitCommitIdAbbrev: JsonField) = apply { this.gitCommitIdAbbrev = gitCommitIdAbbrev } @@ -726,8 +761,6 @@ private constructor( fun gitCommitIdDescribe(gitCommitIdDescribe: String) = gitCommitIdDescribe(JsonField.of(gitCommitIdDescribe)) - @JsonProperty("git.commit.id.describe") - @ExcludeMissing fun gitCommitIdDescribe(gitCommitIdDescribe: JsonField) = apply { this.gitCommitIdDescribe = gitCommitIdDescribe } @@ -735,8 +768,6 @@ private constructor( fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: String) = gitCommitIdDescribeShort(JsonField.of(gitCommitIdDescribeShort)) - @JsonProperty("git.commit.id.describe-short") - @ExcludeMissing fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: JsonField) = apply { this.gitCommitIdDescribeShort = gitCommitIdDescribeShort @@ -745,8 +776,6 @@ private constructor( fun gitCommitMessageFull(gitCommitMessageFull: String) = gitCommitMessageFull(JsonField.of(gitCommitMessageFull)) - @JsonProperty("git.commit.message.full") - @ExcludeMissing fun gitCommitMessageFull(gitCommitMessageFull: JsonField) = apply { this.gitCommitMessageFull = gitCommitMessageFull } @@ -754,8 +783,6 @@ private constructor( fun gitCommitMessageShort(gitCommitMessageShort: String) = gitCommitMessageShort(JsonField.of(gitCommitMessageShort)) - @JsonProperty("git.commit.message.short") - @ExcludeMissing fun gitCommitMessageShort(gitCommitMessageShort: JsonField) = apply { this.gitCommitMessageShort = gitCommitMessageShort } @@ -763,8 +790,6 @@ private constructor( fun gitCommitTime(gitCommitTime: String) = gitCommitTime(JsonField.of(gitCommitTime)) - @JsonProperty("git.commit.time") - @ExcludeMissing fun gitCommitTime(gitCommitTime: JsonField) = apply { this.gitCommitTime = gitCommitTime } @@ -772,8 +797,6 @@ private constructor( fun gitCommitUserEmail(gitCommitUserEmail: String) = gitCommitUserEmail(JsonField.of(gitCommitUserEmail)) - @JsonProperty("git.commit.user.email") - @ExcludeMissing fun gitCommitUserEmail(gitCommitUserEmail: JsonField) = apply { this.gitCommitUserEmail = gitCommitUserEmail } @@ -781,41 +804,32 @@ private constructor( fun gitCommitUserName(gitCommitUserName: String) = gitCommitUserName(JsonField.of(gitCommitUserName)) - @JsonProperty("git.commit.user.name") - @ExcludeMissing fun gitCommitUserName(gitCommitUserName: JsonField) = apply { this.gitCommitUserName = gitCommitUserName } fun gitDirty(gitDirty: String) = gitDirty(JsonField.of(gitDirty)) - @JsonProperty("git.dirty") - @ExcludeMissing fun gitDirty(gitDirty: JsonField) = apply { this.gitDirty = gitDirty } fun gitRemoteOriginUrl(gitRemoteOriginUrl: String) = gitRemoteOriginUrl(JsonField.of(gitRemoteOriginUrl)) - @JsonProperty("git.remote.origin.url") - @ExcludeMissing fun gitRemoteOriginUrl(gitRemoteOriginUrl: JsonField) = apply { this.gitRemoteOriginUrl = gitRemoteOriginUrl } fun gitTags(gitTags: String) = gitTags(JsonField.of(gitTags)) - @JsonProperty("git.tags") - @ExcludeMissing fun gitTags(gitTags: JsonField) = apply { this.gitTags = gitTags } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -823,6 +837,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): GitProperties = GitProperties( gitBranch, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt index 6d03116..b296308 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class CurrentTimeRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt index 1df37ab..cd1538b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = CurrentTimeRetrieveResponse.Builder::class) @NoAutoDetect class CurrentTimeRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): CurrentTimeRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(currentTimeRetrieveResponse: CurrentTimeRetrieveResponse) = apply { - this.code = currentTimeRetrieveResponse.code - this.currentTime = currentTimeRetrieveResponse.currentTime - this.text = currentTimeRetrieveResponse.text - this.version = currentTimeRetrieveResponse.version - this.data = currentTimeRetrieveResponse.data - additionalProperties(currentTimeRetrieveResponse.additionalProperties) + code = currentTimeRetrieveResponse.code + currentTime = currentTimeRetrieveResponse.currentTime + text = currentTimeRetrieveResponse.text + version = currentTimeRetrieveResponse.version + data = currentTimeRetrieveResponse.data + additionalProperties = currentTimeRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): CurrentTimeRetrieveResponse = CurrentTimeRetrieveResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,17 +246,20 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val readableTime: JsonField, - private val time: JsonField, - private val additionalProperties: Map, + @JsonProperty("readableTime") + @ExcludeMissing + private val readableTime: JsonField = JsonMissing.of(), + @JsonProperty("time") + @ExcludeMissing + private val time: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun readableTime(): Optional = Optional.ofNullable(readableTime.getNullable("readableTime")) @@ -264,6 +273,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { readableTime() @@ -287,33 +298,28 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.readableTime = entry.readableTime - this.time = entry.time - additionalProperties(entry.additionalProperties) + readableTime = entry.readableTime + time = entry.time + additionalProperties = entry.additionalProperties.toMutableMap() } fun readableTime(readableTime: String) = readableTime(JsonField.of(readableTime)) - @JsonProperty("readableTime") - @ExcludeMissing fun readableTime(readableTime: JsonField) = apply { this.readableTime = readableTime } fun time(time: Long) = time(JsonField.of(time)) - @JsonProperty("time") - @ExcludeMissing fun time(time: JsonField) = apply { this.time = time } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -321,6 +327,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( readableTime, 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 3c52cf4..5bd60d2 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 @@ -6,7 +6,6 @@ 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.Enum @@ -15,24 +14,35 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable import org.onebusaway.errors.OnebusawaySdkInvalidDataException -@JsonDeserialize(builder = References.Builder::class) @NoAutoDetect class References +@JsonCreator private constructor( - private val agencies: JsonField>, - private val routes: JsonField>, - private val situations: JsonField>, - private val stopTimes: JsonField>, - private val stops: JsonField>, - private val trips: JsonField>, - private val additionalProperties: Map, + @JsonProperty("agencies") + @ExcludeMissing + private val agencies: JsonField> = JsonMissing.of(), + @JsonProperty("routes") + @ExcludeMissing + private val routes: JsonField> = JsonMissing.of(), + @JsonProperty("situations") + @ExcludeMissing + private val situations: JsonField> = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + private val stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("stops") + @ExcludeMissing + private val stops: JsonField> = JsonMissing.of(), + @JsonProperty("trips") + @ExcludeMissing + private val trips: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun agencies(): List = agencies.getRequired("agencies") fun routes(): List = routes.getRequired("routes") @@ -61,6 +71,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): References = apply { if (!validated) { agencies().forEach { it.validate() } @@ -92,67 +104,60 @@ private constructor( @JvmSynthetic internal fun from(references: References) = apply { - this.agencies = references.agencies - this.routes = references.routes - this.situations = references.situations - this.stopTimes = references.stopTimes - this.stops = references.stops - this.trips = references.trips - additionalProperties(references.additionalProperties) + agencies = references.agencies + routes = references.routes + situations = references.situations + stopTimes = references.stopTimes + stops = references.stops + trips = references.trips + additionalProperties = references.additionalProperties.toMutableMap() } fun agencies(agencies: List) = agencies(JsonField.of(agencies)) - @JsonProperty("agencies") - @ExcludeMissing fun agencies(agencies: JsonField>) = apply { this.agencies = agencies } fun routes(routes: List) = routes(JsonField.of(routes)) - @JsonProperty("routes") - @ExcludeMissing fun routes(routes: JsonField>) = apply { this.routes = routes } fun situations(situations: List) = situations(JsonField.of(situations)) - @JsonProperty("situations") - @ExcludeMissing fun situations(situations: JsonField>) = apply { this.situations = situations } fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - @JsonProperty("stopTimes") - @ExcludeMissing fun stopTimes(stopTimes: JsonField>) = apply { this.stopTimes = stopTimes } fun stops(stops: List) = stops(JsonField.of(stops)) - @JsonProperty("stops") - @ExcludeMissing fun stops(stops: JsonField>) = apply { this.stops = stops } fun trips(trips: List) = trips(JsonField.of(trips)) - @JsonProperty("trips") - @ExcludeMissing fun trips(trips: JsonField>) = apply { this.trips = trips } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): References = References( agencies.map { it.toImmutable() }, @@ -165,25 +170,40 @@ private constructor( ) } - @JsonDeserialize(builder = Agency.Builder::class) @NoAutoDetect class Agency + @JsonCreator private constructor( - private val disclaimer: JsonField, - private val email: JsonField, - private val fareUrl: JsonField, - private val id: JsonField, - private val lang: JsonField, - private val name: JsonField, - private val phone: JsonField, - private val privateService: JsonField, - private val timezone: JsonField, - private val url: JsonField, - private val additionalProperties: Map, + @JsonProperty("disclaimer") + @ExcludeMissing + private val disclaimer: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + private val email: JsonField = JsonMissing.of(), + @JsonProperty("fareUrl") + @ExcludeMissing + private val fareUrl: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("lang") + @ExcludeMissing + private val lang: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("phone") + @ExcludeMissing + private val phone: JsonField = JsonMissing.of(), + @JsonProperty("privateService") + @ExcludeMissing + private val privateService: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + private val timezone: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun disclaimer(): Optional = Optional.ofNullable(disclaimer.getNullable("disclaimer")) @@ -230,6 +250,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Agency = apply { if (!validated) { disclaimer() @@ -269,96 +291,81 @@ private constructor( @JvmSynthetic internal fun from(agency: Agency) = apply { - this.disclaimer = agency.disclaimer - this.email = agency.email - this.fareUrl = agency.fareUrl - this.id = agency.id - this.lang = agency.lang - this.name = agency.name - this.phone = agency.phone - this.privateService = agency.privateService - this.timezone = agency.timezone - this.url = agency.url - additionalProperties(agency.additionalProperties) + disclaimer = agency.disclaimer + email = agency.email + fareUrl = agency.fareUrl + id = agency.id + lang = agency.lang + name = agency.name + phone = agency.phone + privateService = agency.privateService + timezone = agency.timezone + url = agency.url + additionalProperties = agency.additionalProperties.toMutableMap() } fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) - @JsonProperty("disclaimer") - @ExcludeMissing fun disclaimer(disclaimer: JsonField) = apply { this.disclaimer = disclaimer } fun email(email: String) = email(JsonField.of(email)) - @JsonProperty("email") - @ExcludeMissing fun email(email: JsonField) = apply { this.email = email } fun fareUrl(fareUrl: String) = fareUrl(JsonField.of(fareUrl)) - @JsonProperty("fareUrl") - @ExcludeMissing fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun lang(lang: String) = lang(JsonField.of(lang)) - @JsonProperty("lang") - @ExcludeMissing fun lang(lang: JsonField) = apply { this.lang = lang } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun phone(phone: String) = phone(JsonField.of(phone)) - @JsonProperty("phone") - @ExcludeMissing fun phone(phone: JsonField) = apply { this.phone = phone } fun privateService(privateService: Boolean) = privateService(JsonField.of(privateService)) - @JsonProperty("privateService") - @ExcludeMissing fun privateService(privateService: JsonField) = apply { this.privateService = privateService } fun timezone(timezone: String) = timezone(JsonField.of(timezone)) - @JsonProperty("timezone") - @ExcludeMissing fun timezone(timezone: JsonField) = apply { this.timezone = timezone } fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Agency = Agency( disclaimer, @@ -393,25 +400,38 @@ private constructor( "Agency{disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, id=$id, lang=$lang, name=$name, phone=$phone, privateService=$privateService, timezone=$timezone, url=$url, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Route.Builder::class) @NoAutoDetect class Route + @JsonCreator private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, + @JsonProperty("agencyId") + @ExcludeMissing + private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + private val longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + private val nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + private val shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + private val textColor: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun agencyId(): String = agencyId.getRequired("agencyId") fun color(): Optional = Optional.ofNullable(color.getNullable("color")) @@ -460,6 +480,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Route = apply { if (!validated) { agencyId() @@ -499,98 +521,83 @@ private constructor( @JvmSynthetic internal fun from(route: Route) = apply { - this.agencyId = route.agencyId - this.color = route.color - this.description = route.description - this.id = route.id - this.longName = route.longName - this.nullSafeShortName = route.nullSafeShortName - this.shortName = route.shortName - this.textColor = route.textColor - this.type = route.type - this.url = route.url - additionalProperties(route.additionalProperties) + agencyId = route.agencyId + color = route.color + description = route.description + id = route.id + longName = route.longName + nullSafeShortName = route.nullSafeShortName + shortName = route.shortName + textColor = route.textColor + type = route.type + url = route.url + additionalProperties = route.additionalProperties.toMutableMap() } fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - @JsonProperty("agencyId") - @ExcludeMissing fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } fun color(color: String) = color(JsonField.of(color)) - @JsonProperty("color") - @ExcludeMissing fun color(color: JsonField) = apply { this.color = color } fun description(description: String) = description(JsonField.of(description)) - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun longName(longName: String) = longName(JsonField.of(longName)) - @JsonProperty("longName") - @ExcludeMissing fun longName(longName: JsonField) = apply { this.longName = longName } fun nullSafeShortName(nullSafeShortName: String) = nullSafeShortName(JsonField.of(nullSafeShortName)) - @JsonProperty("nullSafeShortName") - @ExcludeMissing fun nullSafeShortName(nullSafeShortName: JsonField) = apply { this.nullSafeShortName = nullSafeShortName } fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - @JsonProperty("shortName") - @ExcludeMissing fun shortName(shortName: JsonField) = apply { this.shortName = shortName } fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - @JsonProperty("textColor") - @ExcludeMissing fun textColor(textColor: JsonField) = apply { this.textColor = textColor } fun type(type: Long) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Route = Route( agencyId, @@ -625,27 +632,46 @@ private constructor( "Route{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Situation.Builder::class) @NoAutoDetect class Situation + @JsonCreator private constructor( - private val id: JsonField, - private val creationTime: JsonField, - private val reason: JsonField, - private val summary: JsonField, - private val description: JsonField, - private val url: JsonField, - private val activeWindows: JsonField>, - private val allAffects: JsonField>, - private val consequences: JsonField>, - private val publicationWindows: JsonField>, - private val severity: JsonField, - private val consequenceMessage: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("creationTime") + @ExcludeMissing + private val creationTime: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonProperty("summary") + @ExcludeMissing + private val summary: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonProperty("activeWindows") + @ExcludeMissing + private val activeWindows: JsonField> = JsonMissing.of(), + @JsonProperty("allAffects") + @ExcludeMissing + private val allAffects: JsonField> = JsonMissing.of(), + @JsonProperty("consequences") + @ExcludeMissing + private val consequences: JsonField> = JsonMissing.of(), + @JsonProperty("publicationWindows") + @ExcludeMissing + private val publicationWindows: JsonField> = JsonMissing.of(), + @JsonProperty("severity") + @ExcludeMissing + private val severity: JsonField = JsonMissing.of(), + @JsonProperty("consequenceMessage") + @ExcludeMissing + private val consequenceMessage: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the situation. */ fun id(): String = id.getRequired("id") @@ -718,6 +744,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Situation = apply { if (!validated) { id() @@ -761,35 +789,31 @@ private constructor( @JvmSynthetic internal fun from(situation: Situation) = apply { - this.id = situation.id - this.creationTime = situation.creationTime - this.reason = situation.reason - this.summary = situation.summary - this.description = situation.description - this.url = situation.url - this.activeWindows = situation.activeWindows - this.allAffects = situation.allAffects - this.consequences = situation.consequences - this.publicationWindows = situation.publicationWindows - this.severity = situation.severity - this.consequenceMessage = situation.consequenceMessage - additionalProperties(situation.additionalProperties) + id = situation.id + creationTime = situation.creationTime + reason = situation.reason + summary = situation.summary + description = situation.description + url = situation.url + activeWindows = situation.activeWindows + allAffects = situation.allAffects + consequences = situation.consequences + publicationWindows = situation.publicationWindows + severity = situation.severity + consequenceMessage = situation.consequenceMessage + additionalProperties = situation.additionalProperties.toMutableMap() } /** Unique identifier for the situation. */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the situation. */ - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Unix timestamp of when this situation was created. */ fun creationTime(creationTime: Long) = creationTime(JsonField.of(creationTime)) /** Unix timestamp of when this situation was created. */ - @JsonProperty("creationTime") - @ExcludeMissing fun creationTime(creationTime: JsonField) = apply { this.creationTime = creationTime } @@ -798,43 +822,31 @@ private constructor( fun reason(reason: Reason) = reason(JsonField.of(reason)) /** Reason for the service alert, taken from TPEG codes. */ - @JsonProperty("reason") - @ExcludeMissing fun reason(reason: JsonField) = apply { this.reason = reason } fun summary(summary: Summary) = summary(JsonField.of(summary)) - @JsonProperty("summary") - @ExcludeMissing fun summary(summary: JsonField) = apply { this.summary = summary } fun description(description: Description) = description(JsonField.of(description)) - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } fun url(url: Url) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun activeWindows(activeWindows: List) = activeWindows(JsonField.of(activeWindows)) - @JsonProperty("activeWindows") - @ExcludeMissing fun activeWindows(activeWindows: JsonField>) = apply { this.activeWindows = activeWindows } fun allAffects(allAffects: List) = allAffects(JsonField.of(allAffects)) - @JsonProperty("allAffects") - @ExcludeMissing fun allAffects(allAffects: JsonField>) = apply { this.allAffects = allAffects } @@ -842,8 +854,6 @@ private constructor( fun consequences(consequences: List) = consequences(JsonField.of(consequences)) - @JsonProperty("consequences") - @ExcludeMissing fun consequences(consequences: JsonField>) = apply { this.consequences = consequences } @@ -851,8 +861,6 @@ private constructor( fun publicationWindows(publicationWindows: List) = publicationWindows(JsonField.of(publicationWindows)) - @JsonProperty("publicationWindows") - @ExcludeMissing fun publicationWindows(publicationWindows: JsonField>) = apply { this.publicationWindows = publicationWindows } @@ -861,8 +869,6 @@ private constructor( fun severity(severity: String) = severity(JsonField.of(severity)) /** Severity of the situation. */ - @JsonProperty("severity") - @ExcludeMissing fun severity(severity: JsonField) = apply { this.severity = severity } /** Message regarding the consequence of the situation. */ @@ -870,26 +876,29 @@ private constructor( consequenceMessage(JsonField.of(consequenceMessage)) /** Message regarding the consequence of the situation. */ - @JsonProperty("consequenceMessage") - @ExcludeMissing fun consequenceMessage(consequenceMessage: JsonField) = apply { this.consequenceMessage = consequenceMessage } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Situation = Situation( id, @@ -908,17 +917,18 @@ private constructor( ) } - @JsonDeserialize(builder = ActiveWindow.Builder::class) @NoAutoDetect class ActiveWindow + @JsonCreator private constructor( - private val from: JsonField, - private val to: JsonField, - private val additionalProperties: Map, + @JsonProperty("from") + @ExcludeMissing + private val from: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing private val to: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Start time of the active window as a Unix timestamp. */ fun from(): Optional = Optional.ofNullable(from.getNullable("from")) @@ -935,6 +945,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ActiveWindow = apply { if (!validated) { from() @@ -958,35 +970,30 @@ private constructor( @JvmSynthetic internal fun from(activeWindow: ActiveWindow) = apply { - this.from = activeWindow.from - this.to = activeWindow.to - additionalProperties(activeWindow.additionalProperties) + from = activeWindow.from + to = activeWindow.to + additionalProperties = activeWindow.additionalProperties.toMutableMap() } /** Start time of the active window as a Unix timestamp. */ fun from(from: Long) = from(JsonField.of(from)) /** Start time of the active window as a Unix timestamp. */ - @JsonProperty("from") - @ExcludeMissing fun from(from: JsonField) = apply { this.from = from } /** End time of the active window as a Unix timestamp. */ fun to(to: Long) = to(JsonField.of(to)) /** End time of the active window as a Unix timestamp. */ - @JsonProperty("to") - @ExcludeMissing fun to(to: JsonField) = apply { this.to = to } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -994,6 +1001,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ActiveWindow = ActiveWindow( from, @@ -1020,21 +1035,32 @@ private constructor( "ActiveWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = AllAffect.Builder::class) @NoAutoDetect class AllAffect + @JsonCreator private constructor( - private val agencyId: JsonField, - private val applicationId: JsonField, - private val directionId: JsonField, - private val routeId: JsonField, - private val stopId: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, + @JsonProperty("agencyId") + @ExcludeMissing + private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("applicationId") + @ExcludeMissing + private val applicationId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + private val directionId: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Identifier for the agency. */ fun agencyId(): Optional = Optional.ofNullable(agencyId.getNullable("agencyId")) @@ -1077,6 +1103,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): AllAffect = apply { if (!validated) { agencyId() @@ -1108,21 +1136,19 @@ private constructor( @JvmSynthetic internal fun from(allAffect: AllAffect) = apply { - this.agencyId = allAffect.agencyId - this.applicationId = allAffect.applicationId - this.directionId = allAffect.directionId - this.routeId = allAffect.routeId - this.stopId = allAffect.stopId - this.tripId = allAffect.tripId - additionalProperties(allAffect.additionalProperties) + agencyId = allAffect.agencyId + applicationId = allAffect.applicationId + directionId = allAffect.directionId + routeId = allAffect.routeId + stopId = allAffect.stopId + tripId = allAffect.tripId + additionalProperties = allAffect.additionalProperties.toMutableMap() } /** Identifier for the agency. */ fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) /** Identifier for the agency. */ - @JsonProperty("agencyId") - @ExcludeMissing fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } /** Identifier for the application. */ @@ -1130,8 +1156,6 @@ private constructor( applicationId(JsonField.of(applicationId)) /** Identifier for the application. */ - @JsonProperty("applicationId") - @ExcludeMissing fun applicationId(applicationId: JsonField) = apply { this.applicationId = applicationId } @@ -1140,8 +1164,6 @@ private constructor( fun directionId(directionId: String) = directionId(JsonField.of(directionId)) /** Identifier for the direction. */ - @JsonProperty("directionId") - @ExcludeMissing fun directionId(directionId: JsonField) = apply { this.directionId = directionId } @@ -1150,34 +1172,27 @@ private constructor( fun routeId(routeId: String) = routeId(JsonField.of(routeId)) /** Identifier for the route. */ - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } /** Identifier for the stop. */ fun stopId(stopId: String) = stopId(JsonField.of(stopId)) /** Identifier for the stop. */ - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } /** Identifier for the trip. */ fun tripId(tripId: String) = tripId(JsonField.of(tripId)) /** Identifier for the trip. */ - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1185,6 +1200,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AllAffect = AllAffect( agencyId, @@ -1215,17 +1238,20 @@ private constructor( "AllAffect{agencyId=$agencyId, applicationId=$applicationId, directionId=$directionId, routeId=$routeId, stopId=$stopId, tripId=$tripId, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Consequence.Builder::class) @NoAutoDetect class Consequence + @JsonCreator private constructor( - private val condition: JsonField, - private val conditionDetails: JsonField, - private val additionalProperties: Map, + @JsonProperty("condition") + @ExcludeMissing + private val condition: JsonField = JsonMissing.of(), + @JsonProperty("conditionDetails") + @ExcludeMissing + private val conditionDetails: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Condition of the consequence. */ fun condition(): Optional = Optional.ofNullable(condition.getNullable("condition")) @@ -1244,6 +1270,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Consequence = apply { if (!validated) { condition() @@ -1267,36 +1295,31 @@ private constructor( @JvmSynthetic internal fun from(consequence: Consequence) = apply { - this.condition = consequence.condition - this.conditionDetails = consequence.conditionDetails - additionalProperties(consequence.additionalProperties) + condition = consequence.condition + conditionDetails = consequence.conditionDetails + additionalProperties = consequence.additionalProperties.toMutableMap() } /** Condition of the consequence. */ fun condition(condition: String) = condition(JsonField.of(condition)) /** Condition of the consequence. */ - @JsonProperty("condition") - @ExcludeMissing fun condition(condition: JsonField) = apply { this.condition = condition } fun conditionDetails(conditionDetails: ConditionDetails) = conditionDetails(JsonField.of(conditionDetails)) - @JsonProperty("conditionDetails") - @ExcludeMissing fun conditionDetails(conditionDetails: JsonField) = apply { this.conditionDetails = conditionDetails } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1304,6 +1327,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Consequence = Consequence( condition, @@ -1312,17 +1343,20 @@ private constructor( ) } - @JsonDeserialize(builder = ConditionDetails.Builder::class) @NoAutoDetect class ConditionDetails + @JsonCreator private constructor( - private val diversionPath: JsonField, - private val diversionStopIds: JsonField>, - private val additionalProperties: Map, + @JsonProperty("diversionPath") + @ExcludeMissing + private val diversionPath: JsonField = JsonMissing.of(), + @JsonProperty("diversionStopIds") + @ExcludeMissing + private val diversionStopIds: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun diversionPath(): Optional = Optional.ofNullable(diversionPath.getNullable("diversionPath")) @@ -1339,6 +1373,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ConditionDetails = apply { if (!validated) { diversionPath().map { it.validate() } @@ -1362,16 +1398,14 @@ private constructor( @JvmSynthetic internal fun from(conditionDetails: ConditionDetails) = apply { - this.diversionPath = conditionDetails.diversionPath - this.diversionStopIds = conditionDetails.diversionStopIds - additionalProperties(conditionDetails.additionalProperties) + diversionPath = conditionDetails.diversionPath + diversionStopIds = conditionDetails.diversionStopIds + additionalProperties = conditionDetails.additionalProperties.toMutableMap() } fun diversionPath(diversionPath: DiversionPath) = diversionPath(JsonField.of(diversionPath)) - @JsonProperty("diversionPath") - @ExcludeMissing fun diversionPath(diversionPath: JsonField) = apply { this.diversionPath = diversionPath } @@ -1379,20 +1413,17 @@ private constructor( fun diversionStopIds(diversionStopIds: List) = diversionStopIds(JsonField.of(diversionStopIds)) - @JsonProperty("diversionStopIds") - @ExcludeMissing fun diversionStopIds(diversionStopIds: JsonField>) = apply { this.diversionStopIds = diversionStopIds } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1400,6 +1431,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ConditionDetails = ConditionDetails( diversionPath, @@ -1408,18 +1447,23 @@ private constructor( ) } - @JsonDeserialize(builder = DiversionPath.Builder::class) @NoAutoDetect class DiversionPath + @JsonCreator private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: Map, + @JsonProperty("length") + @ExcludeMissing + private val length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + private val levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + private val points: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Length of the diversion path. */ fun length(): Optional = Optional.ofNullable(length.getNullable("length")) @@ -1444,6 +1488,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): DiversionPath = apply { if (!validated) { length() @@ -1470,51 +1516,52 @@ private constructor( @JvmSynthetic internal fun from(diversionPath: DiversionPath) = apply { - this.length = diversionPath.length - this.levels = diversionPath.levels - this.points = diversionPath.points - additionalProperties(diversionPath.additionalProperties) + length = diversionPath.length + levels = diversionPath.levels + points = diversionPath.points + additionalProperties = diversionPath.additionalProperties.toMutableMap() } /** Length of the diversion path. */ fun length(length: Long) = length(JsonField.of(length)) /** Length of the diversion path. */ - @JsonProperty("length") - @ExcludeMissing fun length(length: JsonField) = apply { this.length = length } /** Levels of the diversion path. */ fun levels(levels: String) = levels(JsonField.of(levels)) /** Levels of the diversion path. */ - @JsonProperty("levels") - @ExcludeMissing fun levels(levels: JsonField) = apply { this.levels = levels } /** Points of the diversion path. */ fun points(points: String) = points(JsonField.of(points)) /** Points of the diversion path. */ - @JsonProperty("points") - @ExcludeMissing fun points(points: JsonField) = apply { this.points = points } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): DiversionPath = DiversionPath( length, @@ -1578,17 +1625,20 @@ private constructor( "Consequence{condition=$condition, conditionDetails=$conditionDetails, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Description.Builder::class) @NoAutoDetect class Description + @JsonCreator private constructor( - private val lang: JsonField, - private val value: JsonField, - private val additionalProperties: Map, + @JsonProperty("lang") + @ExcludeMissing + private val lang: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Language of the description. */ fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) @@ -1605,6 +1655,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Description = apply { if (!validated) { lang() @@ -1628,35 +1680,30 @@ private constructor( @JvmSynthetic internal fun from(description: Description) = apply { - this.lang = description.lang - this.value = description.value - additionalProperties(description.additionalProperties) + lang = description.lang + value = description.value + additionalProperties = description.additionalProperties.toMutableMap() } /** Language of the description. */ fun lang(lang: String) = lang(JsonField.of(lang)) /** Language of the description. */ - @JsonProperty("lang") - @ExcludeMissing fun lang(lang: JsonField) = apply { this.lang = lang } /** Longer description of the situation. */ fun value(value: String) = value(JsonField.of(value)) /** Longer description of the situation. */ - @JsonProperty("value") - @ExcludeMissing fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1664,6 +1711,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Description = Description( lang, @@ -1690,17 +1745,18 @@ private constructor( "Description{lang=$lang, value=$value, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = PublicationWindow.Builder::class) @NoAutoDetect class PublicationWindow + @JsonCreator private constructor( - private val from: JsonField, - private val to: JsonField, - private val additionalProperties: Map, + @JsonProperty("from") + @ExcludeMissing + private val from: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing private val to: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Start time of the time window as a Unix timestamp. */ fun from(): Long = from.getRequired("from") @@ -1717,6 +1773,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): PublicationWindow = apply { if (!validated) { from() @@ -1740,35 +1798,30 @@ private constructor( @JvmSynthetic internal fun from(publicationWindow: PublicationWindow) = apply { - this.from = publicationWindow.from - this.to = publicationWindow.to - additionalProperties(publicationWindow.additionalProperties) + from = publicationWindow.from + to = publicationWindow.to + additionalProperties = publicationWindow.additionalProperties.toMutableMap() } /** Start time of the time window as a Unix timestamp. */ fun from(from: Long) = from(JsonField.of(from)) /** Start time of the time window as a Unix timestamp. */ - @JsonProperty("from") - @ExcludeMissing fun from(from: JsonField) = apply { this.from = from } /** End time of the time window as a Unix timestamp. */ fun to(to: Long) = to(JsonField.of(to)) /** End time of the time window as a Unix timestamp. */ - @JsonProperty("to") - @ExcludeMissing fun to(to: JsonField) = apply { this.to = to } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1776,6 +1829,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PublicationWindow = PublicationWindow( from, @@ -1810,29 +1871,17 @@ private constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Reason && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val EQUIPMENT_REASON = Reason(JsonField.of("equipmentReason")) + @JvmField val EQUIPMENT_REASON = of("equipmentReason") - @JvmField val ENVIRONMENT_REASON = Reason(JsonField.of("environmentReason")) + @JvmField val ENVIRONMENT_REASON = of("environmentReason") - @JvmField val PERSONNEL_REASON = Reason(JsonField.of("personnelReason")) + @JvmField val PERSONNEL_REASON = of("personnelReason") - @JvmField val MISCELLANEOUS_REASON = Reason(JsonField.of("miscellaneousReason")) + @JvmField val MISCELLANEOUS_REASON = of("miscellaneousReason") - @JvmField val SECURITY_ALERT = Reason(JsonField.of("securityAlert")) + @JvmField val SECURITY_ALERT = of("securityAlert") @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) } @@ -1875,19 +1924,34 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Reason && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - @JsonDeserialize(builder = Summary.Builder::class) @NoAutoDetect class Summary + @JsonCreator private constructor( - private val lang: JsonField, - private val value: JsonField, - private val additionalProperties: Map, + @JsonProperty("lang") + @ExcludeMissing + private val lang: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Language of the summary. */ fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) @@ -1904,6 +1968,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Summary = apply { if (!validated) { lang() @@ -1927,35 +1993,30 @@ private constructor( @JvmSynthetic internal fun from(summary: Summary) = apply { - this.lang = summary.lang - this.value = summary.value - additionalProperties(summary.additionalProperties) + lang = summary.lang + value = summary.value + additionalProperties = summary.additionalProperties.toMutableMap() } /** Language of the summary. */ fun lang(lang: String) = lang(JsonField.of(lang)) /** Language of the summary. */ - @JsonProperty("lang") - @ExcludeMissing fun lang(lang: JsonField) = apply { this.lang = lang } /** Short summary of the situation. */ fun value(value: String) = value(JsonField.of(value)) /** Short summary of the situation. */ - @JsonProperty("value") - @ExcludeMissing fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1963,6 +2024,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Summary = Summary( lang, @@ -1989,17 +2058,20 @@ private constructor( "Summary{lang=$lang, value=$value, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Url.Builder::class) @NoAutoDetect class Url + @JsonCreator private constructor( - private val lang: JsonField, - private val value: JsonField, - private val additionalProperties: Map, + @JsonProperty("lang") + @ExcludeMissing + private val lang: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Language of the URL. */ fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) @@ -2016,6 +2088,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Url = apply { if (!validated) { lang() @@ -2039,35 +2113,30 @@ private constructor( @JvmSynthetic internal fun from(url: Url) = apply { - this.lang = url.lang - this.value = url.value - additionalProperties(url.additionalProperties) + lang = url.lang + value = url.value + additionalProperties = url.additionalProperties.toMutableMap() } /** Language of the URL. */ fun lang(lang: String) = lang(JsonField.of(lang)) /** Language of the URL. */ - @JsonProperty("lang") - @ExcludeMissing fun lang(lang: JsonField) = apply { this.lang = lang } /** URL for more information about the situation. */ fun value(value: String) = value(JsonField.of(value)) /** URL for more information about the situation. */ - @JsonProperty("value") - @ExcludeMissing fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2075,6 +2144,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Url = Url( lang, @@ -2119,26 +2196,41 @@ private constructor( "Situation{id=$id, creationTime=$creationTime, reason=$reason, summary=$summary, description=$description, url=$url, activeWindows=$activeWindows, allAffects=$allAffects, consequences=$consequences, publicationWindows=$publicationWindows, severity=$severity, consequenceMessage=$consequenceMessage, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Stop.Builder::class) @NoAutoDetect class Stop + @JsonCreator private constructor( - private val code: JsonField, - private val direction: JsonField, - 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 wheelchairBoarding: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + private val routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + private val wheelchairBoarding: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) @@ -2191,6 +2283,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Stop = apply { if (!validated) { code() @@ -2232,81 +2326,61 @@ private constructor( @JvmSynthetic internal fun from(stop: Stop) = apply { - this.code = stop.code - this.direction = stop.direction - this.id = stop.id - this.lat = stop.lat - this.locationType = stop.locationType - this.lon = stop.lon - this.name = stop.name - this.parent = stop.parent - this.routeIds = stop.routeIds - this.staticRouteIds = stop.staticRouteIds - this.wheelchairBoarding = stop.wheelchairBoarding - additionalProperties(stop.additionalProperties) + code = stop.code + direction = stop.direction + id = stop.id + lat = stop.lat + locationType = stop.locationType + lon = stop.lon + name = stop.name + parent = stop.parent + routeIds = stop.routeIds + staticRouteIds = stop.staticRouteIds + wheelchairBoarding = stop.wheelchairBoarding + additionalProperties = stop.additionalProperties.toMutableMap() } fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun direction(direction: String) = direction(JsonField.of(direction)) - @JsonProperty("direction") - @ExcludeMissing fun direction(direction: JsonField) = apply { this.direction = direction } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun lat(lat: Double) = lat(JsonField.of(lat)) - @JsonProperty("lat") - @ExcludeMissing fun lat(lat: JsonField) = apply { this.lat = lat } fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - @JsonProperty("locationType") - @ExcludeMissing fun locationType(locationType: JsonField) = apply { this.locationType = locationType } fun lon(lon: Double) = lon(JsonField.of(lon)) - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun parent(parent: String) = parent(JsonField.of(parent)) - @JsonProperty("parent") - @ExcludeMissing fun parent(parent: JsonField) = apply { this.parent = parent } fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - @JsonProperty("routeIds") - @ExcludeMissing fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } fun staticRouteIds(staticRouteIds: List) = staticRouteIds(JsonField.of(staticRouteIds)) - @JsonProperty("staticRouteIds") - @ExcludeMissing fun staticRouteIds(staticRouteIds: JsonField>) = apply { this.staticRouteIds = staticRouteIds } @@ -2314,26 +2388,29 @@ private constructor( fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) - @JsonProperty("wheelchairBoarding") - @ExcludeMissing fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { this.wheelchairBoarding = wheelchairBoarding } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Stop = Stop( code, @@ -2369,21 +2446,32 @@ private constructor( "Stop{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = StopTime.Builder::class) @NoAutoDetect class StopTime + @JsonCreator private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, + @JsonProperty("arrivalTime") + @ExcludeMissing + private val arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + private val departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + private val historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arrivalTime(): Optional = Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) @@ -2421,6 +2509,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopTime = apply { if (!validated) { arrivalTime() @@ -2452,25 +2542,21 @@ private constructor( @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() } fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing fun arrivalTime(arrivalTime: JsonField) = apply { this.arrivalTime = arrivalTime } fun departureTime(departureTime: Long) = departureTime(JsonField.of(departureTime)) - @JsonProperty("departureTime") - @ExcludeMissing fun departureTime(departureTime: JsonField) = apply { this.departureTime = departureTime } @@ -2478,8 +2564,6 @@ private constructor( fun distanceAlongTrip(distanceAlongTrip: Double) = distanceAlongTrip(JsonField.of(distanceAlongTrip)) - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -2487,40 +2571,39 @@ private constructor( fun historicalOccupancy(historicalOccupancy: String) = historicalOccupancy(JsonField.of(historicalOccupancy)) - @JsonProperty("historicalOccupancy") - @ExcludeMissing fun historicalOccupancy(historicalOccupancy: JsonField) = apply { this.historicalOccupancy = historicalOccupancy } fun stopHeadsign(stopHeadsign: String) = stopHeadsign(JsonField.of(stopHeadsign)) - @JsonProperty("stopHeadsign") - @ExcludeMissing fun stopHeadsign(stopHeadsign: JsonField) = apply { this.stopHeadsign = stopHeadsign } fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopTime = StopTime( arrivalTime, @@ -2551,26 +2634,45 @@ private constructor( "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Trip.Builder::class) @NoAutoDetect class Trip + @JsonCreator private constructor( - private val blockId: JsonField, - private val directionId: JsonField, - private val id: JsonField, - private val peakOffpeak: JsonField, - private val routeId: JsonField, - private val routeShortName: JsonField, - private val serviceId: JsonField, - private val shapeId: JsonField, - private val timeZone: JsonField, - private val tripHeadsign: JsonField, - private val tripShortName: JsonField, - private val additionalProperties: Map, + @JsonProperty("blockId") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + private val directionId: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("peakOffpeak") + @ExcludeMissing + private val peakOffpeak: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + private val routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), + @JsonProperty("shapeId") + @ExcludeMissing + private val shapeId: JsonField = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + private val timeZone: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripShortName") + @ExcludeMissing + private val tripShortName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) fun directionId(): Optional = @@ -2624,6 +2726,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Trip = apply { if (!validated) { blockId() @@ -2665,109 +2769,92 @@ private constructor( @JvmSynthetic internal fun from(trip: Trip) = apply { - this.blockId = trip.blockId - this.directionId = trip.directionId - this.id = trip.id - this.peakOffpeak = trip.peakOffpeak - this.routeId = trip.routeId - this.routeShortName = trip.routeShortName - this.serviceId = trip.serviceId - this.shapeId = trip.shapeId - this.timeZone = trip.timeZone - this.tripHeadsign = trip.tripHeadsign - this.tripShortName = trip.tripShortName - additionalProperties(trip.additionalProperties) + blockId = trip.blockId + directionId = trip.directionId + id = trip.id + peakOffpeak = trip.peakOffpeak + routeId = trip.routeId + routeShortName = trip.routeShortName + serviceId = trip.serviceId + shapeId = trip.shapeId + timeZone = trip.timeZone + tripHeadsign = trip.tripHeadsign + tripShortName = trip.tripShortName + additionalProperties = trip.additionalProperties.toMutableMap() } fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - @JsonProperty("blockId") - @ExcludeMissing fun blockId(blockId: JsonField) = apply { this.blockId = blockId } fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - @JsonProperty("directionId") - @ExcludeMissing fun directionId(directionId: JsonField) = apply { this.directionId = directionId } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) - @JsonProperty("peakOffpeak") - @ExcludeMissing fun peakOffpeak(peakOffpeak: JsonField) = apply { this.peakOffpeak = peakOffpeak } fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } fun routeShortName(routeShortName: String) = routeShortName(JsonField.of(routeShortName)) - @JsonProperty("routeShortName") - @ExcludeMissing fun routeShortName(routeShortName: JsonField) = apply { this.routeShortName = routeShortName } fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - @JsonProperty("serviceId") - @ExcludeMissing fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) - @JsonProperty("shapeId") - @ExcludeMissing fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - @JsonProperty("timeZone") - @ExcludeMissing fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) - @JsonProperty("tripHeadsign") - @ExcludeMissing fun tripHeadsign(tripHeadsign: JsonField) = apply { this.tripHeadsign = tripHeadsign } fun tripShortName(tripShortName: String) = tripShortName(JsonField.of(tripShortName)) - @JsonProperty("tripShortName") - @ExcludeMissing fun tripShortName(tripShortName: JsonField) = apply { this.tripShortName = tripShortName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Trip = Trip( blockId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt index 01a7a2c..f5ddb96 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt @@ -7,12 +7,10 @@ import java.util.Objects import java.util.Optional import org.onebusaway.core.Enum import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams import org.onebusaway.errors.OnebusawaySdkInvalidDataException -import org.onebusaway.models.* class ReportProblemWithStopRetrieveParams constructor( @@ -237,29 +235,17 @@ constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Code && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val STOP_NAME_WRONG = Code(JsonField.of("stop_name_wrong")) + @JvmField val STOP_NAME_WRONG = of("stop_name_wrong") - @JvmField val STOP_NUMBER_WRONG = Code(JsonField.of("stop_number_wrong")) + @JvmField val STOP_NUMBER_WRONG = of("stop_number_wrong") - @JvmField val STOP_LOCATION_WRONG = Code(JsonField.of("stop_location_wrong")) + @JvmField val STOP_LOCATION_WRONG = of("stop_location_wrong") - @JvmField val ROUTE_OR_TRIP_MISSING = Code(JsonField.of("route_or_trip_missing")) + @JvmField val ROUTE_OR_TRIP_MISSING = of("route_or_trip_missing") - @JvmField val OTHER = Code(JsonField.of("other")) + @JvmField val OTHER = of("other") @JvmStatic fun of(value: String) = Code(JsonField.of(value)) } @@ -302,6 +288,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt index f1a7b2f..961bb1b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt @@ -7,12 +7,10 @@ import java.util.Objects import java.util.Optional import org.onebusaway.core.Enum import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams import org.onebusaway.errors.OnebusawaySdkInvalidDataException -import org.onebusaway.models.* class ReportProblemWithTripRetrieveParams constructor( @@ -289,32 +287,19 @@ constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Code && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val VEHICLE_NEVER_CAME = Code(JsonField.of("vehicle_never_came")) + @JvmField val VEHICLE_NEVER_CAME = of("vehicle_never_came") - @JvmField val VEHICLE_CAME_EARLY = Code(JsonField.of("vehicle_came_early")) + @JvmField val VEHICLE_CAME_EARLY = of("vehicle_came_early") - @JvmField val VEHICLE_CAME_LATE = Code(JsonField.of("vehicle_came_late")) + @JvmField val VEHICLE_CAME_LATE = of("vehicle_came_late") - @JvmField val WRONG_HEADSIGN = Code(JsonField.of("wrong_headsign")) + @JvmField val WRONG_HEADSIGN = of("wrong_headsign") - @JvmField - val VEHICLE_DOES_NOT_STOP_HERE = Code(JsonField.of("vehicle_does_not_stop_here")) + @JvmField val VEHICLE_DOES_NOT_STOP_HERE = of("vehicle_does_not_stop_here") - @JvmField val OTHER = Code(JsonField.of("other")) + @JvmField val OTHER = of("other") @JvmStatic fun of(value: String) = Code(JsonField.of(value)) } @@ -361,6 +346,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { 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 96d774b..eb9ea9a 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 @@ -4,29 +4,32 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = ResponseWrapper.Builder::class) @NoAutoDetect class ResponseWrapper +@JsonCreator private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -47,6 +50,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ResponseWrapper = apply { if (!validated) { code() @@ -74,51 +79,48 @@ private constructor( @JvmSynthetic internal fun from(responseWrapper: ResponseWrapper) = apply { - this.code = responseWrapper.code - this.currentTime = responseWrapper.currentTime - this.text = responseWrapper.text - this.version = responseWrapper.version - additionalProperties(responseWrapper.additionalProperties) + code = responseWrapper.code + currentTime = responseWrapper.currentTime + text = responseWrapper.text + version = responseWrapper.version + additionalProperties = responseWrapper.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ResponseWrapper = ResponseWrapper( code, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt index f9ee685..cdbc57c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class RouteIdsForAgencyListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt index 64d3b4a..d7aa39a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt @@ -4,30 +4,33 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = RouteIdsForAgencyListResponse.Builder::class) @NoAutoDetect class RouteIdsForAgencyListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -38,14 +41,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -60,6 +55,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): RouteIdsForAgencyListResponse = apply { if (!validated) { code() @@ -89,58 +94,53 @@ private constructor( @JvmSynthetic internal fun from(routeIdsForAgencyListResponse: RouteIdsForAgencyListResponse) = apply { - this.code = routeIdsForAgencyListResponse.code - this.currentTime = routeIdsForAgencyListResponse.currentTime - this.text = routeIdsForAgencyListResponse.text - this.version = routeIdsForAgencyListResponse.version - this.data = routeIdsForAgencyListResponse.data - additionalProperties(routeIdsForAgencyListResponse.additionalProperties) + code = routeIdsForAgencyListResponse.code + currentTime = routeIdsForAgencyListResponse.currentTime + text = routeIdsForAgencyListResponse.text + version = routeIdsForAgencyListResponse.version + data = routeIdsForAgencyListResponse.data + additionalProperties = routeIdsForAgencyListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): RouteIdsForAgencyListResponse = RouteIdsForAgencyListResponse( code, @@ -152,18 +152,23 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun list(): List = list.getRequired("list") @@ -180,6 +185,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -205,48 +212,47 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt index c2dd038..54c0374 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class RouteRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt index 22c03a1..5d65b29 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = RouteRetrieveResponse.Builder::class) @NoAutoDetect class RouteRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): RouteRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(routeRetrieveResponse: RouteRetrieveResponse) = apply { - this.code = routeRetrieveResponse.code - this.currentTime = routeRetrieveResponse.currentTime - this.text = routeRetrieveResponse.text - this.version = routeRetrieveResponse.version - this.data = routeRetrieveResponse.data - additionalProperties(routeRetrieveResponse.additionalProperties) + code = routeRetrieveResponse.code + currentTime = routeRetrieveResponse.currentTime + text = routeRetrieveResponse.text + version = routeRetrieveResponse.version + data = routeRetrieveResponse.data + additionalProperties = routeRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): RouteRetrieveResponse = RouteRetrieveResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,25 +246,44 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, + @JsonProperty("agencyId") + @ExcludeMissing + private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + private val longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + private val nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + private val shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + private val textColor: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonProperty("url") + @ExcludeMissing + private val url: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun agencyId(): String = agencyId.getRequired("agencyId") fun color(): Optional = Optional.ofNullable(color.getNullable("color")) @@ -309,6 +334,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { agencyId() @@ -348,92 +375,71 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.agencyId = entry.agencyId - this.color = entry.color - this.description = entry.description - this.id = entry.id - this.longName = entry.longName - this.nullSafeShortName = entry.nullSafeShortName - this.shortName = entry.shortName - this.textColor = entry.textColor - this.type = entry.type - this.url = entry.url - additionalProperties(entry.additionalProperties) + agencyId = entry.agencyId + color = entry.color + description = entry.description + id = entry.id + longName = entry.longName + nullSafeShortName = entry.nullSafeShortName + shortName = entry.shortName + textColor = entry.textColor + type = entry.type + url = entry.url + additionalProperties = entry.additionalProperties.toMutableMap() } fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - @JsonProperty("agencyId") - @ExcludeMissing fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } fun color(color: String) = color(JsonField.of(color)) - @JsonProperty("color") - @ExcludeMissing fun color(color: JsonField) = apply { this.color = color } fun description(description: String) = description(JsonField.of(description)) - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun longName(longName: String) = longName(JsonField.of(longName)) - @JsonProperty("longName") - @ExcludeMissing fun longName(longName: JsonField) = apply { this.longName = longName } fun nullSafeShortName(nullSafeShortName: String) = nullSafeShortName(JsonField.of(nullSafeShortName)) - @JsonProperty("nullSafeShortName") - @ExcludeMissing fun nullSafeShortName(nullSafeShortName: JsonField) = apply { this.nullSafeShortName = nullSafeShortName } fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - @JsonProperty("shortName") - @ExcludeMissing fun shortName(shortName: JsonField) = apply { this.shortName = shortName } fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - @JsonProperty("textColor") - @ExcludeMissing fun textColor(textColor: JsonField) = apply { this.textColor = textColor } fun type(type: Long) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -441,6 +447,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( agencyId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt index daedf1b..288f3ee 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class RoutesForAgencyListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt index 7882c21..c647b28 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = RoutesForAgencyListResponse.Builder::class) @NoAutoDetect class RoutesForAgencyListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): RoutesForAgencyListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(routesForAgencyListResponse: RoutesForAgencyListResponse) = apply { - this.code = routesForAgencyListResponse.code - this.currentTime = routesForAgencyListResponse.currentTime - this.text = routesForAgencyListResponse.text - this.version = routesForAgencyListResponse.version - this.data = routesForAgencyListResponse.data - additionalProperties(routesForAgencyListResponse.additionalProperties) + code = routesForAgencyListResponse.code + currentTime = routesForAgencyListResponse.currentTime + text = routesForAgencyListResponse.text + version = routesForAgencyListResponse.version + data = routesForAgencyListResponse.data + additionalProperties = routesForAgencyListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): RoutesForAgencyListResponse = RoutesForAgencyListResponse( code, @@ -153,18 +153,23 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun list(): kotlin.collections.List = list.getRequired("list") @@ -181,6 +186,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -206,48 +213,47 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -257,25 +263,44 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, + @JsonProperty("agencyId") + @ExcludeMissing + private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + private val longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + private val nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + private val shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + private val textColor: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonProperty("url") + @ExcludeMissing + private val url: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun agencyId(): String = agencyId.getRequired("agencyId") fun color(): Optional = Optional.ofNullable(color.getNullable("color")) @@ -326,6 +351,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { agencyId() @@ -365,92 +392,71 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.agencyId = list.agencyId - this.color = list.color - this.description = list.description - this.id = list.id - this.longName = list.longName - this.nullSafeShortName = list.nullSafeShortName - this.shortName = list.shortName - this.textColor = list.textColor - this.type = list.type - this.url = list.url - additionalProperties(list.additionalProperties) + agencyId = list.agencyId + color = list.color + description = list.description + id = list.id + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + type = list.type + url = list.url + additionalProperties = list.additionalProperties.toMutableMap() } fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - @JsonProperty("agencyId") - @ExcludeMissing fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } fun color(color: String) = color(JsonField.of(color)) - @JsonProperty("color") - @ExcludeMissing fun color(color: JsonField) = apply { this.color = color } fun description(description: String) = description(JsonField.of(description)) - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun longName(longName: String) = longName(JsonField.of(longName)) - @JsonProperty("longName") - @ExcludeMissing fun longName(longName: JsonField) = apply { this.longName = longName } fun nullSafeShortName(nullSafeShortName: String) = nullSafeShortName(JsonField.of(nullSafeShortName)) - @JsonProperty("nullSafeShortName") - @ExcludeMissing fun nullSafeShortName(nullSafeShortName: JsonField) = apply { this.nullSafeShortName = nullSafeShortName } fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - @JsonProperty("shortName") - @ExcludeMissing fun shortName(shortName: JsonField) = apply { this.shortName = shortName } fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - @JsonProperty("textColor") - @ExcludeMissing fun textColor(textColor: JsonField) = apply { this.textColor = textColor } fun type(type: Long) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -458,6 +464,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( agencyId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt index acbc08d..f934535 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class RoutesForLocationListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt index 04ecb1c..3ecf897 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = RoutesForLocationListResponse.Builder::class) @NoAutoDetect class RoutesForLocationListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): RoutesForLocationListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(routesForLocationListResponse: RoutesForLocationListResponse) = apply { - this.code = routesForLocationListResponse.code - this.currentTime = routesForLocationListResponse.currentTime - this.text = routesForLocationListResponse.text - this.version = routesForLocationListResponse.version - this.data = routesForLocationListResponse.data - additionalProperties(routesForLocationListResponse.additionalProperties) + code = routesForLocationListResponse.code + currentTime = routesForLocationListResponse.currentTime + text = routesForLocationListResponse.text + version = routesForLocationListResponse.version + data = routesForLocationListResponse.data + additionalProperties = routesForLocationListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): RoutesForLocationListResponse = RoutesForLocationListResponse( code, @@ -153,19 +153,26 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val outOfRange: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun list(): kotlin.collections.List = list.getRequired("list") @@ -186,6 +193,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -213,55 +222,52 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.outOfRange = data.outOfRange - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + outOfRange = data.outOfRange + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - @JsonProperty("outOfRange") - @ExcludeMissing fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -272,25 +278,44 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, + @JsonProperty("agencyId") + @ExcludeMissing + private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + private val longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + private val nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + private val shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + private val textColor: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonProperty("url") + @ExcludeMissing + private val url: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun agencyId(): String = agencyId.getRequired("agencyId") fun color(): Optional = Optional.ofNullable(color.getNullable("color")) @@ -341,6 +366,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { agencyId() @@ -380,92 +407,71 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.agencyId = list.agencyId - this.color = list.color - this.description = list.description - this.id = list.id - this.longName = list.longName - this.nullSafeShortName = list.nullSafeShortName - this.shortName = list.shortName - this.textColor = list.textColor - this.type = list.type - this.url = list.url - additionalProperties(list.additionalProperties) + agencyId = list.agencyId + color = list.color + description = list.description + id = list.id + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + type = list.type + url = list.url + additionalProperties = list.additionalProperties.toMutableMap() } fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - @JsonProperty("agencyId") - @ExcludeMissing fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } fun color(color: String) = color(JsonField.of(color)) - @JsonProperty("color") - @ExcludeMissing fun color(color: JsonField) = apply { this.color = color } fun description(description: String) = description(JsonField.of(description)) - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun longName(longName: String) = longName(JsonField.of(longName)) - @JsonProperty("longName") - @ExcludeMissing fun longName(longName: JsonField) = apply { this.longName = longName } fun nullSafeShortName(nullSafeShortName: String) = nullSafeShortName(JsonField.of(nullSafeShortName)) - @JsonProperty("nullSafeShortName") - @ExcludeMissing fun nullSafeShortName(nullSafeShortName: JsonField) = apply { this.nullSafeShortName = nullSafeShortName } fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - @JsonProperty("shortName") - @ExcludeMissing fun shortName(shortName: JsonField) = apply { this.shortName = shortName } fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - @JsonProperty("textColor") - @ExcludeMissing fun textColor(textColor: JsonField) = apply { this.textColor = textColor } fun type(type: Long) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -473,6 +479,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( agencyId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt index bb28391..35954aa 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt @@ -8,7 +8,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ScheduleForRouteRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt index 559e125..90e5f08 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = ScheduleForRouteRetrieveResponse.Builder::class) @NoAutoDetect class ScheduleForRouteRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): ScheduleForRouteRetrieveResponse = apply { if (!validated) { code() @@ -91,58 +96,54 @@ private constructor( @JvmSynthetic internal fun from(scheduleForRouteRetrieveResponse: ScheduleForRouteRetrieveResponse) = apply { - this.code = scheduleForRouteRetrieveResponse.code - this.currentTime = scheduleForRouteRetrieveResponse.currentTime - this.text = scheduleForRouteRetrieveResponse.text - this.version = scheduleForRouteRetrieveResponse.version - this.data = scheduleForRouteRetrieveResponse.data - additionalProperties(scheduleForRouteRetrieveResponse.additionalProperties) + code = scheduleForRouteRetrieveResponse.code + currentTime = scheduleForRouteRetrieveResponse.currentTime + text = scheduleForRouteRetrieveResponse.text + version = scheduleForRouteRetrieveResponse.version + data = scheduleForRouteRetrieveResponse.data + additionalProperties = + scheduleForRouteRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ScheduleForRouteRetrieveResponse = ScheduleForRouteRetrieveResponse( code, @@ -154,16 +155,17 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") @JsonProperty("entry") @ExcludeMissing fun _entry() = entry @@ -172,6 +174,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -193,48 +197,62 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - additionalProperties(data.additionalProperties) + entry = data.entry + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data(entry, additionalProperties.toImmutable()) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val routeId: JsonField, - private val scheduleDate: JsonField, - private val serviceIds: JsonField>, - private val stopTripGroupings: JsonField>, - private val stops: JsonField>, - private val trips: JsonField>, - private val additionalProperties: Map, + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDate") + @ExcludeMissing + private val scheduleDate: JsonField = JsonMissing.of(), + @JsonProperty("serviceIds") + @ExcludeMissing + private val serviceIds: JsonField> = JsonMissing.of(), + @JsonProperty("stopTripGroupings") + @ExcludeMissing + private val stopTripGroupings: JsonField> = JsonMissing.of(), + @JsonProperty("stops") + @ExcludeMissing + private val stops: JsonField> = JsonMissing.of(), + @JsonProperty("trips") + @ExcludeMissing + private val trips: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun routeId(): String = routeId.getRequired("routeId") fun scheduleDate(): Long = scheduleDate.getRequired("scheduleDate") @@ -266,6 +284,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { routeId() @@ -297,33 +317,27 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.routeId = entry.routeId - this.scheduleDate = entry.scheduleDate - this.serviceIds = entry.serviceIds - this.stopTripGroupings = entry.stopTripGroupings - this.stops = entry.stops - this.trips = entry.trips - additionalProperties(entry.additionalProperties) + routeId = entry.routeId + scheduleDate = entry.scheduleDate + serviceIds = entry.serviceIds + stopTripGroupings = entry.stopTripGroupings + stops = entry.stops + trips = entry.trips + additionalProperties = entry.additionalProperties.toMutableMap() } fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } fun scheduleDate(scheduleDate: Long) = scheduleDate(JsonField.of(scheduleDate)) - @JsonProperty("scheduleDate") - @ExcludeMissing fun scheduleDate(scheduleDate: JsonField) = apply { this.scheduleDate = scheduleDate } fun serviceIds(serviceIds: List) = serviceIds(JsonField.of(serviceIds)) - @JsonProperty("serviceIds") - @ExcludeMissing fun serviceIds(serviceIds: JsonField>) = apply { this.serviceIds = serviceIds } @@ -331,8 +345,6 @@ private constructor( fun stopTripGroupings(stopTripGroupings: List) = stopTripGroupings(JsonField.of(stopTripGroupings)) - @JsonProperty("stopTripGroupings") - @ExcludeMissing fun stopTripGroupings(stopTripGroupings: JsonField>) = apply { this.stopTripGroupings = stopTripGroupings @@ -340,24 +352,19 @@ private constructor( fun stops(stops: List) = stops(JsonField.of(stops)) - @JsonProperty("stops") - @ExcludeMissing fun stops(stops: JsonField>) = apply { this.stops = stops } fun trips(trips: List) = trips(JsonField.of(trips)) - @JsonProperty("trips") - @ExcludeMissing fun trips(trips: JsonField>) = apply { this.trips = trips } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -365,6 +372,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( routeId, @@ -377,26 +392,47 @@ private constructor( ) } - @JsonDeserialize(builder = Stop.Builder::class) @NoAutoDetect class Stop + @JsonCreator private constructor( - private val code: JsonField, - private val direction: JsonField, - 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 wheelchairBoarding: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + private val routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + private val wheelchairBoarding: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) fun direction(): Optional = @@ -452,6 +488,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Stop = apply { if (!validated) { code() @@ -493,76 +531,58 @@ private constructor( @JvmSynthetic internal fun from(stop: Stop) = apply { - this.code = stop.code - this.direction = stop.direction - this.id = stop.id - this.lat = stop.lat - this.locationType = stop.locationType - this.lon = stop.lon - this.name = stop.name - this.parent = stop.parent - this.routeIds = stop.routeIds - this.staticRouteIds = stop.staticRouteIds - this.wheelchairBoarding = stop.wheelchairBoarding - additionalProperties(stop.additionalProperties) + code = stop.code + direction = stop.direction + id = stop.id + lat = stop.lat + locationType = stop.locationType + lon = stop.lon + name = stop.name + parent = stop.parent + routeIds = stop.routeIds + staticRouteIds = stop.staticRouteIds + wheelchairBoarding = stop.wheelchairBoarding + additionalProperties = stop.additionalProperties.toMutableMap() } fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun direction(direction: String) = direction(JsonField.of(direction)) - @JsonProperty("direction") - @ExcludeMissing fun direction(direction: JsonField) = apply { this.direction = direction } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun lat(lat: Double) = lat(JsonField.of(lat)) - @JsonProperty("lat") - @ExcludeMissing fun lat(lat: JsonField) = apply { this.lat = lat } fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - @JsonProperty("locationType") - @ExcludeMissing fun locationType(locationType: JsonField) = apply { this.locationType = locationType } fun lon(lon: Double) = lon(JsonField.of(lon)) - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun parent(parent: String) = parent(JsonField.of(parent)) - @JsonProperty("parent") - @ExcludeMissing fun parent(parent: JsonField) = apply { this.parent = parent } fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - @JsonProperty("routeIds") - @ExcludeMissing fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } @@ -570,8 +590,6 @@ private constructor( fun staticRouteIds(staticRouteIds: List) = staticRouteIds(JsonField.of(staticRouteIds)) - @JsonProperty("staticRouteIds") - @ExcludeMissing fun staticRouteIds(staticRouteIds: JsonField>) = apply { this.staticRouteIds = staticRouteIds } @@ -579,20 +597,17 @@ private constructor( fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) - @JsonProperty("wheelchairBoarding") - @ExcludeMissing fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { this.wheelchairBoarding = wheelchairBoarding } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -600,6 +615,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Stop = Stop( code, @@ -635,20 +658,30 @@ private constructor( "Stop{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = StopTripGrouping.Builder::class) @NoAutoDetect class StopTripGrouping + @JsonCreator 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: Map, + @JsonProperty("directionId") + @ExcludeMissing + private val directionId: JsonField = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + private val stopIds: JsonField> = JsonMissing.of(), + @JsonProperty("tripHeadsigns") + @ExcludeMissing + private val tripHeadsigns: JsonField> = JsonMissing.of(), + @JsonProperty("tripIds") + @ExcludeMissing + private val tripIds: JsonField> = JsonMissing.of(), + @JsonProperty("tripsWithStopTimes") + @ExcludeMissing + private val tripsWithStopTimes: JsonField> = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun directionId(): String = directionId.getRequired("directionId") fun stopIds(): List = stopIds.getRequired("stopIds") @@ -676,6 +709,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopTripGrouping = apply { if (!validated) { directionId() @@ -706,48 +741,38 @@ private constructor( @JvmSynthetic internal fun from(stopTripGrouping: StopTripGrouping) = apply { - this.directionId = stopTripGrouping.directionId - this.stopIds = stopTripGrouping.stopIds - this.tripHeadsigns = stopTripGrouping.tripHeadsigns - this.tripIds = stopTripGrouping.tripIds - this.tripsWithStopTimes = stopTripGrouping.tripsWithStopTimes - additionalProperties(stopTripGrouping.additionalProperties) + directionId = stopTripGrouping.directionId + stopIds = stopTripGrouping.stopIds + tripHeadsigns = stopTripGrouping.tripHeadsigns + tripIds = stopTripGrouping.tripIds + tripsWithStopTimes = stopTripGrouping.tripsWithStopTimes + additionalProperties = stopTripGrouping.additionalProperties.toMutableMap() } fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - @JsonProperty("directionId") - @ExcludeMissing fun directionId(directionId: JsonField) = apply { this.directionId = directionId } fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - @JsonProperty("stopIds") - @ExcludeMissing fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } fun tripHeadsigns(tripHeadsigns: List) = tripHeadsigns(JsonField.of(tripHeadsigns)) - @JsonProperty("tripHeadsigns") - @ExcludeMissing fun tripHeadsigns(tripHeadsigns: JsonField>) = apply { this.tripHeadsigns = tripHeadsigns } fun tripIds(tripIds: List) = tripIds(JsonField.of(tripIds)) - @JsonProperty("tripIds") - @ExcludeMissing fun tripIds(tripIds: JsonField>) = apply { this.tripIds = tripIds } fun tripsWithStopTimes(tripsWithStopTimes: List) = tripsWithStopTimes(JsonField.of(tripsWithStopTimes)) - @JsonProperty("tripsWithStopTimes") - @ExcludeMissing fun tripsWithStopTimes(tripsWithStopTimes: JsonField>) = apply { this.tripsWithStopTimes = tripsWithStopTimes @@ -755,12 +780,11 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -768,6 +792,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): StopTripGrouping = StopTripGrouping( directionId, @@ -779,17 +811,20 @@ private constructor( ) } - @JsonDeserialize(builder = TripsWithStopTime.Builder::class) @NoAutoDetect class TripsWithStopTime + @JsonCreator private constructor( - private val tripId: JsonField, - private val stopTimes: JsonField>, - private val additionalProperties: Map, + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + private val stopTimes: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun tripId(): String = tripId.getRequired("tripId") fun stopTimes(): List = stopTimes.getRequired("stopTimes") @@ -802,6 +837,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): TripsWithStopTime = apply { if (!validated) { tripId() @@ -826,22 +863,19 @@ private constructor( @JvmSynthetic internal fun from(tripsWithStopTime: TripsWithStopTime) = apply { - this.tripId = tripsWithStopTime.tripId - this.stopTimes = tripsWithStopTime.stopTimes - additionalProperties(tripsWithStopTime.additionalProperties) + tripId = tripsWithStopTime.tripId + stopTimes = tripsWithStopTime.stopTimes + additionalProperties = + tripsWithStopTime.additionalProperties.toMutableMap() } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - @JsonProperty("stopTimes") - @ExcludeMissing fun stopTimes(stopTimes: JsonField>) = apply { this.stopTimes = stopTimes } @@ -849,18 +883,25 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): TripsWithStopTime = TripsWithStopTime( tripId, @@ -869,23 +910,39 @@ private constructor( ) } - @JsonDeserialize(builder = StopTime.Builder::class) @NoAutoDetect class StopTime + @JsonCreator private constructor( - private val arrivalEnabled: JsonField, - private val arrivalTime: JsonField, - private val departureEnabled: JsonField, - private val departureTime: JsonField, - private val serviceId: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, + @JsonProperty("arrivalEnabled") + @ExcludeMissing + private val arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("arrivalTime") + @ExcludeMissing + private val arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + private val departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + private val departureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") @@ -935,6 +992,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopTime = apply { if (!validated) { arrivalEnabled() @@ -971,22 +1030,20 @@ private constructor( @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - this.arrivalEnabled = stopTime.arrivalEnabled - this.arrivalTime = stopTime.arrivalTime - this.departureEnabled = stopTime.departureEnabled - this.departureTime = stopTime.departureTime - this.serviceId = stopTime.serviceId - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - this.tripId = stopTime.tripId - additionalProperties(stopTime.additionalProperties) + arrivalEnabled = stopTime.arrivalEnabled + arrivalTime = stopTime.arrivalTime + departureEnabled = stopTime.departureEnabled + departureTime = stopTime.departureTime + serviceId = stopTime.serviceId + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + tripId = stopTime.tripId + additionalProperties = stopTime.additionalProperties.toMutableMap() } fun arrivalEnabled(arrivalEnabled: Boolean) = arrivalEnabled(JsonField.of(arrivalEnabled)) - @JsonProperty("arrivalEnabled") - @ExcludeMissing fun arrivalEnabled(arrivalEnabled: JsonField) = apply { this.arrivalEnabled = arrivalEnabled } @@ -994,8 +1051,6 @@ private constructor( fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing fun arrivalTime(arrivalTime: JsonField) = apply { this.arrivalTime = arrivalTime } @@ -1003,8 +1058,6 @@ private constructor( fun departureEnabled(departureEnabled: Boolean) = departureEnabled(JsonField.of(departureEnabled)) - @JsonProperty("departureEnabled") - @ExcludeMissing fun departureEnabled(departureEnabled: JsonField) = apply { this.departureEnabled = departureEnabled } @@ -1012,16 +1065,12 @@ private constructor( fun departureTime(departureTime: Long) = departureTime(JsonField.of(departureTime)) - @JsonProperty("departureTime") - @ExcludeMissing fun departureTime(departureTime: JsonField) = apply { this.departureTime = departureTime } fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - @JsonProperty("serviceId") - @ExcludeMissing fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } @@ -1029,39 +1078,40 @@ private constructor( fun stopHeadsign(stopHeadsign: String) = stopHeadsign(JsonField.of(stopHeadsign)) - @JsonProperty("stopHeadsign") - @ExcludeMissing fun stopHeadsign(stopHeadsign: JsonField) = apply { this.stopHeadsign = stopHeadsign } fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopTime = StopTime( arrivalEnabled, @@ -1130,26 +1180,47 @@ private constructor( "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Trip.Builder::class) @NoAutoDetect class Trip + @JsonCreator private constructor( - private val blockId: JsonField, - private val directionId: JsonField, - private val id: JsonField, - private val peakOffpeak: JsonField, - private val routeId: JsonField, - private val routeShortName: JsonField, - private val serviceId: JsonField, - private val shapeId: JsonField, - private val timeZone: JsonField, - private val tripHeadsign: JsonField, - private val tripShortName: JsonField, - private val additionalProperties: Map, + @JsonProperty("blockId") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + private val directionId: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("peakOffpeak") + @ExcludeMissing + private val peakOffpeak: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + private val routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), + @JsonProperty("shapeId") + @ExcludeMissing + private val shapeId: JsonField = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + private val timeZone: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripShortName") + @ExcludeMissing + private val tripShortName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) @@ -1208,6 +1279,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Trip = apply { if (!validated) { blockId() @@ -1249,88 +1322,68 @@ private constructor( @JvmSynthetic internal fun from(trip: Trip) = apply { - this.blockId = trip.blockId - this.directionId = trip.directionId - this.id = trip.id - this.peakOffpeak = trip.peakOffpeak - this.routeId = trip.routeId - this.routeShortName = trip.routeShortName - this.serviceId = trip.serviceId - this.shapeId = trip.shapeId - this.timeZone = trip.timeZone - this.tripHeadsign = trip.tripHeadsign - this.tripShortName = trip.tripShortName - additionalProperties(trip.additionalProperties) + blockId = trip.blockId + directionId = trip.directionId + id = trip.id + peakOffpeak = trip.peakOffpeak + routeId = trip.routeId + routeShortName = trip.routeShortName + serviceId = trip.serviceId + shapeId = trip.shapeId + timeZone = trip.timeZone + tripHeadsign = trip.tripHeadsign + tripShortName = trip.tripShortName + additionalProperties = trip.additionalProperties.toMutableMap() } fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - @JsonProperty("blockId") - @ExcludeMissing fun blockId(blockId: JsonField) = apply { this.blockId = blockId } fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - @JsonProperty("directionId") - @ExcludeMissing fun directionId(directionId: JsonField) = apply { this.directionId = directionId } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) - @JsonProperty("peakOffpeak") - @ExcludeMissing fun peakOffpeak(peakOffpeak: JsonField) = apply { this.peakOffpeak = peakOffpeak } fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } fun routeShortName(routeShortName: String) = routeShortName(JsonField.of(routeShortName)) - @JsonProperty("routeShortName") - @ExcludeMissing fun routeShortName(routeShortName: JsonField) = apply { this.routeShortName = routeShortName } fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - @JsonProperty("serviceId") - @ExcludeMissing fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) - @JsonProperty("shapeId") - @ExcludeMissing fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - @JsonProperty("timeZone") - @ExcludeMissing fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) - @JsonProperty("tripHeadsign") - @ExcludeMissing fun tripHeadsign(tripHeadsign: JsonField) = apply { this.tripHeadsign = tripHeadsign } @@ -1338,20 +1391,17 @@ private constructor( fun tripShortName(tripShortName: String) = tripShortName(JsonField.of(tripShortName)) - @JsonProperty("tripShortName") - @ExcludeMissing fun tripShortName(tripShortName: JsonField) = apply { this.tripShortName = tripShortName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1359,6 +1409,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Trip = Trip( blockId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt index 23621ec..cb6f935 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt @@ -8,7 +8,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ScheduleForStopRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt index 7063b94..307813a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = ScheduleForStopRetrieveResponse.Builder::class) @NoAutoDetect class ScheduleForStopRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): ScheduleForStopRetrieveResponse = apply { if (!validated) { code() @@ -91,58 +96,54 @@ private constructor( @JvmSynthetic internal fun from(scheduleForStopRetrieveResponse: ScheduleForStopRetrieveResponse) = apply { - this.code = scheduleForStopRetrieveResponse.code - this.currentTime = scheduleForStopRetrieveResponse.currentTime - this.text = scheduleForStopRetrieveResponse.text - this.version = scheduleForStopRetrieveResponse.version - this.data = scheduleForStopRetrieveResponse.data - additionalProperties(scheduleForStopRetrieveResponse.additionalProperties) + code = scheduleForStopRetrieveResponse.code + currentTime = scheduleForStopRetrieveResponse.currentTime + text = scheduleForStopRetrieveResponse.text + version = scheduleForStopRetrieveResponse.version + data = scheduleForStopRetrieveResponse.data + additionalProperties = + scheduleForStopRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ScheduleForStopRetrieveResponse = ScheduleForStopRetrieveResponse( code, @@ -154,17 +155,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -177,6 +181,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -200,39 +206,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -241,18 +248,23 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val date: JsonField, - private val stopId: JsonField, - private val stopRouteSchedules: JsonField>, - private val additionalProperties: Map, + @JsonProperty("date") + @ExcludeMissing + private val date: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopRouteSchedules") + @ExcludeMissing + private val stopRouteSchedules: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun date(): Long = date.getRequired("date") fun stopId(): String = stopId.getRequired("stopId") @@ -272,6 +284,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { date() @@ -298,29 +312,23 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.date = entry.date - this.stopId = entry.stopId - this.stopRouteSchedules = entry.stopRouteSchedules - additionalProperties(entry.additionalProperties) + date = entry.date + stopId = entry.stopId + stopRouteSchedules = entry.stopRouteSchedules + additionalProperties = entry.additionalProperties.toMutableMap() } fun date(date: Long) = date(JsonField.of(date)) - @JsonProperty("date") - @ExcludeMissing fun date(date: JsonField) = apply { this.date = date } fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } fun stopRouteSchedules(stopRouteSchedules: List) = stopRouteSchedules(JsonField.of(stopRouteSchedules)) - @JsonProperty("stopRouteSchedules") - @ExcludeMissing fun stopRouteSchedules(stopRouteSchedules: JsonField>) = apply { this.stopRouteSchedules = stopRouteSchedules @@ -328,12 +336,11 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -341,6 +348,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( date, @@ -350,18 +365,22 @@ private constructor( ) } - @JsonDeserialize(builder = StopRouteSchedule.Builder::class) @NoAutoDetect class StopRouteSchedule + @JsonCreator private constructor( - private val routeId: JsonField, + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopRouteDirectionSchedules") + @ExcludeMissing private val stopRouteDirectionSchedules: - JsonField>, - private val additionalProperties: Map, + JsonField> = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun routeId(): String = routeId.getRequired("routeId") fun stopRouteDirectionSchedules(): List = @@ -377,6 +396,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopRouteSchedule = apply { if (!validated) { routeId() @@ -402,36 +423,30 @@ private constructor( @JvmSynthetic internal fun from(stopRouteSchedule: StopRouteSchedule) = apply { - this.routeId = stopRouteSchedule.routeId - this.stopRouteDirectionSchedules = - stopRouteSchedule.stopRouteDirectionSchedules - additionalProperties(stopRouteSchedule.additionalProperties) + routeId = stopRouteSchedule.routeId + stopRouteDirectionSchedules = stopRouteSchedule.stopRouteDirectionSchedules + additionalProperties = stopRouteSchedule.additionalProperties.toMutableMap() } fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } fun stopRouteDirectionSchedules( stopRouteDirectionSchedules: List ) = stopRouteDirectionSchedules(JsonField.of(stopRouteDirectionSchedules)) - @JsonProperty("stopRouteDirectionSchedules") - @ExcludeMissing fun stopRouteDirectionSchedules( stopRouteDirectionSchedules: JsonField> ) = apply { this.stopRouteDirectionSchedules = stopRouteDirectionSchedules } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -439,6 +454,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): StopRouteSchedule = StopRouteSchedule( routeId, @@ -447,18 +470,25 @@ private constructor( ) } - @JsonDeserialize(builder = StopRouteDirectionSchedule.Builder::class) @NoAutoDetect class StopRouteDirectionSchedule + @JsonCreator private constructor( - private val scheduleFrequencies: JsonField>, - private val scheduleStopTimes: JsonField>, - private val tripHeadsign: JsonField, - private val additionalProperties: Map, + @JsonProperty("scheduleFrequencies") + @ExcludeMissing + private val scheduleFrequencies: JsonField> = + JsonMissing.of(), + @JsonProperty("scheduleStopTimes") + @ExcludeMissing + private val scheduleStopTimes: JsonField> = + JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun scheduleFrequencies(): Optional> = Optional.ofNullable(scheduleFrequencies.getNullable("scheduleFrequencies")) @@ -481,6 +511,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopRouteDirectionSchedule = apply { if (!validated) { scheduleFrequencies().map { it.forEach { it.validate() } } @@ -510,21 +542,16 @@ private constructor( @JvmSynthetic internal fun from(stopRouteDirectionSchedule: StopRouteDirectionSchedule) = apply { - this.scheduleFrequencies = - stopRouteDirectionSchedule.scheduleFrequencies - this.scheduleStopTimes = - stopRouteDirectionSchedule.scheduleStopTimes - this.tripHeadsign = stopRouteDirectionSchedule.tripHeadsign - additionalProperties( - stopRouteDirectionSchedule.additionalProperties - ) + scheduleFrequencies = stopRouteDirectionSchedule.scheduleFrequencies + scheduleStopTimes = stopRouteDirectionSchedule.scheduleStopTimes + tripHeadsign = stopRouteDirectionSchedule.tripHeadsign + additionalProperties = + stopRouteDirectionSchedule.additionalProperties.toMutableMap() } fun scheduleFrequencies(scheduleFrequencies: List) = scheduleFrequencies(JsonField.of(scheduleFrequencies)) - @JsonProperty("scheduleFrequencies") - @ExcludeMissing fun scheduleFrequencies( scheduleFrequencies: JsonField> ) = apply { this.scheduleFrequencies = scheduleFrequencies } @@ -532,8 +559,6 @@ private constructor( fun scheduleStopTimes(scheduleStopTimes: List) = scheduleStopTimes(JsonField.of(scheduleStopTimes)) - @JsonProperty("scheduleStopTimes") - @ExcludeMissing fun scheduleStopTimes( scheduleStopTimes: JsonField> ) = apply { this.scheduleStopTimes = scheduleStopTimes } @@ -541,8 +566,6 @@ private constructor( fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) - @JsonProperty("tripHeadsign") - @ExcludeMissing fun tripHeadsign(tripHeadsign: JsonField) = apply { this.tripHeadsign = tripHeadsign } @@ -550,18 +573,25 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopRouteDirectionSchedule = StopRouteDirectionSchedule( scheduleFrequencies.map { it.toImmutable() }, @@ -571,22 +601,36 @@ private constructor( ) } - @JsonDeserialize(builder = ScheduleStopTime.Builder::class) @NoAutoDetect class ScheduleStopTime + @JsonCreator private constructor( - private val arrivalEnabled: JsonField, - private val arrivalTime: JsonField, - private val departureEnabled: JsonField, - private val departureTime: JsonField, - private val serviceId: JsonField, - private val stopHeadsign: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, + @JsonProperty("arrivalEnabled") + @ExcludeMissing + private val arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("arrivalTime") + @ExcludeMissing + private val arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + private val departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + private val departureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") @@ -631,6 +675,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ScheduleStopTime = apply { if (!validated) { arrivalEnabled() @@ -665,21 +711,20 @@ private constructor( @JvmSynthetic internal fun from(scheduleStopTime: ScheduleStopTime) = apply { - this.arrivalEnabled = scheduleStopTime.arrivalEnabled - this.arrivalTime = scheduleStopTime.arrivalTime - this.departureEnabled = scheduleStopTime.departureEnabled - this.departureTime = scheduleStopTime.departureTime - this.serviceId = scheduleStopTime.serviceId - this.stopHeadsign = scheduleStopTime.stopHeadsign - this.tripId = scheduleStopTime.tripId - additionalProperties(scheduleStopTime.additionalProperties) + arrivalEnabled = scheduleStopTime.arrivalEnabled + arrivalTime = scheduleStopTime.arrivalTime + departureEnabled = scheduleStopTime.departureEnabled + departureTime = scheduleStopTime.departureTime + serviceId = scheduleStopTime.serviceId + stopHeadsign = scheduleStopTime.stopHeadsign + tripId = scheduleStopTime.tripId + additionalProperties = + scheduleStopTime.additionalProperties.toMutableMap() } fun arrivalEnabled(arrivalEnabled: Boolean) = arrivalEnabled(JsonField.of(arrivalEnabled)) - @JsonProperty("arrivalEnabled") - @ExcludeMissing fun arrivalEnabled(arrivalEnabled: JsonField) = apply { this.arrivalEnabled = arrivalEnabled } @@ -687,8 +732,6 @@ private constructor( fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing fun arrivalTime(arrivalTime: JsonField) = apply { this.arrivalTime = arrivalTime } @@ -696,8 +739,6 @@ private constructor( fun departureEnabled(departureEnabled: Boolean) = departureEnabled(JsonField.of(departureEnabled)) - @JsonProperty("departureEnabled") - @ExcludeMissing fun departureEnabled(departureEnabled: JsonField) = apply { this.departureEnabled = departureEnabled } @@ -705,16 +746,12 @@ private constructor( fun departureTime(departureTime: Long) = departureTime(JsonField.of(departureTime)) - @JsonProperty("departureTime") - @ExcludeMissing fun departureTime(departureTime: JsonField) = apply { this.departureTime = departureTime } fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - @JsonProperty("serviceId") - @ExcludeMissing fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } @@ -722,33 +759,36 @@ private constructor( fun stopHeadsign(stopHeadsign: String) = stopHeadsign(JsonField.of(stopHeadsign)) - @JsonProperty("stopHeadsign") - @ExcludeMissing fun stopHeadsign(stopHeadsign: JsonField) = apply { this.stopHeadsign = stopHeadsign } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ScheduleStopTime = ScheduleStopTime( arrivalEnabled, @@ -780,21 +820,33 @@ private constructor( "ScheduleStopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, stopHeadsign=$stopHeadsign, tripId=$tripId, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = ScheduleFrequency.Builder::class) @NoAutoDetect class ScheduleFrequency + @JsonCreator private constructor( - private val serviceDate: JsonField, - private val startTime: JsonField, - private val endTime: JsonField, - private val headway: JsonField, - private val serviceId: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("startTime") + @ExcludeMissing + private val startTime: JsonField = JsonMissing.of(), + @JsonProperty("endTime") + @ExcludeMissing + private val endTime: JsonField = JsonMissing.of(), + @JsonProperty("headway") + @ExcludeMissing + private val headway: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") fun startTime(): Long = startTime.getRequired("startTime") @@ -825,6 +877,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ScheduleFrequency = apply { if (!validated) { serviceDate() @@ -857,73 +911,69 @@ private constructor( @JvmSynthetic internal fun from(scheduleFrequency: ScheduleFrequency) = apply { - this.serviceDate = scheduleFrequency.serviceDate - this.startTime = scheduleFrequency.startTime - this.endTime = scheduleFrequency.endTime - this.headway = scheduleFrequency.headway - this.serviceId = scheduleFrequency.serviceId - this.tripId = scheduleFrequency.tripId - additionalProperties(scheduleFrequency.additionalProperties) + serviceDate = scheduleFrequency.serviceDate + startTime = scheduleFrequency.startTime + endTime = scheduleFrequency.endTime + headway = scheduleFrequency.headway + serviceId = scheduleFrequency.serviceId + tripId = scheduleFrequency.tripId + additionalProperties = + scheduleFrequency.additionalProperties.toMutableMap() } fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } fun startTime(startTime: Long) = startTime(JsonField.of(startTime)) - @JsonProperty("startTime") - @ExcludeMissing fun startTime(startTime: JsonField) = apply { this.startTime = startTime } fun endTime(endTime: Long) = endTime(JsonField.of(endTime)) - @JsonProperty("endTime") - @ExcludeMissing fun endTime(endTime: JsonField) = apply { this.endTime = endTime } fun headway(headway: Long) = headway(JsonField.of(headway)) - @JsonProperty("headway") - @ExcludeMissing fun headway(headway: JsonField) = apply { this.headway = headway } fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - @JsonProperty("serviceId") - @ExcludeMissing fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ScheduleFrequency = ScheduleFrequency( serviceDate, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt index 54fbeb1..02347a2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class SearchForRouteListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt index 3c11e1a..c845a37 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = SearchForRouteListResponse.Builder::class) @NoAutoDetect class SearchForRouteListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): SearchForRouteListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(searchForRouteListResponse: SearchForRouteListResponse) = apply { - this.code = searchForRouteListResponse.code - this.currentTime = searchForRouteListResponse.currentTime - this.text = searchForRouteListResponse.text - this.version = searchForRouteListResponse.version - this.data = searchForRouteListResponse.data - additionalProperties(searchForRouteListResponse.additionalProperties) + code = searchForRouteListResponse.code + currentTime = searchForRouteListResponse.currentTime + text = searchForRouteListResponse.text + version = searchForRouteListResponse.version + data = searchForRouteListResponse.data + additionalProperties = searchForRouteListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): SearchForRouteListResponse = SearchForRouteListResponse( code, @@ -153,19 +153,26 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val outOfRange: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun list(): kotlin.collections.List = list.getRequired("list") @@ -186,6 +193,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -213,55 +222,52 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.outOfRange = data.outOfRange - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + outOfRange = data.outOfRange + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - @JsonProperty("outOfRange") - @ExcludeMissing fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -272,25 +278,44 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val agencyId: JsonField, - private val color: JsonField, - private val description: JsonField, - private val id: JsonField, - private val longName: JsonField, - private val nullSafeShortName: JsonField, - private val shortName: JsonField, - private val textColor: JsonField, - private val type: JsonField, - private val url: JsonField, - private val additionalProperties: Map, + @JsonProperty("agencyId") + @ExcludeMissing + private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + private val longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + private val nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + private val shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + private val textColor: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonProperty("url") + @ExcludeMissing + private val url: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun agencyId(): String = agencyId.getRequired("agencyId") fun color(): Optional = Optional.ofNullable(color.getNullable("color")) @@ -341,6 +366,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { agencyId() @@ -380,92 +407,71 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.agencyId = list.agencyId - this.color = list.color - this.description = list.description - this.id = list.id - this.longName = list.longName - this.nullSafeShortName = list.nullSafeShortName - this.shortName = list.shortName - this.textColor = list.textColor - this.type = list.type - this.url = list.url - additionalProperties(list.additionalProperties) + agencyId = list.agencyId + color = list.color + description = list.description + id = list.id + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + type = list.type + url = list.url + additionalProperties = list.additionalProperties.toMutableMap() } fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - @JsonProperty("agencyId") - @ExcludeMissing fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } fun color(color: String) = color(JsonField.of(color)) - @JsonProperty("color") - @ExcludeMissing fun color(color: JsonField) = apply { this.color = color } fun description(description: String) = description(JsonField.of(description)) - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun longName(longName: String) = longName(JsonField.of(longName)) - @JsonProperty("longName") - @ExcludeMissing fun longName(longName: JsonField) = apply { this.longName = longName } fun nullSafeShortName(nullSafeShortName: String) = nullSafeShortName(JsonField.of(nullSafeShortName)) - @JsonProperty("nullSafeShortName") - @ExcludeMissing fun nullSafeShortName(nullSafeShortName: JsonField) = apply { this.nullSafeShortName = nullSafeShortName } fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - @JsonProperty("shortName") - @ExcludeMissing fun shortName(shortName: JsonField) = apply { this.shortName = shortName } fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - @JsonProperty("textColor") - @ExcludeMissing fun textColor(textColor: JsonField) = apply { this.textColor = textColor } fun type(type: Long) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -473,6 +479,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( agencyId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt index 01ef1e8..55a6e79 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class SearchForStopListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt index 7c1e4d9..eb341ad 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = SearchForStopListResponse.Builder::class) @NoAutoDetect class SearchForStopListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): SearchForStopListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(searchForStopListResponse: SearchForStopListResponse) = apply { - this.code = searchForStopListResponse.code - this.currentTime = searchForStopListResponse.currentTime - this.text = searchForStopListResponse.text - this.version = searchForStopListResponse.version - this.data = searchForStopListResponse.data - additionalProperties(searchForStopListResponse.additionalProperties) + code = searchForStopListResponse.code + currentTime = searchForStopListResponse.currentTime + text = searchForStopListResponse.text + version = searchForStopListResponse.version + data = searchForStopListResponse.data + additionalProperties = searchForStopListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): SearchForStopListResponse = SearchForStopListResponse( code, @@ -153,19 +153,26 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val outOfRange: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun list(): kotlin.collections.List = list.getRequired("list") @@ -186,6 +193,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -213,55 +222,52 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.outOfRange = data.outOfRange - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + outOfRange = data.outOfRange + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - @JsonProperty("outOfRange") - @ExcludeMissing fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -272,26 +278,48 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val code: JsonField, - private val direction: JsonField, - 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 wheelchairBoarding: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + private val routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + private val staticRouteIds: JsonField> = + JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + private val wheelchairBoarding: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) fun direction(): Optional = @@ -346,6 +374,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { code() @@ -388,75 +418,57 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.code = list.code - this.direction = list.direction - this.id = list.id - this.lat = list.lat - this.locationType = list.locationType - this.lon = list.lon - this.name = list.name - this.parent = list.parent - this.routeIds = list.routeIds - this.staticRouteIds = list.staticRouteIds - this.wheelchairBoarding = list.wheelchairBoarding - additionalProperties(list.additionalProperties) + code = list.code + direction = list.direction + id = list.id + lat = list.lat + locationType = list.locationType + lon = list.lon + name = list.name + parent = list.parent + routeIds = list.routeIds + staticRouteIds = list.staticRouteIds + wheelchairBoarding = list.wheelchairBoarding + additionalProperties = list.additionalProperties.toMutableMap() } fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun direction(direction: String) = direction(JsonField.of(direction)) - @JsonProperty("direction") - @ExcludeMissing fun direction(direction: JsonField) = apply { this.direction = direction } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun lat(lat: Double) = lat(JsonField.of(lat)) - @JsonProperty("lat") - @ExcludeMissing fun lat(lat: JsonField) = apply { this.lat = lat } fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - @JsonProperty("locationType") - @ExcludeMissing fun locationType(locationType: JsonField) = apply { this.locationType = locationType } fun lon(lon: Double) = lon(JsonField.of(lon)) - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun parent(parent: String) = parent(JsonField.of(parent)) - @JsonProperty("parent") - @ExcludeMissing fun parent(parent: JsonField) = apply { this.parent = parent } fun routeIds(routeIds: kotlin.collections.List) = routeIds(JsonField.of(routeIds)) - @JsonProperty("routeIds") - @ExcludeMissing fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } @@ -464,8 +476,6 @@ private constructor( fun staticRouteIds(staticRouteIds: kotlin.collections.List) = staticRouteIds(JsonField.of(staticRouteIds)) - @JsonProperty("staticRouteIds") - @ExcludeMissing fun staticRouteIds(staticRouteIds: JsonField>) = apply { this.staticRouteIds = staticRouteIds @@ -474,20 +484,17 @@ private constructor( fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) - @JsonProperty("wheelchairBoarding") - @ExcludeMissing fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { this.wheelchairBoarding = wheelchairBoarding } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -495,6 +502,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( code, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt index 016a724..d484d52 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ShapeRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt index 24a8043..cb95187 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = ShapeRetrieveResponse.Builder::class) @NoAutoDetect class ShapeRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): ShapeRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(shapeRetrieveResponse: ShapeRetrieveResponse) = apply { - this.code = shapeRetrieveResponse.code - this.currentTime = shapeRetrieveResponse.currentTime - this.text = shapeRetrieveResponse.text - this.version = shapeRetrieveResponse.version - this.data = shapeRetrieveResponse.data - additionalProperties(shapeRetrieveResponse.additionalProperties) + code = shapeRetrieveResponse.code + currentTime = shapeRetrieveResponse.currentTime + text = shapeRetrieveResponse.text + version = shapeRetrieveResponse.version + data = shapeRetrieveResponse.data + additionalProperties = shapeRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): ShapeRetrieveResponse = ShapeRetrieveResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,18 +246,23 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: Map, + @JsonProperty("length") + @ExcludeMissing + private val length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + private val levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + private val points: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun length(): Long = length.getRequired("length") fun levels(): Optional = Optional.ofNullable(levels.getNullable("levels")) @@ -270,6 +281,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { length() @@ -295,40 +308,33 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.length = entry.length - this.levels = entry.levels - this.points = entry.points - additionalProperties(entry.additionalProperties) + length = entry.length + levels = entry.levels + points = entry.points + additionalProperties = entry.additionalProperties.toMutableMap() } fun length(length: Long) = length(JsonField.of(length)) - @JsonProperty("length") - @ExcludeMissing fun length(length: JsonField) = apply { this.length = length } fun levels(levels: String) = levels(JsonField.of(levels)) - @JsonProperty("levels") - @ExcludeMissing fun levels(levels: JsonField) = apply { this.levels = levels } /** Encoded polyline format representing the shape of the path */ fun points(points: String) = points(JsonField.of(points)) /** Encoded polyline format representing the shape of the path */ - @JsonProperty("points") - @ExcludeMissing fun points(points: JsonField) = apply { this.points = points } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -336,6 +342,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( length, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt index 04075b1..5ed4d90 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class StopIdsForAgencyListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt index b95cb63..47ff328 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt @@ -4,30 +4,33 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = StopIdsForAgencyListResponse.Builder::class) @NoAutoDetect class StopIdsForAgencyListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -38,14 +41,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -60,6 +55,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): StopIdsForAgencyListResponse = apply { if (!validated) { code() @@ -89,58 +94,53 @@ private constructor( @JvmSynthetic internal fun from(stopIdsForAgencyListResponse: StopIdsForAgencyListResponse) = apply { - this.code = stopIdsForAgencyListResponse.code - this.currentTime = stopIdsForAgencyListResponse.currentTime - this.text = stopIdsForAgencyListResponse.text - this.version = stopIdsForAgencyListResponse.version - this.data = stopIdsForAgencyListResponse.data - additionalProperties(stopIdsForAgencyListResponse.additionalProperties) + code = stopIdsForAgencyListResponse.code + currentTime = stopIdsForAgencyListResponse.currentTime + text = stopIdsForAgencyListResponse.text + version = stopIdsForAgencyListResponse.version + data = stopIdsForAgencyListResponse.data + additionalProperties = stopIdsForAgencyListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopIdsForAgencyListResponse = StopIdsForAgencyListResponse( code, @@ -152,18 +152,23 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun list(): List = list.getRequired("list") @@ -180,6 +185,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -205,48 +212,47 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt index 867a165..1b46e7b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class StopRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt index e81fb01..0888b1b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = StopRetrieveResponse.Builder::class) @NoAutoDetect class StopRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): StopRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(stopRetrieveResponse: StopRetrieveResponse) = apply { - this.code = stopRetrieveResponse.code - this.currentTime = stopRetrieveResponse.currentTime - this.text = stopRetrieveResponse.text - this.version = stopRetrieveResponse.version - this.data = stopRetrieveResponse.data - additionalProperties(stopRetrieveResponse.additionalProperties) + code = stopRetrieveResponse.code + currentTime = stopRetrieveResponse.currentTime + text = stopRetrieveResponse.text + version = stopRetrieveResponse.version + data = stopRetrieveResponse.data + additionalProperties = stopRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopRetrieveResponse = StopRetrieveResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,26 +246,47 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val code: JsonField, - private val direction: JsonField, - 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 wheelchairBoarding: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + private val routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + private val wheelchairBoarding: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) fun direction(): Optional = @@ -313,6 +340,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { code() @@ -354,81 +383,61 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.code = entry.code - this.direction = entry.direction - this.id = entry.id - this.lat = entry.lat - this.locationType = entry.locationType - this.lon = entry.lon - this.name = entry.name - this.parent = entry.parent - this.routeIds = entry.routeIds - this.staticRouteIds = entry.staticRouteIds - this.wheelchairBoarding = entry.wheelchairBoarding - additionalProperties(entry.additionalProperties) + code = entry.code + direction = entry.direction + id = entry.id + lat = entry.lat + locationType = entry.locationType + lon = entry.lon + name = entry.name + parent = entry.parent + routeIds = entry.routeIds + staticRouteIds = entry.staticRouteIds + wheelchairBoarding = entry.wheelchairBoarding + additionalProperties = entry.additionalProperties.toMutableMap() } fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun direction(direction: String) = direction(JsonField.of(direction)) - @JsonProperty("direction") - @ExcludeMissing fun direction(direction: JsonField) = apply { this.direction = direction } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun lat(lat: Double) = lat(JsonField.of(lat)) - @JsonProperty("lat") - @ExcludeMissing fun lat(lat: JsonField) = apply { this.lat = lat } fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - @JsonProperty("locationType") - @ExcludeMissing fun locationType(locationType: JsonField) = apply { this.locationType = locationType } fun lon(lon: Double) = lon(JsonField.of(lon)) - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun parent(parent: String) = parent(JsonField.of(parent)) - @JsonProperty("parent") - @ExcludeMissing fun parent(parent: JsonField) = apply { this.parent = parent } fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - @JsonProperty("routeIds") - @ExcludeMissing fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } fun staticRouteIds(staticRouteIds: List) = staticRouteIds(JsonField.of(staticRouteIds)) - @JsonProperty("staticRouteIds") - @ExcludeMissing fun staticRouteIds(staticRouteIds: JsonField>) = apply { this.staticRouteIds = staticRouteIds } @@ -436,20 +445,17 @@ private constructor( fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) - @JsonProperty("wheelchairBoarding") - @ExcludeMissing fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { this.wheelchairBoarding = wheelchairBoarding } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -457,6 +463,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( code, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt index 58b9f04..aa654da 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class StopsForAgencyListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt index ff40515..b3e2c4e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,25 +13,36 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = StopsForAgencyListResponse.Builder::class) @NoAutoDetect class StopsForAgencyListResponse +@JsonCreator private constructor( - private val code: JsonField, - private val currentTime: JsonField, - private val text: JsonField, - private val version: JsonField, - private val limitExceeded: JsonField, - private val outOfRange: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -48,14 +59,6 @@ private constructor( fun references(): References = references.getRequired("references") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -76,6 +79,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): StopsForAgencyListResponse = apply { if (!validated) { code() @@ -111,81 +124,70 @@ private constructor( @JvmSynthetic internal fun from(stopsForAgencyListResponse: StopsForAgencyListResponse) = apply { - this.code = stopsForAgencyListResponse.code - this.currentTime = stopsForAgencyListResponse.currentTime - this.text = stopsForAgencyListResponse.text - this.version = stopsForAgencyListResponse.version - this.limitExceeded = stopsForAgencyListResponse.limitExceeded - this.outOfRange = stopsForAgencyListResponse.outOfRange - this.list = stopsForAgencyListResponse.list - this.references = stopsForAgencyListResponse.references - additionalProperties(stopsForAgencyListResponse.additionalProperties) + code = stopsForAgencyListResponse.code + currentTime = stopsForAgencyListResponse.currentTime + text = stopsForAgencyListResponse.text + version = stopsForAgencyListResponse.version + limitExceeded = stopsForAgencyListResponse.limitExceeded + outOfRange = stopsForAgencyListResponse.outOfRange + list = stopsForAgencyListResponse.list + references = stopsForAgencyListResponse.references + additionalProperties = stopsForAgencyListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - @JsonProperty("outOfRange") - @ExcludeMissing fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopsForAgencyListResponse = StopsForAgencyListResponse( code, @@ -200,26 +202,41 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val code: JsonField, - private val direction: JsonField, - 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 wheelchairBoarding: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + private val routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + private val wheelchairBoarding: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) @@ -273,6 +290,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { code() @@ -315,75 +334,57 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.code = list.code - this.direction = list.direction - this.id = list.id - this.lat = list.lat - this.locationType = list.locationType - this.lon = list.lon - this.name = list.name - this.parent = list.parent - this.routeIds = list.routeIds - this.staticRouteIds = list.staticRouteIds - this.wheelchairBoarding = list.wheelchairBoarding - additionalProperties(list.additionalProperties) + code = list.code + direction = list.direction + id = list.id + lat = list.lat + locationType = list.locationType + lon = list.lon + name = list.name + parent = list.parent + routeIds = list.routeIds + staticRouteIds = list.staticRouteIds + wheelchairBoarding = list.wheelchairBoarding + additionalProperties = list.additionalProperties.toMutableMap() } fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun direction(direction: String) = direction(JsonField.of(direction)) - @JsonProperty("direction") - @ExcludeMissing fun direction(direction: JsonField) = apply { this.direction = direction } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun lat(lat: Double) = lat(JsonField.of(lat)) - @JsonProperty("lat") - @ExcludeMissing fun lat(lat: JsonField) = apply { this.lat = lat } fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - @JsonProperty("locationType") - @ExcludeMissing fun locationType(locationType: JsonField) = apply { this.locationType = locationType } fun lon(lon: Double) = lon(JsonField.of(lon)) - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun parent(parent: String) = parent(JsonField.of(parent)) - @JsonProperty("parent") - @ExcludeMissing fun parent(parent: JsonField) = apply { this.parent = parent } fun routeIds(routeIds: kotlin.collections.List) = routeIds(JsonField.of(routeIds)) - @JsonProperty("routeIds") - @ExcludeMissing fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } @@ -391,8 +392,6 @@ private constructor( fun staticRouteIds(staticRouteIds: kotlin.collections.List) = staticRouteIds(JsonField.of(staticRouteIds)) - @JsonProperty("staticRouteIds") - @ExcludeMissing fun staticRouteIds(staticRouteIds: JsonField>) = apply { this.staticRouteIds = staticRouteIds } @@ -400,26 +399,29 @@ private constructor( fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) - @JsonProperty("wheelchairBoarding") - @ExcludeMissing fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { this.wheelchairBoarding = wheelchairBoarding } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): List = List( code, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt index ff70a36..7b09c87 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class StopsForLocationListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt index ea1dd8f..e1efeed 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = StopsForLocationListResponse.Builder::class) @NoAutoDetect class StopsForLocationListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): StopsForLocationListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(stopsForLocationListResponse: StopsForLocationListResponse) = apply { - this.code = stopsForLocationListResponse.code - this.currentTime = stopsForLocationListResponse.currentTime - this.text = stopsForLocationListResponse.text - this.version = stopsForLocationListResponse.version - this.data = stopsForLocationListResponse.data - additionalProperties(stopsForLocationListResponse.additionalProperties) + code = stopsForLocationListResponse.code + currentTime = stopsForLocationListResponse.currentTime + text = stopsForLocationListResponse.text + version = stopsForLocationListResponse.version + data = stopsForLocationListResponse.data + additionalProperties = stopsForLocationListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopsForLocationListResponse = StopsForLocationListResponse( code, @@ -153,19 +153,26 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val outOfRange: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun outOfRange(): Optional = @@ -187,6 +194,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -214,55 +223,52 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.outOfRange = data.outOfRange - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + outOfRange = data.outOfRange + list = data.list + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - @JsonProperty("outOfRange") - @ExcludeMissing fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -273,26 +279,48 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val code: JsonField, - private val direction: JsonField, - 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 wheelchairBoarding: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + private val routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + private val staticRouteIds: JsonField> = + JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + private val wheelchairBoarding: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) fun direction(): Optional = @@ -347,6 +375,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { code() @@ -389,75 +419,57 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.code = list.code - this.direction = list.direction - this.id = list.id - this.lat = list.lat - this.locationType = list.locationType - this.lon = list.lon - this.name = list.name - this.parent = list.parent - this.routeIds = list.routeIds - this.staticRouteIds = list.staticRouteIds - this.wheelchairBoarding = list.wheelchairBoarding - additionalProperties(list.additionalProperties) + code = list.code + direction = list.direction + id = list.id + lat = list.lat + locationType = list.locationType + lon = list.lon + name = list.name + parent = list.parent + routeIds = list.routeIds + staticRouteIds = list.staticRouteIds + wheelchairBoarding = list.wheelchairBoarding + additionalProperties = list.additionalProperties.toMutableMap() } fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun direction(direction: String) = direction(JsonField.of(direction)) - @JsonProperty("direction") - @ExcludeMissing fun direction(direction: JsonField) = apply { this.direction = direction } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun lat(lat: Double) = lat(JsonField.of(lat)) - @JsonProperty("lat") - @ExcludeMissing fun lat(lat: JsonField) = apply { this.lat = lat } fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - @JsonProperty("locationType") - @ExcludeMissing fun locationType(locationType: JsonField) = apply { this.locationType = locationType } fun lon(lon: Double) = lon(JsonField.of(lon)) - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun parent(parent: String) = parent(JsonField.of(parent)) - @JsonProperty("parent") - @ExcludeMissing fun parent(parent: JsonField) = apply { this.parent = parent } fun routeIds(routeIds: kotlin.collections.List) = routeIds(JsonField.of(routeIds)) - @JsonProperty("routeIds") - @ExcludeMissing fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } @@ -465,8 +477,6 @@ private constructor( fun staticRouteIds(staticRouteIds: kotlin.collections.List) = staticRouteIds(JsonField.of(staticRouteIds)) - @JsonProperty("staticRouteIds") - @ExcludeMissing fun staticRouteIds(staticRouteIds: JsonField>) = apply { this.staticRouteIds = staticRouteIds @@ -475,20 +485,17 @@ private constructor( fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) - @JsonProperty("wheelchairBoarding") - @ExcludeMissing fun wheelchairBoarding(wheelchairBoarding: JsonField) = apply { this.wheelchairBoarding = wheelchairBoarding } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -496,6 +503,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( code, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt index a81b36f..4f2998a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class StopsForRouteListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt index 8089ee4..e42c0f0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = StopsForRouteListResponse.Builder::class) @NoAutoDetect class StopsForRouteListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): StopsForRouteListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(stopsForRouteListResponse: StopsForRouteListResponse) = apply { - this.code = stopsForRouteListResponse.code - this.currentTime = stopsForRouteListResponse.currentTime - this.text = stopsForRouteListResponse.text - this.version = stopsForRouteListResponse.version - this.data = stopsForRouteListResponse.data - additionalProperties(stopsForRouteListResponse.additionalProperties) + code = stopsForRouteListResponse.code + currentTime = stopsForRouteListResponse.currentTime + text = stopsForRouteListResponse.text + version = stopsForRouteListResponse.version + data = stopsForRouteListResponse.data + additionalProperties = stopsForRouteListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopsForRouteListResponse = StopsForRouteListResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,19 +246,26 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val polylines: JsonField>, - private val routeId: JsonField, - private val stopGroupings: JsonField>, - private val stopIds: JsonField>, - private val additionalProperties: Map, + @JsonProperty("polylines") + @ExcludeMissing + private val polylines: JsonField> = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopGroupings") + @ExcludeMissing + private val stopGroupings: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + private val stopIds: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun polylines(): Optional> = Optional.ofNullable(polylines.getNullable("polylines")) @@ -276,6 +289,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { polylines().map { it.forEach { it.validate() } } @@ -303,50 +318,41 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.polylines = entry.polylines - this.routeId = entry.routeId - this.stopGroupings = entry.stopGroupings - this.stopIds = entry.stopIds - additionalProperties(entry.additionalProperties) + polylines = entry.polylines + routeId = entry.routeId + stopGroupings = entry.stopGroupings + stopIds = entry.stopIds + additionalProperties = entry.additionalProperties.toMutableMap() } fun polylines(polylines: List) = polylines(JsonField.of(polylines)) - @JsonProperty("polylines") - @ExcludeMissing fun polylines(polylines: JsonField>) = apply { this.polylines = polylines } fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } fun stopGroupings(stopGroupings: List) = stopGroupings(JsonField.of(stopGroupings)) - @JsonProperty("stopGroupings") - @ExcludeMissing fun stopGroupings(stopGroupings: JsonField>) = apply { this.stopGroupings = stopGroupings } fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - @JsonProperty("stopIds") - @ExcludeMissing fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -354,6 +360,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( polylines.map { it.toImmutable() }, @@ -364,18 +378,23 @@ private constructor( ) } - @JsonDeserialize(builder = Polyline.Builder::class) @NoAutoDetect class Polyline + @JsonCreator private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: Map, + @JsonProperty("length") + @ExcludeMissing + private val length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + private val levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + private val points: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun length(): Optional = Optional.ofNullable(length.getNullable("length")) fun levels(): Optional = Optional.ofNullable(levels.getNullable("levels")) @@ -392,6 +411,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Polyline = apply { if (!validated) { length() @@ -417,38 +438,31 @@ private constructor( @JvmSynthetic internal fun from(polyline: Polyline) = apply { - this.length = polyline.length - this.levels = polyline.levels - this.points = polyline.points - additionalProperties(polyline.additionalProperties) + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() } fun length(length: Long) = length(JsonField.of(length)) - @JsonProperty("length") - @ExcludeMissing fun length(length: JsonField) = apply { this.length = length } fun levels(levels: String) = levels(JsonField.of(levels)) - @JsonProperty("levels") - @ExcludeMissing fun levels(levels: JsonField) = apply { this.levels = levels } fun points(points: String) = points(JsonField.of(points)) - @JsonProperty("points") - @ExcludeMissing fun points(points: JsonField) = apply { this.points = points } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -456,6 +470,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Polyline = Polyline( length, @@ -483,19 +505,26 @@ private constructor( "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = StopGrouping.Builder::class) @NoAutoDetect class StopGrouping + @JsonCreator private constructor( - private val id: JsonField, - private val name: JsonField, - private val polylines: JsonField>, - private val stopIds: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("polylines") + @ExcludeMissing + private val polylines: JsonField> = JsonMissing.of(), + @JsonProperty("stopIds") + @ExcludeMissing + private val stopIds: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -518,6 +547,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopGrouping = apply { if (!validated) { id() @@ -545,47 +576,38 @@ private constructor( @JvmSynthetic internal fun from(stopGrouping: StopGrouping) = apply { - this.id = stopGrouping.id - this.name = stopGrouping.name - this.polylines = stopGrouping.polylines - this.stopIds = stopGrouping.stopIds - additionalProperties(stopGrouping.additionalProperties) + id = stopGrouping.id + name = stopGrouping.name + polylines = stopGrouping.polylines + stopIds = stopGrouping.stopIds + additionalProperties = stopGrouping.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun name(name: Name) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun polylines(polylines: List) = polylines(JsonField.of(polylines)) - @JsonProperty("polylines") - @ExcludeMissing fun polylines(polylines: JsonField>) = apply { this.polylines = polylines } fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - @JsonProperty("stopIds") - @ExcludeMissing fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -593,6 +615,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): StopGrouping = StopGrouping( id, @@ -603,18 +633,23 @@ private constructor( ) } - @JsonDeserialize(builder = Name.Builder::class) @NoAutoDetect class Name + @JsonCreator private constructor( - private val name: JsonField, - private val names: JsonField>, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("names") + @ExcludeMissing + private val names: JsonField> = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) fun names(): Optional> = @@ -632,6 +667,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Name = apply { if (!validated) { name() @@ -659,44 +696,45 @@ private constructor( @JvmSynthetic internal fun from(name: Name) = apply { this.name = name.name - this.names = name.names - this.type = name.type - additionalProperties(name.additionalProperties) + names = name.names + type = name.type + additionalProperties = name.additionalProperties.toMutableMap() } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun names(names: List) = names(JsonField.of(names)) - @JsonProperty("names") - @ExcludeMissing fun names(names: JsonField>) = apply { this.names = names } fun type(type: String) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Name = Name( name, @@ -724,18 +762,23 @@ private constructor( "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Polyline.Builder::class) @NoAutoDetect class Polyline + @JsonCreator private constructor( - private val length: JsonField, - private val levels: JsonField, - private val points: JsonField, - private val additionalProperties: Map, + @JsonProperty("length") + @ExcludeMissing + private val length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + private val levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + private val points: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun length(): Optional = Optional.ofNullable(length.getNullable("length")) fun levels(): Optional = @@ -754,6 +797,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Polyline = apply { if (!validated) { length() @@ -780,45 +825,46 @@ private constructor( @JvmSynthetic internal fun from(polyline: Polyline) = apply { - this.length = polyline.length - this.levels = polyline.levels - this.points = polyline.points - additionalProperties(polyline.additionalProperties) + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() } fun length(length: Long) = length(JsonField.of(length)) - @JsonProperty("length") - @ExcludeMissing fun length(length: JsonField) = apply { this.length = length } fun levels(levels: String) = levels(JsonField.of(levels)) - @JsonProperty("levels") - @ExcludeMissing fun levels(levels: JsonField) = apply { this.levels = levels } fun points(points: String) = points(JsonField.of(points)) - @JsonProperty("points") - @ExcludeMissing fun points(points: JsonField) = apply { this.points = points } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Polyline = Polyline( length, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt index d054387..4c7c3e3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripDetailRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt index 4ac12ff..4ffb4c1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = TripDetailRetrieveResponse.Builder::class) @NoAutoDetect class TripDetailRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): TripDetailRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(tripDetailRetrieveResponse: TripDetailRetrieveResponse) = apply { - this.code = tripDetailRetrieveResponse.code - this.currentTime = tripDetailRetrieveResponse.currentTime - this.text = tripDetailRetrieveResponse.text - this.version = tripDetailRetrieveResponse.version - this.data = tripDetailRetrieveResponse.data - additionalProperties(tripDetailRetrieveResponse.additionalProperties) + code = tripDetailRetrieveResponse.code + currentTime = tripDetailRetrieveResponse.currentTime + text = tripDetailRetrieveResponse.text + version = tripDetailRetrieveResponse.version + data = tripDetailRetrieveResponse.data + additionalProperties = tripDetailRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): TripDetailRetrieveResponse = TripDetailRetrieveResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,21 +246,32 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val frequency: JsonField, - private val schedule: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + private val schedule: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -287,6 +304,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { frequency() @@ -318,31 +337,25 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.frequency = entry.frequency - this.schedule = entry.schedule - this.serviceDate = entry.serviceDate - this.situationIds = entry.situationIds - this.status = entry.status - this.tripId = entry.tripId - additionalProperties(entry.additionalProperties) + frequency = entry.frequency + schedule = entry.schedule + serviceDate = entry.serviceDate + situationIds = entry.situationIds + status = entry.status + tripId = entry.tripId + additionalProperties = entry.additionalProperties.toMutableMap() } fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - @JsonProperty("schedule") - @ExcludeMissing fun schedule(schedule: JsonField) = apply { this.schedule = schedule } fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -350,32 +363,25 @@ private constructor( fun situationIds(situationIds: List) = situationIds(JsonField.of(situationIds)) - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } fun status(status: Status) = status(JsonField.of(status)) - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -383,6 +389,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( frequency, @@ -395,20 +409,29 @@ private constructor( ) } - @JsonDeserialize(builder = Schedule.Builder::class) @NoAutoDetect class Schedule + @JsonCreator private constructor( - private val frequency: JsonField, - private val nextTripId: JsonField, - private val previousTripId: JsonField, - private val stopTimes: JsonField>, - private val timeZone: JsonField, - private val additionalProperties: Map, + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("nextTripId") + @ExcludeMissing + private val nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + private val previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + private val stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + private val timeZone: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -436,6 +459,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Schedule = apply { if (!validated) { frequency() @@ -465,26 +490,22 @@ private constructor( @JvmSynthetic internal fun from(schedule: Schedule) = apply { - this.frequency = schedule.frequency - this.nextTripId = schedule.nextTripId - this.previousTripId = schedule.previousTripId - this.stopTimes = schedule.stopTimes - this.timeZone = schedule.timeZone - additionalProperties(schedule.additionalProperties) + frequency = schedule.frequency + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes + timeZone = schedule.timeZone + additionalProperties = schedule.additionalProperties.toMutableMap() } fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - @JsonProperty("nextTripId") - @ExcludeMissing fun nextTripId(nextTripId: JsonField) = apply { this.nextTripId = nextTripId } @@ -492,34 +513,27 @@ private constructor( fun previousTripId(previousTripId: String) = previousTripId(JsonField.of(previousTripId)) - @JsonProperty("previousTripId") - @ExcludeMissing fun previousTripId(previousTripId: JsonField) = apply { this.previousTripId = previousTripId } fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - @JsonProperty("stopTimes") - @ExcludeMissing fun stopTimes(stopTimes: JsonField>) = apply { this.stopTimes = stopTimes } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - @JsonProperty("timeZone") - @ExcludeMissing fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -527,6 +541,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Schedule = Schedule( frequency, @@ -538,21 +560,32 @@ private constructor( ) } - @JsonDeserialize(builder = StopTime.Builder::class) @NoAutoDetect class StopTime + @JsonCreator private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, + @JsonProperty("arrivalTime") + @ExcludeMissing + private val arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + private val departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + private val historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arrivalTime(): Optional = Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) @@ -593,6 +626,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopTime = apply { if (!validated) { arrivalTime() @@ -625,19 +660,17 @@ private constructor( @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() } fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing fun arrivalTime(arrivalTime: JsonField) = apply { this.arrivalTime = arrivalTime } @@ -645,8 +678,6 @@ private constructor( fun departureTime(departureTime: Long) = departureTime(JsonField.of(departureTime)) - @JsonProperty("departureTime") - @ExcludeMissing fun departureTime(departureTime: JsonField) = apply { this.departureTime = departureTime } @@ -654,8 +685,6 @@ private constructor( fun distanceAlongTrip(distanceAlongTrip: Double) = distanceAlongTrip(JsonField.of(distanceAlongTrip)) - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -663,8 +692,6 @@ private constructor( fun historicalOccupancy(historicalOccupancy: String) = historicalOccupancy(JsonField.of(historicalOccupancy)) - @JsonProperty("historicalOccupancy") - @ExcludeMissing fun historicalOccupancy(historicalOccupancy: JsonField) = apply { this.historicalOccupancy = historicalOccupancy } @@ -672,33 +699,36 @@ private constructor( fun stopHeadsign(stopHeadsign: String) = stopHeadsign(JsonField.of(stopHeadsign)) - @JsonProperty("stopHeadsign") - @ExcludeMissing fun stopHeadsign(stopHeadsign: JsonField) = apply { this.stopHeadsign = stopHeadsign } fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopTime = StopTime( arrivalTime, @@ -747,42 +777,95 @@ private constructor( "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Status.Builder::class) @NoAutoDetect class Status + @JsonCreator private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("activeTripId") + @ExcludeMissing + private val activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + private val closestStop: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + private val occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + private val occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + private val scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Trip ID of the trip the vehicle is actively serving. */ fun activeTripId(): String = activeTripId.getRequired("activeTripId") @@ -1037,6 +1120,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Status = apply { if (!validated) { activeTripId() @@ -1110,34 +1195,34 @@ private constructor( @JvmSynthetic internal fun from(status: Status) = apply { - this.activeTripId = status.activeTripId - this.blockTripSequence = status.blockTripSequence - this.closestStop = status.closestStop - this.closestStopTimeOffset = status.closestStopTimeOffset - this.distanceAlongTrip = status.distanceAlongTrip - this.frequency = status.frequency - this.lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - this.lastKnownLocation = status.lastKnownLocation - this.lastKnownOrientation = status.lastKnownOrientation - this.lastLocationUpdateTime = status.lastLocationUpdateTime - this.lastUpdateTime = status.lastUpdateTime - this.nextStop = status.nextStop - this.nextStopTimeOffset = status.nextStopTimeOffset - this.occupancyCapacity = status.occupancyCapacity - this.occupancyCount = status.occupancyCount - this.occupancyStatus = status.occupancyStatus - this.orientation = status.orientation - this.phase = status.phase - this.position = status.position - this.predicted = status.predicted - this.scheduleDeviation = status.scheduleDeviation - this.scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - this.serviceDate = status.serviceDate - this.situationIds = status.situationIds + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + closestStopTimeOffset = status.closestStopTimeOffset + distanceAlongTrip = status.distanceAlongTrip + frequency = status.frequency + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + orientation = status.orientation + phase = status.phase + position = status.position + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + serviceDate = status.serviceDate + situationIds = status.situationIds this.status = status.status - this.totalDistanceAlongTrip = status.totalDistanceAlongTrip - this.vehicleId = status.vehicleId - additionalProperties(status.additionalProperties) + totalDistanceAlongTrip = status.totalDistanceAlongTrip + vehicleId = status.vehicleId + additionalProperties = status.additionalProperties.toMutableMap() } /** Trip ID of the trip the vehicle is actively serving. */ @@ -1145,8 +1230,6 @@ private constructor( activeTripId(JsonField.of(activeTripId)) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing fun activeTripId(activeTripId: JsonField) = apply { this.activeTripId = activeTripId } @@ -1156,8 +1239,6 @@ private constructor( blockTripSequence(JsonField.of(blockTripSequence)) /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -1166,8 +1247,6 @@ private constructor( fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing fun closestStop(closestStop: JsonField) = apply { this.closestStop = closestStop } @@ -1183,8 +1262,6 @@ private constructor( * Time offset from the closest stop to the current position of the transit * vehicle (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { this.closestStopTimeOffset = closestStopTimeOffset } @@ -1200,8 +1277,6 @@ private constructor( * Distance, in meters, the transit vehicle has progressed along the active * trip. */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -1210,8 +1285,6 @@ private constructor( fun frequency(frequency: String) = frequency(JsonField.of(frequency)) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -1227,8 +1300,6 @@ private constructor( * Last known distance along the trip received in real-time from the transit * vehicle. */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip @@ -1239,8 +1310,6 @@ private constructor( lastKnownLocation(JsonField.of(lastKnownLocation)) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing fun lastKnownLocation(lastKnownLocation: JsonField) = apply { this.lastKnownLocation = lastKnownLocation } @@ -1254,8 +1323,6 @@ private constructor( /** * Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { this.lastKnownOrientation = lastKnownOrientation } @@ -1271,8 +1338,6 @@ private constructor( * Timestamp of the last known real-time location update from the transit * vehicle. */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { this.lastLocationUpdateTime = lastLocationUpdateTime } @@ -1282,8 +1347,6 @@ private constructor( lastUpdateTime(JsonField.of(lastUpdateTime)) /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -1292,8 +1355,6 @@ private constructor( fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } /** @@ -1307,8 +1368,6 @@ private constructor( * Time offset from the next stop to the current position of the transit vehicle * (in seconds). */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { this.nextStopTimeOffset = nextStopTimeOffset } @@ -1318,8 +1377,6 @@ private constructor( occupancyCapacity(JsonField.of(occupancyCapacity)) /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing fun occupancyCapacity(occupancyCapacity: JsonField) = apply { this.occupancyCapacity = occupancyCapacity } @@ -1329,8 +1386,6 @@ private constructor( occupancyCount(JsonField.of(occupancyCount)) /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing fun occupancyCount(occupancyCount: JsonField) = apply { this.occupancyCount = occupancyCount } @@ -1340,8 +1395,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -1350,8 +1403,6 @@ private constructor( fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing fun orientation(orientation: JsonField) = apply { this.orientation = orientation } @@ -1360,24 +1411,18 @@ private constructor( fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing fun phase(phase: JsonField) = apply { this.phase = phase } /** Current position of the transit vehicle. */ fun position(position: Position) = position(JsonField.of(position)) /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } @@ -1393,8 +1438,6 @@ private constructor( * Deviation from the schedule in seconds (positive for late, negative for * early). */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing fun scheduleDeviation(scheduleDeviation: JsonField) = apply { this.scheduleDeviation = scheduleDeviation } @@ -1410,8 +1453,6 @@ private constructor( * Distance, in meters, the transit vehicle is scheduled to have progressed * along the active trip. */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip @@ -1427,8 +1468,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -1438,8 +1477,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } @@ -1448,8 +1485,6 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** Total length of the trip, in meters. */ @@ -1457,8 +1492,6 @@ private constructor( totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { this.totalDistanceAlongTrip = totalDistanceAlongTrip } @@ -1467,20 +1500,17 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1488,6 +1518,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Status = Status( activeTripId, @@ -1522,17 +1560,20 @@ private constructor( } /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) @NoAutoDetect class LastKnownLocation + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the last known location of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1549,6 +1590,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): LastKnownLocation = apply { if (!validated) { lat() @@ -1573,42 +1616,46 @@ private constructor( @JvmSynthetic internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) + 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)) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): LastKnownLocation = LastKnownLocation( lat, @@ -1636,17 +1683,20 @@ private constructor( } /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) @NoAutoDetect class Position + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the current position of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1663,6 +1713,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Position = apply { if (!validated) { lat() @@ -1687,42 +1739,45 @@ private constructor( @JvmSynthetic internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) + 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)) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Position = Position( lat, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt index 1d8bdfc..57401e2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripForVehicleRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt index 3e30f24..58341fb 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = TripForVehicleRetrieveResponse.Builder::class) @NoAutoDetect class TripForVehicleRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): TripForVehicleRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,54 @@ private constructor( @JvmSynthetic internal fun from(tripForVehicleRetrieveResponse: TripForVehicleRetrieveResponse) = apply { - this.code = tripForVehicleRetrieveResponse.code - this.currentTime = tripForVehicleRetrieveResponse.currentTime - this.text = tripForVehicleRetrieveResponse.text - this.version = tripForVehicleRetrieveResponse.version - this.data = tripForVehicleRetrieveResponse.data - additionalProperties(tripForVehicleRetrieveResponse.additionalProperties) + code = tripForVehicleRetrieveResponse.code + currentTime = tripForVehicleRetrieveResponse.currentTime + text = tripForVehicleRetrieveResponse.text + version = tripForVehicleRetrieveResponse.version + data = tripForVehicleRetrieveResponse.data + additionalProperties = + tripForVehicleRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): TripForVehicleRetrieveResponse = TripForVehicleRetrieveResponse( code, @@ -153,17 +154,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +180,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +205,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,21 +247,32 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val frequency: JsonField, - private val schedule: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val tripId: JsonField, - private val additionalProperties: Map, + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + private val schedule: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -287,6 +305,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { frequency() @@ -318,31 +338,25 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.frequency = entry.frequency - this.schedule = entry.schedule - this.serviceDate = entry.serviceDate - this.situationIds = entry.situationIds - this.status = entry.status - this.tripId = entry.tripId - additionalProperties(entry.additionalProperties) + frequency = entry.frequency + schedule = entry.schedule + serviceDate = entry.serviceDate + situationIds = entry.situationIds + status = entry.status + tripId = entry.tripId + additionalProperties = entry.additionalProperties.toMutableMap() } fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - @JsonProperty("schedule") - @ExcludeMissing fun schedule(schedule: JsonField) = apply { this.schedule = schedule } fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -350,32 +364,25 @@ private constructor( fun situationIds(situationIds: List) = situationIds(JsonField.of(situationIds)) - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } fun status(status: Status) = status(JsonField.of(status)) - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -383,6 +390,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( frequency, @@ -395,20 +410,29 @@ private constructor( ) } - @JsonDeserialize(builder = Schedule.Builder::class) @NoAutoDetect class Schedule + @JsonCreator private constructor( - private val frequency: JsonField, - private val nextTripId: JsonField, - private val previousTripId: JsonField, - private val stopTimes: JsonField>, - private val timeZone: JsonField, - private val additionalProperties: Map, + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("nextTripId") + @ExcludeMissing + private val nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + private val previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + private val stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + private val timeZone: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -436,6 +460,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Schedule = apply { if (!validated) { frequency() @@ -465,26 +491,22 @@ private constructor( @JvmSynthetic internal fun from(schedule: Schedule) = apply { - this.frequency = schedule.frequency - this.nextTripId = schedule.nextTripId - this.previousTripId = schedule.previousTripId - this.stopTimes = schedule.stopTimes - this.timeZone = schedule.timeZone - additionalProperties(schedule.additionalProperties) + frequency = schedule.frequency + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes + timeZone = schedule.timeZone + additionalProperties = schedule.additionalProperties.toMutableMap() } fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - @JsonProperty("nextTripId") - @ExcludeMissing fun nextTripId(nextTripId: JsonField) = apply { this.nextTripId = nextTripId } @@ -492,34 +514,27 @@ private constructor( fun previousTripId(previousTripId: String) = previousTripId(JsonField.of(previousTripId)) - @JsonProperty("previousTripId") - @ExcludeMissing fun previousTripId(previousTripId: JsonField) = apply { this.previousTripId = previousTripId } fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - @JsonProperty("stopTimes") - @ExcludeMissing fun stopTimes(stopTimes: JsonField>) = apply { this.stopTimes = stopTimes } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - @JsonProperty("timeZone") - @ExcludeMissing fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -527,6 +542,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Schedule = Schedule( frequency, @@ -538,21 +561,32 @@ private constructor( ) } - @JsonDeserialize(builder = StopTime.Builder::class) @NoAutoDetect class StopTime + @JsonCreator private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, + @JsonProperty("arrivalTime") + @ExcludeMissing + private val arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + private val departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + private val historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arrivalTime(): Optional = Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) @@ -593,6 +627,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopTime = apply { if (!validated) { arrivalTime() @@ -625,19 +661,17 @@ private constructor( @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() } fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing fun arrivalTime(arrivalTime: JsonField) = apply { this.arrivalTime = arrivalTime } @@ -645,8 +679,6 @@ private constructor( fun departureTime(departureTime: Long) = departureTime(JsonField.of(departureTime)) - @JsonProperty("departureTime") - @ExcludeMissing fun departureTime(departureTime: JsonField) = apply { this.departureTime = departureTime } @@ -654,8 +686,6 @@ private constructor( fun distanceAlongTrip(distanceAlongTrip: Double) = distanceAlongTrip(JsonField.of(distanceAlongTrip)) - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -663,8 +693,6 @@ private constructor( fun historicalOccupancy(historicalOccupancy: String) = historicalOccupancy(JsonField.of(historicalOccupancy)) - @JsonProperty("historicalOccupancy") - @ExcludeMissing fun historicalOccupancy(historicalOccupancy: JsonField) = apply { this.historicalOccupancy = historicalOccupancy } @@ -672,33 +700,36 @@ private constructor( fun stopHeadsign(stopHeadsign: String) = stopHeadsign(JsonField.of(stopHeadsign)) - @JsonProperty("stopHeadsign") - @ExcludeMissing fun stopHeadsign(stopHeadsign: JsonField) = apply { this.stopHeadsign = stopHeadsign } fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopTime = StopTime( arrivalTime, @@ -747,42 +778,95 @@ private constructor( "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Status.Builder::class) @NoAutoDetect class Status + @JsonCreator private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("activeTripId") + @ExcludeMissing + private val activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + private val closestStop: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + private val occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + private val occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + private val scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Trip ID of the trip the vehicle is actively serving. */ fun activeTripId(): String = activeTripId.getRequired("activeTripId") @@ -1037,6 +1121,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Status = apply { if (!validated) { activeTripId() @@ -1110,34 +1196,34 @@ private constructor( @JvmSynthetic internal fun from(status: Status) = apply { - this.activeTripId = status.activeTripId - this.blockTripSequence = status.blockTripSequence - this.closestStop = status.closestStop - this.closestStopTimeOffset = status.closestStopTimeOffset - this.distanceAlongTrip = status.distanceAlongTrip - this.frequency = status.frequency - this.lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - this.lastKnownLocation = status.lastKnownLocation - this.lastKnownOrientation = status.lastKnownOrientation - this.lastLocationUpdateTime = status.lastLocationUpdateTime - this.lastUpdateTime = status.lastUpdateTime - this.nextStop = status.nextStop - this.nextStopTimeOffset = status.nextStopTimeOffset - this.occupancyCapacity = status.occupancyCapacity - this.occupancyCount = status.occupancyCount - this.occupancyStatus = status.occupancyStatus - this.orientation = status.orientation - this.phase = status.phase - this.position = status.position - this.predicted = status.predicted - this.scheduleDeviation = status.scheduleDeviation - this.scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - this.serviceDate = status.serviceDate - this.situationIds = status.situationIds + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + closestStopTimeOffset = status.closestStopTimeOffset + distanceAlongTrip = status.distanceAlongTrip + frequency = status.frequency + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + orientation = status.orientation + phase = status.phase + position = status.position + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + serviceDate = status.serviceDate + situationIds = status.situationIds this.status = status.status - this.totalDistanceAlongTrip = status.totalDistanceAlongTrip - this.vehicleId = status.vehicleId - additionalProperties(status.additionalProperties) + totalDistanceAlongTrip = status.totalDistanceAlongTrip + vehicleId = status.vehicleId + additionalProperties = status.additionalProperties.toMutableMap() } /** Trip ID of the trip the vehicle is actively serving. */ @@ -1145,8 +1231,6 @@ private constructor( activeTripId(JsonField.of(activeTripId)) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing fun activeTripId(activeTripId: JsonField) = apply { this.activeTripId = activeTripId } @@ -1156,8 +1240,6 @@ private constructor( blockTripSequence(JsonField.of(blockTripSequence)) /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -1166,8 +1248,6 @@ private constructor( fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing fun closestStop(closestStop: JsonField) = apply { this.closestStop = closestStop } @@ -1183,8 +1263,6 @@ private constructor( * Time offset from the closest stop to the current position of the transit * vehicle (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { this.closestStopTimeOffset = closestStopTimeOffset } @@ -1200,8 +1278,6 @@ private constructor( * Distance, in meters, the transit vehicle has progressed along the active * trip. */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -1210,8 +1286,6 @@ private constructor( fun frequency(frequency: String) = frequency(JsonField.of(frequency)) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -1227,8 +1301,6 @@ private constructor( * Last known distance along the trip received in real-time from the transit * vehicle. */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip @@ -1239,8 +1311,6 @@ private constructor( lastKnownLocation(JsonField.of(lastKnownLocation)) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing fun lastKnownLocation(lastKnownLocation: JsonField) = apply { this.lastKnownLocation = lastKnownLocation } @@ -1254,8 +1324,6 @@ private constructor( /** * Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { this.lastKnownOrientation = lastKnownOrientation } @@ -1271,8 +1339,6 @@ private constructor( * Timestamp of the last known real-time location update from the transit * vehicle. */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { this.lastLocationUpdateTime = lastLocationUpdateTime } @@ -1282,8 +1348,6 @@ private constructor( lastUpdateTime(JsonField.of(lastUpdateTime)) /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -1292,8 +1356,6 @@ private constructor( fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } /** @@ -1307,8 +1369,6 @@ private constructor( * Time offset from the next stop to the current position of the transit vehicle * (in seconds). */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { this.nextStopTimeOffset = nextStopTimeOffset } @@ -1318,8 +1378,6 @@ private constructor( occupancyCapacity(JsonField.of(occupancyCapacity)) /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing fun occupancyCapacity(occupancyCapacity: JsonField) = apply { this.occupancyCapacity = occupancyCapacity } @@ -1329,8 +1387,6 @@ private constructor( occupancyCount(JsonField.of(occupancyCount)) /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing fun occupancyCount(occupancyCount: JsonField) = apply { this.occupancyCount = occupancyCount } @@ -1340,8 +1396,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -1350,8 +1404,6 @@ private constructor( fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing fun orientation(orientation: JsonField) = apply { this.orientation = orientation } @@ -1360,24 +1412,18 @@ private constructor( fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing fun phase(phase: JsonField) = apply { this.phase = phase } /** Current position of the transit vehicle. */ fun position(position: Position) = position(JsonField.of(position)) /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } @@ -1393,8 +1439,6 @@ private constructor( * Deviation from the schedule in seconds (positive for late, negative for * early). */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing fun scheduleDeviation(scheduleDeviation: JsonField) = apply { this.scheduleDeviation = scheduleDeviation } @@ -1410,8 +1454,6 @@ private constructor( * Distance, in meters, the transit vehicle is scheduled to have progressed * along the active trip. */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip @@ -1427,8 +1469,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -1438,8 +1478,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } @@ -1448,8 +1486,6 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** Total length of the trip, in meters. */ @@ -1457,8 +1493,6 @@ private constructor( totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { this.totalDistanceAlongTrip = totalDistanceAlongTrip } @@ -1467,20 +1501,17 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1488,6 +1519,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Status = Status( activeTripId, @@ -1522,17 +1561,20 @@ private constructor( } /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) @NoAutoDetect class LastKnownLocation + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the last known location of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1549,6 +1591,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): LastKnownLocation = apply { if (!validated) { lat() @@ -1573,42 +1617,46 @@ private constructor( @JvmSynthetic internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) + 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)) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): LastKnownLocation = LastKnownLocation( lat, @@ -1636,17 +1684,20 @@ private constructor( } /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) @NoAutoDetect class Position + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the current position of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1663,6 +1714,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Position = apply { if (!validated) { lat() @@ -1687,42 +1740,45 @@ private constructor( @JvmSynthetic internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) + 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)) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Position = Position( lat, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt index fffa5d4..a2511a5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt @@ -6,7 +6,6 @@ import java.util.Objects import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripRetrieveParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt index 097630f..0ab0673 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = TripRetrieveResponse.Builder::class) @NoAutoDetect class TripRetrieveResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): TripRetrieveResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(tripRetrieveResponse: TripRetrieveResponse) = apply { - this.code = tripRetrieveResponse.code - this.currentTime = tripRetrieveResponse.currentTime - this.text = tripRetrieveResponse.text - this.version = tripRetrieveResponse.version - this.data = tripRetrieveResponse.data - additionalProperties(tripRetrieveResponse.additionalProperties) + code = tripRetrieveResponse.code + currentTime = tripRetrieveResponse.currentTime + text = tripRetrieveResponse.text + version = tripRetrieveResponse.version + data = tripRetrieveResponse.data + additionalProperties = tripRetrieveResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): TripRetrieveResponse = TripRetrieveResponse( code, @@ -153,17 +153,20 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val entry: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("entry") + @ExcludeMissing + private val entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun entry(): Entry = entry.getRequired("entry") fun references(): References = references.getRequired("references") @@ -176,6 +179,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { entry().validate() @@ -199,39 +204,40 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.entry = data.entry - this.references = data.references - additionalProperties(data.additionalProperties) + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun entry(entry: Entry) = entry(JsonField.of(entry)) - @JsonProperty("entry") - @ExcludeMissing fun entry(entry: JsonField) = apply { this.entry = entry } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( entry, @@ -240,26 +246,47 @@ private constructor( ) } - @JsonDeserialize(builder = Entry.Builder::class) @NoAutoDetect class Entry + @JsonCreator private constructor( - private val blockId: JsonField, - private val directionId: JsonField, - private val id: JsonField, - private val peakOffpeak: JsonField, - private val routeId: JsonField, - private val routeShortName: JsonField, - private val serviceId: JsonField, - private val shapeId: JsonField, - private val timeZone: JsonField, - private val tripHeadsign: JsonField, - private val tripShortName: JsonField, - private val additionalProperties: Map, + @JsonProperty("blockId") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + private val directionId: JsonField = JsonMissing.of(), + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("peakOffpeak") + @ExcludeMissing + private val peakOffpeak: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + private val routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), + @JsonProperty("shapeId") + @ExcludeMissing + private val shapeId: JsonField = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + private val timeZone: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripShortName") + @ExcludeMissing + private val tripShortName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) fun directionId(): Optional = @@ -313,6 +340,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Entry = apply { if (!validated) { blockId() @@ -354,85 +383,65 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - this.blockId = entry.blockId - this.directionId = entry.directionId - this.id = entry.id - this.peakOffpeak = entry.peakOffpeak - this.routeId = entry.routeId - this.routeShortName = entry.routeShortName - this.serviceId = entry.serviceId - this.shapeId = entry.shapeId - this.timeZone = entry.timeZone - this.tripHeadsign = entry.tripHeadsign - this.tripShortName = entry.tripShortName - additionalProperties(entry.additionalProperties) + blockId = entry.blockId + directionId = entry.directionId + id = entry.id + peakOffpeak = entry.peakOffpeak + routeId = entry.routeId + routeShortName = entry.routeShortName + serviceId = entry.serviceId + shapeId = entry.shapeId + timeZone = entry.timeZone + tripHeadsign = entry.tripHeadsign + tripShortName = entry.tripShortName + additionalProperties = entry.additionalProperties.toMutableMap() } fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - @JsonProperty("blockId") - @ExcludeMissing fun blockId(blockId: JsonField) = apply { this.blockId = blockId } fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - @JsonProperty("directionId") - @ExcludeMissing fun directionId(directionId: JsonField) = apply { this.directionId = directionId } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) - @JsonProperty("peakOffpeak") - @ExcludeMissing fun peakOffpeak(peakOffpeak: JsonField) = apply { this.peakOffpeak = peakOffpeak } fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - @JsonProperty("routeId") - @ExcludeMissing fun routeId(routeId: JsonField) = apply { this.routeId = routeId } fun routeShortName(routeShortName: String) = routeShortName(JsonField.of(routeShortName)) - @JsonProperty("routeShortName") - @ExcludeMissing fun routeShortName(routeShortName: JsonField) = apply { this.routeShortName = routeShortName } fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - @JsonProperty("serviceId") - @ExcludeMissing fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) - @JsonProperty("shapeId") - @ExcludeMissing fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - @JsonProperty("timeZone") - @ExcludeMissing fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) - @JsonProperty("tripHeadsign") - @ExcludeMissing fun tripHeadsign(tripHeadsign: JsonField) = apply { this.tripHeadsign = tripHeadsign } @@ -440,20 +449,17 @@ private constructor( fun tripShortName(tripShortName: String) = tripShortName(JsonField.of(tripShortName)) - @JsonProperty("tripShortName") - @ExcludeMissing fun tripShortName(tripShortName: JsonField) = apply { this.tripShortName = tripShortName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -461,6 +467,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Entry = Entry( blockId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt index 033afce..e819ee8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripsForLocationListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt index d5485c4..f0ee349 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = TripsForLocationListResponse.Builder::class) @NoAutoDetect class TripsForLocationListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): TripsForLocationListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(tripsForLocationListResponse: TripsForLocationListResponse) = apply { - this.code = tripsForLocationListResponse.code - this.currentTime = tripsForLocationListResponse.currentTime - this.text = tripsForLocationListResponse.text - this.version = tripsForLocationListResponse.version - this.data = tripsForLocationListResponse.data - additionalProperties(tripsForLocationListResponse.additionalProperties) + code = tripsForLocationListResponse.code + currentTime = tripsForLocationListResponse.currentTime + text = tripsForLocationListResponse.text + version = tripsForLocationListResponse.version + data = tripsForLocationListResponse.data + additionalProperties = tripsForLocationListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): TripsForLocationListResponse = TripsForLocationListResponse( code, @@ -153,19 +153,26 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val outOfRange: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Indicates if the limit of trips has been exceeded */ fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") @@ -191,6 +198,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -218,59 +227,56 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.outOfRange = data.outOfRange - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + outOfRange = data.outOfRange + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } /** Indicates if the limit of trips has been exceeded */ fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) /** Indicates if the limit of trips has been exceeded */ - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } /** Indicates if the search location is out of range */ fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) /** Indicates if the search location is out of range */ - @JsonProperty("outOfRange") - @ExcludeMissing fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -281,21 +287,32 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val frequency: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val tripId: JsonField, - private val schedule: JsonField, - private val status: JsonField, - private val additionalProperties: Map, + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + private val schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -327,6 +344,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { frequency() @@ -359,25 +378,21 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.frequency = list.frequency - this.serviceDate = list.serviceDate - this.situationIds = list.situationIds - this.tripId = list.tripId - this.schedule = list.schedule - this.status = list.status - additionalProperties(list.additionalProperties) + frequency = list.frequency + serviceDate = list.serviceDate + situationIds = list.situationIds + tripId = list.tripId + schedule = list.schedule + status = list.status + additionalProperties = list.additionalProperties.toMutableMap() } fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -385,38 +400,29 @@ private constructor( fun situationIds(situationIds: kotlin.collections.List) = situationIds(JsonField.of(situationIds)) - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - @JsonProperty("schedule") - @ExcludeMissing fun schedule(schedule: JsonField) = apply { this.schedule = schedule } fun status(status: Status) = status(JsonField.of(status)) - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -424,6 +430,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( frequency, @@ -436,20 +450,30 @@ private constructor( ) } - @JsonDeserialize(builder = Schedule.Builder::class) @NoAutoDetect class Schedule + @JsonCreator private constructor( - private val frequency: JsonField, - private val nextTripId: JsonField, - private val previousTripId: JsonField, - private val stopTimes: JsonField>, - private val timeZone: JsonField, - private val additionalProperties: Map, + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("nextTripId") + @ExcludeMissing + private val nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + private val previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + private val stopTimes: JsonField> = + JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + private val timeZone: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -478,6 +502,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Schedule = apply { if (!validated) { frequency() @@ -508,26 +534,22 @@ private constructor( @JvmSynthetic internal fun from(schedule: Schedule) = apply { - this.frequency = schedule.frequency - this.nextTripId = schedule.nextTripId - this.previousTripId = schedule.previousTripId - this.stopTimes = schedule.stopTimes - this.timeZone = schedule.timeZone - additionalProperties(schedule.additionalProperties) + frequency = schedule.frequency + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes + timeZone = schedule.timeZone + additionalProperties = schedule.additionalProperties.toMutableMap() } fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - @JsonProperty("nextTripId") - @ExcludeMissing fun nextTripId(nextTripId: JsonField) = apply { this.nextTripId = nextTripId } @@ -535,8 +557,6 @@ private constructor( fun previousTripId(previousTripId: String) = previousTripId(JsonField.of(previousTripId)) - @JsonProperty("previousTripId") - @ExcludeMissing fun previousTripId(previousTripId: JsonField) = apply { this.previousTripId = previousTripId } @@ -544,26 +564,21 @@ private constructor( fun stopTimes(stopTimes: kotlin.collections.List) = stopTimes(JsonField.of(stopTimes)) - @JsonProperty("stopTimes") - @ExcludeMissing fun stopTimes(stopTimes: JsonField>) = apply { this.stopTimes = stopTimes } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - @JsonProperty("timeZone") - @ExcludeMissing fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -571,6 +586,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Schedule = Schedule( frequency, @@ -582,21 +605,32 @@ private constructor( ) } - @JsonDeserialize(builder = StopTime.Builder::class) @NoAutoDetect class StopTime + @JsonCreator private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, + @JsonProperty("arrivalTime") + @ExcludeMissing + private val arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + private val departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + private val historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arrivalTime(): Optional = Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) @@ -637,6 +671,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopTime = apply { if (!validated) { arrivalTime() @@ -669,19 +705,17 @@ private constructor( @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() } fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing fun arrivalTime(arrivalTime: JsonField) = apply { this.arrivalTime = arrivalTime } @@ -689,8 +723,6 @@ private constructor( fun departureTime(departureTime: Long) = departureTime(JsonField.of(departureTime)) - @JsonProperty("departureTime") - @ExcludeMissing fun departureTime(departureTime: JsonField) = apply { this.departureTime = departureTime } @@ -698,8 +730,6 @@ private constructor( fun distanceAlongTrip(distanceAlongTrip: Double) = distanceAlongTrip(JsonField.of(distanceAlongTrip)) - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -707,8 +737,6 @@ private constructor( fun historicalOccupancy(historicalOccupancy: String) = historicalOccupancy(JsonField.of(historicalOccupancy)) - @JsonProperty("historicalOccupancy") - @ExcludeMissing fun historicalOccupancy(historicalOccupancy: JsonField) = apply { this.historicalOccupancy = historicalOccupancy } @@ -716,33 +744,36 @@ private constructor( fun stopHeadsign(stopHeadsign: String) = stopHeadsign(JsonField.of(stopHeadsign)) - @JsonProperty("stopHeadsign") - @ExcludeMissing fun stopHeadsign(stopHeadsign: JsonField) = apply { this.stopHeadsign = stopHeadsign } fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopTime = StopTime( arrivalTime, @@ -791,42 +822,96 @@ private constructor( "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Status.Builder::class) @NoAutoDetect class Status + @JsonCreator private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("activeTripId") + @ExcludeMissing + private val activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + private val closestStop: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + private val occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + private val occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + private val scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = + JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Trip ID of the trip the vehicle is actively serving. */ fun activeTripId(): String = activeTripId.getRequired("activeTripId") @@ -1081,6 +1166,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Status = apply { if (!validated) { activeTripId() @@ -1155,34 +1242,34 @@ private constructor( @JvmSynthetic internal fun from(status: Status) = apply { - this.activeTripId = status.activeTripId - this.blockTripSequence = status.blockTripSequence - this.closestStop = status.closestStop - this.closestStopTimeOffset = status.closestStopTimeOffset - this.distanceAlongTrip = status.distanceAlongTrip - this.frequency = status.frequency - this.lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - this.lastKnownLocation = status.lastKnownLocation - this.lastKnownOrientation = status.lastKnownOrientation - this.lastLocationUpdateTime = status.lastLocationUpdateTime - this.lastUpdateTime = status.lastUpdateTime - this.nextStop = status.nextStop - this.nextStopTimeOffset = status.nextStopTimeOffset - this.occupancyCapacity = status.occupancyCapacity - this.occupancyCount = status.occupancyCount - this.occupancyStatus = status.occupancyStatus - this.orientation = status.orientation - this.phase = status.phase - this.position = status.position - this.predicted = status.predicted - this.scheduleDeviation = status.scheduleDeviation - this.scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - this.serviceDate = status.serviceDate - this.situationIds = status.situationIds + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + closestStopTimeOffset = status.closestStopTimeOffset + distanceAlongTrip = status.distanceAlongTrip + frequency = status.frequency + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + orientation = status.orientation + phase = status.phase + position = status.position + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + serviceDate = status.serviceDate + situationIds = status.situationIds this.status = status.status - this.totalDistanceAlongTrip = status.totalDistanceAlongTrip - this.vehicleId = status.vehicleId - additionalProperties(status.additionalProperties) + totalDistanceAlongTrip = status.totalDistanceAlongTrip + vehicleId = status.vehicleId + additionalProperties = status.additionalProperties.toMutableMap() } /** Trip ID of the trip the vehicle is actively serving. */ @@ -1190,8 +1277,6 @@ private constructor( activeTripId(JsonField.of(activeTripId)) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing fun activeTripId(activeTripId: JsonField) = apply { this.activeTripId = activeTripId } @@ -1201,8 +1286,6 @@ private constructor( blockTripSequence(JsonField.of(blockTripSequence)) /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -1211,8 +1294,6 @@ private constructor( fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing fun closestStop(closestStop: JsonField) = apply { this.closestStop = closestStop } @@ -1228,8 +1309,6 @@ private constructor( * Time offset from the closest stop to the current position of the transit * vehicle (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { this.closestStopTimeOffset = closestStopTimeOffset } @@ -1245,8 +1324,6 @@ private constructor( * Distance, in meters, the transit vehicle has progressed along the active * trip. */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -1255,8 +1332,6 @@ private constructor( fun frequency(frequency: String) = frequency(JsonField.of(frequency)) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -1272,8 +1347,6 @@ private constructor( * Last known distance along the trip received in real-time from the transit * vehicle. */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip @@ -1284,8 +1357,6 @@ private constructor( lastKnownLocation(JsonField.of(lastKnownLocation)) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing fun lastKnownLocation(lastKnownLocation: JsonField) = apply { this.lastKnownLocation = lastKnownLocation } @@ -1299,8 +1370,6 @@ private constructor( /** * Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { this.lastKnownOrientation = lastKnownOrientation } @@ -1316,8 +1385,6 @@ private constructor( * Timestamp of the last known real-time location update from the transit * vehicle. */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { this.lastLocationUpdateTime = lastLocationUpdateTime } @@ -1327,8 +1394,6 @@ private constructor( lastUpdateTime(JsonField.of(lastUpdateTime)) /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -1337,8 +1402,6 @@ private constructor( fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } /** @@ -1352,8 +1415,6 @@ private constructor( * Time offset from the next stop to the current position of the transit vehicle * (in seconds). */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { this.nextStopTimeOffset = nextStopTimeOffset } @@ -1363,8 +1424,6 @@ private constructor( occupancyCapacity(JsonField.of(occupancyCapacity)) /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing fun occupancyCapacity(occupancyCapacity: JsonField) = apply { this.occupancyCapacity = occupancyCapacity } @@ -1374,8 +1433,6 @@ private constructor( occupancyCount(JsonField.of(occupancyCount)) /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing fun occupancyCount(occupancyCount: JsonField) = apply { this.occupancyCount = occupancyCount } @@ -1385,8 +1442,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -1395,8 +1450,6 @@ private constructor( fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing fun orientation(orientation: JsonField) = apply { this.orientation = orientation } @@ -1405,24 +1458,18 @@ private constructor( fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing fun phase(phase: JsonField) = apply { this.phase = phase } /** Current position of the transit vehicle. */ fun position(position: Position) = position(JsonField.of(position)) /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } @@ -1438,8 +1485,6 @@ private constructor( * Deviation from the schedule in seconds (positive for late, negative for * early). */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing fun scheduleDeviation(scheduleDeviation: JsonField) = apply { this.scheduleDeviation = scheduleDeviation } @@ -1455,8 +1500,6 @@ private constructor( * Distance, in meters, the transit vehicle is scheduled to have progressed * along the active trip. */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip @@ -1472,8 +1515,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -1483,8 +1524,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds @@ -1494,8 +1533,6 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** Total length of the trip, in meters. */ @@ -1503,8 +1540,6 @@ private constructor( totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { this.totalDistanceAlongTrip = totalDistanceAlongTrip } @@ -1513,20 +1548,17 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1534,6 +1566,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Status = Status( activeTripId, @@ -1568,17 +1608,20 @@ private constructor( } /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) @NoAutoDetect class LastKnownLocation + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the last known location of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1595,6 +1638,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): LastKnownLocation = apply { if (!validated) { lat() @@ -1619,42 +1664,46 @@ private constructor( @JvmSynthetic internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) + 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)) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): LastKnownLocation = LastKnownLocation( lat, @@ -1682,17 +1731,20 @@ private constructor( } /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) @NoAutoDetect class Position + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the current position of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1709,6 +1761,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Position = apply { if (!validated) { lat() @@ -1733,42 +1787,45 @@ private constructor( @JvmSynthetic internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) + 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)) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Position = Position( lat, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt index c28df08..562eb3c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripsForRouteListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt index aa65c0a..4b2acb0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = TripsForRouteListResponse.Builder::class) @NoAutoDetect class TripsForRouteListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): TripsForRouteListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(tripsForRouteListResponse: TripsForRouteListResponse) = apply { - this.code = tripsForRouteListResponse.code - this.currentTime = tripsForRouteListResponse.currentTime - this.text = tripsForRouteListResponse.text - this.version = tripsForRouteListResponse.version - this.data = tripsForRouteListResponse.data - additionalProperties(tripsForRouteListResponse.additionalProperties) + code = tripsForRouteListResponse.code + currentTime = tripsForRouteListResponse.currentTime + text = tripsForRouteListResponse.text + version = tripsForRouteListResponse.version + data = tripsForRouteListResponse.data + additionalProperties = tripsForRouteListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): TripsForRouteListResponse = TripsForRouteListResponse( code, @@ -153,18 +153,23 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val limitExceeded: JsonField, - private val list: JsonField>, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun list(): kotlin.collections.List = list.getRequired("list") @@ -181,6 +186,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { limitExceeded() @@ -206,48 +213,47 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.limitExceeded = data.limitExceeded - this.list = data.list - this.references = data.references - additionalProperties(data.additionalProperties) + limitExceeded = data.limitExceeded + list = data.list + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( limitExceeded, @@ -257,21 +263,32 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val frequency: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val tripId: JsonField, - private val schedule: JsonField, - private val status: JsonField, - private val additionalProperties: Map, + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + private val schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -303,6 +320,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { frequency() @@ -335,25 +354,21 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.frequency = list.frequency - this.serviceDate = list.serviceDate - this.situationIds = list.situationIds - this.tripId = list.tripId - this.schedule = list.schedule - this.status = list.status - additionalProperties(list.additionalProperties) + frequency = list.frequency + serviceDate = list.serviceDate + situationIds = list.situationIds + tripId = list.tripId + schedule = list.schedule + status = list.status + additionalProperties = list.additionalProperties.toMutableMap() } fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -361,38 +376,29 @@ private constructor( fun situationIds(situationIds: kotlin.collections.List) = situationIds(JsonField.of(situationIds)) - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - @JsonProperty("schedule") - @ExcludeMissing fun schedule(schedule: JsonField) = apply { this.schedule = schedule } fun status(status: Status) = status(JsonField.of(status)) - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -400,6 +406,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( frequency, @@ -412,20 +426,30 @@ private constructor( ) } - @JsonDeserialize(builder = Schedule.Builder::class) @NoAutoDetect class Schedule + @JsonCreator private constructor( - private val frequency: JsonField, - private val nextTripId: JsonField, - private val previousTripId: JsonField, - private val stopTimes: JsonField>, - private val timeZone: JsonField, - private val additionalProperties: Map, + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("nextTripId") + @ExcludeMissing + private val nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + private val previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + private val stopTimes: JsonField> = + JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + private val timeZone: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -454,6 +478,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Schedule = apply { if (!validated) { frequency() @@ -484,26 +510,22 @@ private constructor( @JvmSynthetic internal fun from(schedule: Schedule) = apply { - this.frequency = schedule.frequency - this.nextTripId = schedule.nextTripId - this.previousTripId = schedule.previousTripId - this.stopTimes = schedule.stopTimes - this.timeZone = schedule.timeZone - additionalProperties(schedule.additionalProperties) + frequency = schedule.frequency + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes + timeZone = schedule.timeZone + additionalProperties = schedule.additionalProperties.toMutableMap() } fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - @JsonProperty("nextTripId") - @ExcludeMissing fun nextTripId(nextTripId: JsonField) = apply { this.nextTripId = nextTripId } @@ -511,8 +533,6 @@ private constructor( fun previousTripId(previousTripId: String) = previousTripId(JsonField.of(previousTripId)) - @JsonProperty("previousTripId") - @ExcludeMissing fun previousTripId(previousTripId: JsonField) = apply { this.previousTripId = previousTripId } @@ -520,26 +540,21 @@ private constructor( fun stopTimes(stopTimes: kotlin.collections.List) = stopTimes(JsonField.of(stopTimes)) - @JsonProperty("stopTimes") - @ExcludeMissing fun stopTimes(stopTimes: JsonField>) = apply { this.stopTimes = stopTimes } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - @JsonProperty("timeZone") - @ExcludeMissing fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -547,6 +562,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Schedule = Schedule( frequency, @@ -558,21 +581,32 @@ private constructor( ) } - @JsonDeserialize(builder = StopTime.Builder::class) @NoAutoDetect class StopTime + @JsonCreator private constructor( - private val arrivalTime: JsonField, - private val departureTime: JsonField, - private val distanceAlongTrip: JsonField, - private val historicalOccupancy: JsonField, - private val stopHeadsign: JsonField, - private val stopId: JsonField, - private val additionalProperties: Map, + @JsonProperty("arrivalTime") + @ExcludeMissing + private val arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + private val departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + private val historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arrivalTime(): Optional = Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) @@ -613,6 +647,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): StopTime = apply { if (!validated) { arrivalTime() @@ -645,19 +681,17 @@ private constructor( @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - this.arrivalTime = stopTime.arrivalTime - this.departureTime = stopTime.departureTime - this.distanceAlongTrip = stopTime.distanceAlongTrip - this.historicalOccupancy = stopTime.historicalOccupancy - this.stopHeadsign = stopTime.stopHeadsign - this.stopId = stopTime.stopId - additionalProperties(stopTime.additionalProperties) + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() } fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - @JsonProperty("arrivalTime") - @ExcludeMissing fun arrivalTime(arrivalTime: JsonField) = apply { this.arrivalTime = arrivalTime } @@ -665,8 +699,6 @@ private constructor( fun departureTime(departureTime: Long) = departureTime(JsonField.of(departureTime)) - @JsonProperty("departureTime") - @ExcludeMissing fun departureTime(departureTime: JsonField) = apply { this.departureTime = departureTime } @@ -674,8 +706,6 @@ private constructor( fun distanceAlongTrip(distanceAlongTrip: Double) = distanceAlongTrip(JsonField.of(distanceAlongTrip)) - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -683,8 +713,6 @@ private constructor( fun historicalOccupancy(historicalOccupancy: String) = historicalOccupancy(JsonField.of(historicalOccupancy)) - @JsonProperty("historicalOccupancy") - @ExcludeMissing fun historicalOccupancy(historicalOccupancy: JsonField) = apply { this.historicalOccupancy = historicalOccupancy } @@ -692,33 +720,36 @@ private constructor( fun stopHeadsign(stopHeadsign: String) = stopHeadsign(JsonField.of(stopHeadsign)) - @JsonProperty("stopHeadsign") - @ExcludeMissing fun stopHeadsign(stopHeadsign: JsonField) = apply { this.stopHeadsign = stopHeadsign } fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - @JsonProperty("stopId") - @ExcludeMissing fun stopId(stopId: JsonField) = apply { this.stopId = stopId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): StopTime = StopTime( arrivalTime, @@ -767,42 +798,96 @@ private constructor( "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Status.Builder::class) @NoAutoDetect class Status + @JsonCreator private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("activeTripId") + @ExcludeMissing + private val activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + private val closestStop: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + private val occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + private val occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + private val scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = + JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Trip ID of the trip the vehicle is actively serving. */ fun activeTripId(): String = activeTripId.getRequired("activeTripId") @@ -1057,6 +1142,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Status = apply { if (!validated) { activeTripId() @@ -1131,34 +1218,34 @@ private constructor( @JvmSynthetic internal fun from(status: Status) = apply { - this.activeTripId = status.activeTripId - this.blockTripSequence = status.blockTripSequence - this.closestStop = status.closestStop - this.closestStopTimeOffset = status.closestStopTimeOffset - this.distanceAlongTrip = status.distanceAlongTrip - this.frequency = status.frequency - this.lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - this.lastKnownLocation = status.lastKnownLocation - this.lastKnownOrientation = status.lastKnownOrientation - this.lastLocationUpdateTime = status.lastLocationUpdateTime - this.lastUpdateTime = status.lastUpdateTime - this.nextStop = status.nextStop - this.nextStopTimeOffset = status.nextStopTimeOffset - this.occupancyCapacity = status.occupancyCapacity - this.occupancyCount = status.occupancyCount - this.occupancyStatus = status.occupancyStatus - this.orientation = status.orientation - this.phase = status.phase - this.position = status.position - this.predicted = status.predicted - this.scheduleDeviation = status.scheduleDeviation - this.scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - this.serviceDate = status.serviceDate - this.situationIds = status.situationIds + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + closestStopTimeOffset = status.closestStopTimeOffset + distanceAlongTrip = status.distanceAlongTrip + frequency = status.frequency + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + orientation = status.orientation + phase = status.phase + position = status.position + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + serviceDate = status.serviceDate + situationIds = status.situationIds this.status = status.status - this.totalDistanceAlongTrip = status.totalDistanceAlongTrip - this.vehicleId = status.vehicleId - additionalProperties(status.additionalProperties) + totalDistanceAlongTrip = status.totalDistanceAlongTrip + vehicleId = status.vehicleId + additionalProperties = status.additionalProperties.toMutableMap() } /** Trip ID of the trip the vehicle is actively serving. */ @@ -1166,8 +1253,6 @@ private constructor( activeTripId(JsonField.of(activeTripId)) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing fun activeTripId(activeTripId: JsonField) = apply { this.activeTripId = activeTripId } @@ -1177,8 +1262,6 @@ private constructor( blockTripSequence(JsonField.of(blockTripSequence)) /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -1187,8 +1270,6 @@ private constructor( fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing fun closestStop(closestStop: JsonField) = apply { this.closestStop = closestStop } @@ -1204,8 +1285,6 @@ private constructor( * Time offset from the closest stop to the current position of the transit * vehicle (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { this.closestStopTimeOffset = closestStopTimeOffset } @@ -1221,8 +1300,6 @@ private constructor( * Distance, in meters, the transit vehicle has progressed along the active * trip. */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -1231,8 +1308,6 @@ private constructor( fun frequency(frequency: String) = frequency(JsonField.of(frequency)) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -1248,8 +1323,6 @@ private constructor( * Last known distance along the trip received in real-time from the transit * vehicle. */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip @@ -1260,8 +1333,6 @@ private constructor( lastKnownLocation(JsonField.of(lastKnownLocation)) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing fun lastKnownLocation(lastKnownLocation: JsonField) = apply { this.lastKnownLocation = lastKnownLocation } @@ -1275,8 +1346,6 @@ private constructor( /** * Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { this.lastKnownOrientation = lastKnownOrientation } @@ -1292,8 +1361,6 @@ private constructor( * Timestamp of the last known real-time location update from the transit * vehicle. */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { this.lastLocationUpdateTime = lastLocationUpdateTime } @@ -1303,8 +1370,6 @@ private constructor( lastUpdateTime(JsonField.of(lastUpdateTime)) /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -1313,8 +1378,6 @@ private constructor( fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } /** @@ -1328,8 +1391,6 @@ private constructor( * Time offset from the next stop to the current position of the transit vehicle * (in seconds). */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { this.nextStopTimeOffset = nextStopTimeOffset } @@ -1339,8 +1400,6 @@ private constructor( occupancyCapacity(JsonField.of(occupancyCapacity)) /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing fun occupancyCapacity(occupancyCapacity: JsonField) = apply { this.occupancyCapacity = occupancyCapacity } @@ -1350,8 +1409,6 @@ private constructor( occupancyCount(JsonField.of(occupancyCount)) /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing fun occupancyCount(occupancyCount: JsonField) = apply { this.occupancyCount = occupancyCount } @@ -1361,8 +1418,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -1371,8 +1426,6 @@ private constructor( fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing fun orientation(orientation: JsonField) = apply { this.orientation = orientation } @@ -1381,24 +1434,18 @@ private constructor( fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing fun phase(phase: JsonField) = apply { this.phase = phase } /** Current position of the transit vehicle. */ fun position(position: Position) = position(JsonField.of(position)) /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } @@ -1414,8 +1461,6 @@ private constructor( * Deviation from the schedule in seconds (positive for late, negative for * early). */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing fun scheduleDeviation(scheduleDeviation: JsonField) = apply { this.scheduleDeviation = scheduleDeviation } @@ -1431,8 +1476,6 @@ private constructor( * Distance, in meters, the transit vehicle is scheduled to have progressed * along the active trip. */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip @@ -1448,8 +1491,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -1459,8 +1500,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds @@ -1470,8 +1509,6 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** Total length of the trip, in meters. */ @@ -1479,8 +1516,6 @@ private constructor( totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { this.totalDistanceAlongTrip = totalDistanceAlongTrip } @@ -1489,20 +1524,17 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1510,6 +1542,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Status = Status( activeTripId, @@ -1544,17 +1584,20 @@ private constructor( } /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) @NoAutoDetect class LastKnownLocation + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the last known location of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1571,6 +1614,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): LastKnownLocation = apply { if (!validated) { lat() @@ -1595,42 +1640,46 @@ private constructor( @JvmSynthetic internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) + 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)) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): LastKnownLocation = LastKnownLocation( lat, @@ -1658,17 +1707,20 @@ private constructor( } /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) @NoAutoDetect class Position + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the current position of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1685,6 +1737,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Position = apply { if (!validated) { lat() @@ -1709,42 +1763,45 @@ private constructor( @JvmSynthetic internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) + 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)) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Position = Position( lat, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt index 22c2d4e..b7d39fa 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt @@ -7,7 +7,6 @@ import java.util.Optional import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class VehiclesForAgencyListParams constructor( diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt index cd7ba9e..a8ff567 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt @@ -4,8 +4,8 @@ package org.onebusaway.models 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 com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import org.onebusaway.core.ExcludeMissing @@ -13,22 +13,25 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable -@JsonDeserialize(builder = VehiclesForAgencyListResponse.Builder::class) @NoAutoDetect class VehiclesForAgencyListResponse +@JsonCreator 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: Map, + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + private val currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun code(): Long = code.getRequired("code") fun currentTime(): Long = currentTime.getRequired("currentTime") @@ -39,14 +42,6 @@ private constructor( fun data(): Data = data.getRequired("data") - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - @JsonProperty("code") @ExcludeMissing fun _code() = code @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime @@ -61,6 +56,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + private var validated: Boolean = false + fun validate(): VehiclesForAgencyListResponse = apply { if (!validated) { code() @@ -90,58 +95,53 @@ private constructor( @JvmSynthetic internal fun from(vehiclesForAgencyListResponse: VehiclesForAgencyListResponse) = apply { - this.code = vehiclesForAgencyListResponse.code - this.currentTime = vehiclesForAgencyListResponse.currentTime - this.text = vehiclesForAgencyListResponse.text - this.version = vehiclesForAgencyListResponse.version - this.data = vehiclesForAgencyListResponse.data - additionalProperties(vehiclesForAgencyListResponse.additionalProperties) + code = vehiclesForAgencyListResponse.code + currentTime = vehiclesForAgencyListResponse.currentTime + text = vehiclesForAgencyListResponse.text + version = vehiclesForAgencyListResponse.version + data = vehiclesForAgencyListResponse.data + additionalProperties = vehiclesForAgencyListResponse.additionalProperties.toMutableMap() } fun code(code: Long) = code(JsonField.of(code)) - @JsonProperty("code") - @ExcludeMissing fun code(code: JsonField) = apply { this.code = code } fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - @JsonProperty("currentTime") - @ExcludeMissing fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } fun text(text: String) = text(JsonField.of(text)) - @JsonProperty("text") - @ExcludeMissing fun text(text: JsonField) = apply { this.text = text } fun version(version: Long) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): VehiclesForAgencyListResponse = VehiclesForAgencyListResponse( code, @@ -153,20 +153,23 @@ private constructor( ) } - @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect class Data + @JsonCreator private constructor( - private val list: JsonField>, - private val limitExceeded: JsonField, - private val references: JsonField, - private val additionalProperties: Map, + @JsonProperty("list") + @ExcludeMissing + private val list: JsonField> = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + private val references: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - private var hashCode: Int = 0 - fun list(): kotlin.collections.List = list.getRequired("list") fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") @@ -183,6 +186,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Data = apply { if (!validated) { list().forEach { it.validate() } @@ -208,48 +213,47 @@ private constructor( @JvmSynthetic internal fun from(data: Data) = apply { - this.list = data.list - this.limitExceeded = data.limitExceeded - this.references = data.references - additionalProperties(data.additionalProperties) + list = data.list + limitExceeded = data.limitExceeded + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - @JsonProperty("list") - @ExcludeMissing fun list(list: JsonField>) = apply { this.list = list } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - @JsonProperty("limitExceeded") - @ExcludeMissing fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } fun references(references: References) = references(JsonField.of(references)) - @JsonProperty("references") - @ExcludeMissing fun references(references: JsonField) = apply { this.references = references } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Data = Data( list.map { it.toImmutable() }, @@ -259,26 +263,47 @@ private constructor( ) } - @JsonDeserialize(builder = List.Builder::class) @NoAutoDetect class List + @JsonCreator private constructor( - private val vehicleId: JsonField, - private val lastUpdateTime: JsonField, - private val lastLocationUpdateTime: JsonField, - private val location: JsonField, - private val tripId: JsonField, - private val tripStatus: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val phase: JsonField, - private val status: JsonField, - private val additionalProperties: Map, + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + private val tripStatus: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + private val occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + private val occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun vehicleId(): String = vehicleId.getRequired("vehicleId") fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") @@ -337,6 +362,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): List = apply { if (!validated) { vehicleId() @@ -378,31 +405,27 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - this.vehicleId = list.vehicleId - this.lastUpdateTime = list.lastUpdateTime - this.lastLocationUpdateTime = list.lastLocationUpdateTime - this.location = list.location - this.tripId = list.tripId - this.tripStatus = list.tripStatus - this.occupancyCapacity = list.occupancyCapacity - this.occupancyCount = list.occupancyCount - this.occupancyStatus = list.occupancyStatus - this.phase = list.phase - this.status = list.status - additionalProperties(list.additionalProperties) + vehicleId = list.vehicleId + lastUpdateTime = list.lastUpdateTime + lastLocationUpdateTime = list.lastLocationUpdateTime + location = list.location + tripId = list.tripId + tripStatus = list.tripStatus + occupancyCapacity = list.occupancyCapacity + occupancyCount = list.occupancyCount + occupancyStatus = list.occupancyStatus + phase = list.phase + status = list.status + additionalProperties = list.additionalProperties.toMutableMap() } fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun lastUpdateTime(lastUpdateTime: Long) = lastUpdateTime(JsonField.of(lastUpdateTime)) - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -410,28 +433,20 @@ private constructor( fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { this.lastLocationUpdateTime = lastLocationUpdateTime } fun location(location: Location) = location(JsonField.of(location)) - @JsonProperty("location") - @ExcludeMissing fun location(location: JsonField) = apply { this.location = location } fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - @JsonProperty("tripId") - @ExcludeMissing fun tripId(tripId: JsonField) = apply { this.tripId = tripId } fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) - @JsonProperty("tripStatus") - @ExcludeMissing fun tripStatus(tripStatus: JsonField) = apply { this.tripStatus = tripStatus } @@ -439,8 +454,6 @@ private constructor( fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) - @JsonProperty("occupancyCapacity") - @ExcludeMissing fun occupancyCapacity(occupancyCapacity: JsonField) = apply { this.occupancyCapacity = occupancyCapacity } @@ -448,8 +461,6 @@ private constructor( fun occupancyCount(occupancyCount: Long) = occupancyCount(JsonField.of(occupancyCount)) - @JsonProperty("occupancyCount") - @ExcludeMissing fun occupancyCount(occupancyCount: JsonField) = apply { this.occupancyCount = occupancyCount } @@ -457,32 +468,25 @@ private constructor( fun occupancyStatus(occupancyStatus: String) = occupancyStatus(JsonField.of(occupancyStatus)) - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } fun phase(phase: String) = phase(JsonField.of(phase)) - @JsonProperty("phase") - @ExcludeMissing fun phase(phase: JsonField) = apply { this.phase = phase } fun status(status: String) = status(JsonField.of(status)) - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -490,6 +494,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): List = List( vehicleId, @@ -507,17 +519,20 @@ private constructor( ) } - @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect class Location + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) @@ -530,6 +545,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Location = apply { if (!validated) { lat() @@ -553,31 +570,26 @@ private constructor( @JvmSynthetic internal fun from(location: Location) = apply { - this.lat = location.lat - this.lon = location.lon - additionalProperties(location.additionalProperties) + lat = location.lat + lon = location.lon + additionalProperties = location.additionalProperties.toMutableMap() } fun lat(lat: Double) = lat(JsonField.of(lat)) - @JsonProperty("lat") - @ExcludeMissing fun lat(lat: JsonField) = apply { this.lat = lat } fun lon(lon: Double) = lon(JsonField.of(lon)) - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -585,6 +597,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Location = Location( lat, @@ -611,42 +631,96 @@ private constructor( "Location{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = TripStatus.Builder::class) @NoAutoDetect class TripStatus + @JsonCreator private constructor( - private val activeTripId: JsonField, - private val blockTripSequence: JsonField, - private val closestStop: JsonField, - private val closestStopTimeOffset: JsonField, - private val distanceAlongTrip: JsonField, - private val frequency: JsonField, - private val lastKnownDistanceAlongTrip: JsonField, - private val lastKnownLocation: JsonField, - private val lastKnownOrientation: JsonField, - private val lastLocationUpdateTime: JsonField, - private val lastUpdateTime: JsonField, - private val nextStop: JsonField, - private val nextStopTimeOffset: JsonField, - private val occupancyCapacity: JsonField, - private val occupancyCount: JsonField, - private val occupancyStatus: JsonField, - private val orientation: JsonField, - private val phase: JsonField, - private val position: JsonField, - private val predicted: JsonField, - private val scheduleDeviation: JsonField, - private val scheduledDistanceAlongTrip: JsonField, - private val serviceDate: JsonField, - private val situationIds: JsonField>, - private val status: JsonField, - private val totalDistanceAlongTrip: JsonField, - private val vehicleId: JsonField, - private val additionalProperties: Map, + @JsonProperty("activeTripId") + @ExcludeMissing + private val activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + private val blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + private val closestStop: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + private val distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + private val lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + private val occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + private val occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + private val scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = + JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Trip ID of the trip the vehicle is actively serving. */ fun activeTripId(): String = activeTripId.getRequired("activeTripId") @@ -901,6 +975,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): TripStatus = apply { if (!validated) { activeTripId() @@ -975,34 +1051,34 @@ private constructor( @JvmSynthetic internal fun from(tripStatus: TripStatus) = apply { - this.activeTripId = tripStatus.activeTripId - this.blockTripSequence = tripStatus.blockTripSequence - this.closestStop = tripStatus.closestStop - this.closestStopTimeOffset = tripStatus.closestStopTimeOffset - this.distanceAlongTrip = tripStatus.distanceAlongTrip - this.frequency = tripStatus.frequency - this.lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - this.lastKnownLocation = tripStatus.lastKnownLocation - this.lastKnownOrientation = tripStatus.lastKnownOrientation - this.lastLocationUpdateTime = tripStatus.lastLocationUpdateTime - this.lastUpdateTime = tripStatus.lastUpdateTime - this.nextStop = tripStatus.nextStop - this.nextStopTimeOffset = tripStatus.nextStopTimeOffset - this.occupancyCapacity = tripStatus.occupancyCapacity - this.occupancyCount = tripStatus.occupancyCount - this.occupancyStatus = tripStatus.occupancyStatus - this.orientation = tripStatus.orientation - this.phase = tripStatus.phase - this.position = tripStatus.position - this.predicted = tripStatus.predicted - this.scheduleDeviation = tripStatus.scheduleDeviation - this.scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip - this.serviceDate = tripStatus.serviceDate - this.situationIds = tripStatus.situationIds - this.status = tripStatus.status - this.totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip - this.vehicleId = tripStatus.vehicleId - additionalProperties(tripStatus.additionalProperties) + activeTripId = tripStatus.activeTripId + blockTripSequence = tripStatus.blockTripSequence + closestStop = tripStatus.closestStop + closestStopTimeOffset = tripStatus.closestStopTimeOffset + distanceAlongTrip = tripStatus.distanceAlongTrip + frequency = tripStatus.frequency + lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip + lastKnownLocation = tripStatus.lastKnownLocation + lastKnownOrientation = tripStatus.lastKnownOrientation + lastLocationUpdateTime = tripStatus.lastLocationUpdateTime + lastUpdateTime = tripStatus.lastUpdateTime + nextStop = tripStatus.nextStop + nextStopTimeOffset = tripStatus.nextStopTimeOffset + occupancyCapacity = tripStatus.occupancyCapacity + occupancyCount = tripStatus.occupancyCount + occupancyStatus = tripStatus.occupancyStatus + orientation = tripStatus.orientation + phase = tripStatus.phase + position = tripStatus.position + predicted = tripStatus.predicted + scheduleDeviation = tripStatus.scheduleDeviation + scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip + serviceDate = tripStatus.serviceDate + situationIds = tripStatus.situationIds + status = tripStatus.status + totalDistanceAlongTrip = tripStatus.totalDistanceAlongTrip + vehicleId = tripStatus.vehicleId + additionalProperties = tripStatus.additionalProperties.toMutableMap() } /** Trip ID of the trip the vehicle is actively serving. */ @@ -1010,8 +1086,6 @@ private constructor( activeTripId(JsonField.of(activeTripId)) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing fun activeTripId(activeTripId: JsonField) = apply { this.activeTripId = activeTripId } @@ -1021,8 +1095,6 @@ private constructor( blockTripSequence(JsonField.of(blockTripSequence)) /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing fun blockTripSequence(blockTripSequence: JsonField) = apply { this.blockTripSequence = blockTripSequence } @@ -1031,8 +1103,6 @@ private constructor( fun closestStop(closestStop: String) = closestStop(JsonField.of(closestStop)) /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing fun closestStop(closestStop: JsonField) = apply { this.closestStop = closestStop } @@ -1048,8 +1118,6 @@ private constructor( * Time offset from the closest stop to the current position of the transit * vehicle (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { this.closestStopTimeOffset = closestStopTimeOffset } @@ -1065,8 +1133,6 @@ private constructor( * Distance, in meters, the transit vehicle has progressed along the active * trip. */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { this.distanceAlongTrip = distanceAlongTrip } @@ -1075,8 +1141,6 @@ private constructor( fun frequency(frequency: String) = frequency(JsonField.of(frequency)) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -1092,8 +1156,6 @@ private constructor( * Last known distance along the trip received in real-time from the transit * vehicle. */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing fun lastKnownDistanceAlongTrip(lastKnownDistanceAlongTrip: JsonField) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip @@ -1104,8 +1166,6 @@ private constructor( lastKnownLocation(JsonField.of(lastKnownLocation)) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing fun lastKnownLocation(lastKnownLocation: JsonField) = apply { this.lastKnownLocation = lastKnownLocation } @@ -1119,8 +1179,6 @@ private constructor( /** * Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { this.lastKnownOrientation = lastKnownOrientation } @@ -1136,8 +1194,6 @@ private constructor( * Timestamp of the last known real-time location update from the transit * vehicle. */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { this.lastLocationUpdateTime = lastLocationUpdateTime } @@ -1147,8 +1203,6 @@ private constructor( lastUpdateTime(JsonField.of(lastUpdateTime)) /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing fun lastUpdateTime(lastUpdateTime: JsonField) = apply { this.lastUpdateTime = lastUpdateTime } @@ -1157,8 +1211,6 @@ private constructor( fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing fun nextStop(nextStop: JsonField) = apply { this.nextStop = nextStop } /** @@ -1172,8 +1224,6 @@ private constructor( * Time offset from the next stop to the current position of the transit vehicle * (in seconds). */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { this.nextStopTimeOffset = nextStopTimeOffset } @@ -1183,8 +1233,6 @@ private constructor( occupancyCapacity(JsonField.of(occupancyCapacity)) /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing fun occupancyCapacity(occupancyCapacity: JsonField) = apply { this.occupancyCapacity = occupancyCapacity } @@ -1194,8 +1242,6 @@ private constructor( occupancyCount(JsonField.of(occupancyCount)) /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing fun occupancyCount(occupancyCount: JsonField) = apply { this.occupancyCount = occupancyCount } @@ -1205,8 +1251,6 @@ private constructor( occupancyStatus(JsonField.of(occupancyStatus)) /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing fun occupancyStatus(occupancyStatus: JsonField) = apply { this.occupancyStatus = occupancyStatus } @@ -1215,8 +1259,6 @@ private constructor( fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing fun orientation(orientation: JsonField) = apply { this.orientation = orientation } @@ -1225,24 +1267,18 @@ private constructor( fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ - @JsonProperty("phase") - @ExcludeMissing fun phase(phase: JsonField) = apply { this.phase = phase } /** Current position of the transit vehicle. */ fun position(position: Position) = position(JsonField.of(position)) /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing fun predicted(predicted: JsonField) = apply { this.predicted = predicted } @@ -1258,8 +1294,6 @@ private constructor( * Deviation from the schedule in seconds (positive for late, negative for * early). */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing fun scheduleDeviation(scheduleDeviation: JsonField) = apply { this.scheduleDeviation = scheduleDeviation } @@ -1275,8 +1309,6 @@ private constructor( * Distance, in meters, the transit vehicle is scheduled to have progressed * along the active trip. */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip @@ -1292,8 +1324,6 @@ private constructor( * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") - @ExcludeMissing fun serviceDate(serviceDate: JsonField) = apply { this.serviceDate = serviceDate } @@ -1303,8 +1333,6 @@ private constructor( situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing fun situationIds(situationIds: JsonField>) = apply { this.situationIds = situationIds @@ -1314,8 +1342,6 @@ private constructor( fun status(status: String) = status(JsonField.of(status)) /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } /** Total length of the trip, in meters. */ @@ -1323,8 +1349,6 @@ private constructor( totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing fun totalDistanceAlongTrip(totalDistanceAlongTrip: JsonField) = apply { this.totalDistanceAlongTrip = totalDistanceAlongTrip } @@ -1333,20 +1357,17 @@ private constructor( fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1354,6 +1375,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): TripStatus = TripStatus( activeTripId, @@ -1388,17 +1417,20 @@ private constructor( } /** Last known location of the transit vehicle. */ - @JsonDeserialize(builder = LastKnownLocation.Builder::class) @NoAutoDetect class LastKnownLocation + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the last known location of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1415,6 +1447,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): LastKnownLocation = apply { if (!validated) { lat() @@ -1439,42 +1473,46 @@ private constructor( @JvmSynthetic internal fun from(lastKnownLocation: LastKnownLocation) = apply { - this.lat = lastKnownLocation.lat - this.lon = lastKnownLocation.lon - additionalProperties(lastKnownLocation.additionalProperties) + 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)) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): LastKnownLocation = LastKnownLocation( lat, @@ -1502,17 +1540,20 @@ private constructor( } /** Current position of the transit vehicle. */ - @JsonDeserialize(builder = Position.Builder::class) @NoAutoDetect class Position + @JsonCreator private constructor( - private val lat: JsonField, - private val lon: JsonField, - private val additionalProperties: Map, + @JsonProperty("lat") + @ExcludeMissing + private val lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + private val lon: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Latitude of the current position of the transit vehicle. */ fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) @@ -1529,6 +1570,8 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Position = apply { if (!validated) { lat() @@ -1553,42 +1596,45 @@ private constructor( @JvmSynthetic internal fun from(position: Position) = apply { - this.lat = position.lat - this.lon = position.lon - additionalProperties(position.additionalProperties) + 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)) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") - @ExcludeMissing 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)) /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") - @ExcludeMissing fun lon(lon: JsonField) = apply { this.lon = lon } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + 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) + } + fun build(): Position = Position( lat, diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt index b9a2bd0..7fea7da 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt @@ -3,7 +3,6 @@ package org.onebusaway.models import org.junit.jupiter.api.Test -import org.onebusaway.models.* class AgenciesWithCoverageListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt index ac27d2d..56d8a08 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class AgencyRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt index 83bf404..15676cb 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt @@ -6,14 +6,13 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ArrivalAndDepartureListParamsTest { @Test fun createArrivalAndDepartureListParams() { ArrivalAndDepartureListParams.builder() - .stopId("stopID") + .stopId("1_75403") .minutesAfter(0L) .minutesBefore(0L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -24,7 +23,7 @@ class ArrivalAndDepartureListParamsTest { fun getQueryParams() { val params = ArrivalAndDepartureListParams.builder() - .stopId("stopID") + .stopId("1_75403") .minutesAfter(0L) .minutesBefore(0L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -38,17 +37,17 @@ class ArrivalAndDepartureListParamsTest { @Test fun getQueryParamsWithoutOptionalFields() { - val params = ArrivalAndDepartureListParams.builder().stopId("stopID").build() + val params = ArrivalAndDepartureListParams.builder().stopId("1_75403").build() val expected = QueryParams.builder() assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = ArrivalAndDepartureListParams.builder().stopId("stopID").build() + val params = ArrivalAndDepartureListParams.builder().stopId("1_75403").build() assertThat(params).isNotNull // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") + assertThat(params.getPathParam(0)).isEqualTo("1_75403") // out-of-bound path param assertThat(params.getPathParam(1)).isEqualTo("") } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt index bc60d54..af85193 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt @@ -5,14 +5,13 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ArrivalAndDepartureRetrieveParamsTest { @Test fun createArrivalAndDepartureRetrieveParams() { ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") + .stopId("1_75403") .serviceDate(0L) .tripId("tripId") .stopSequence(0L) @@ -25,7 +24,7 @@ class ArrivalAndDepartureRetrieveParamsTest { fun getQueryParams() { val params = ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") + .stopId("1_75403") .serviceDate(0L) .tripId("tripId") .stopSequence(0L) @@ -45,7 +44,7 @@ class ArrivalAndDepartureRetrieveParamsTest { fun getQueryParamsWithoutOptionalFields() { val params = ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") + .stopId("1_75403") .serviceDate(0L) .tripId("tripId") .build() @@ -59,13 +58,13 @@ class ArrivalAndDepartureRetrieveParamsTest { fun getPathParam() { val params = ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") + .stopId("1_75403") .serviceDate(0L) .tripId("tripId") .build() assertThat(params).isNotNull // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") + assertThat(params.getPathParam(0)).isEqualTo("1_75403") // out-of-bound path param assertThat(params.getPathParam(1)).isEqualTo("") } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt index ce5a695..feb2888 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class BlockRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt index 2a94f4c..7d6183d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt @@ -3,7 +3,6 @@ package org.onebusaway.models import org.junit.jupiter.api.Test -import org.onebusaway.models.* class ConfigRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt index 673dba1..d8f5418 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt @@ -3,7 +3,6 @@ package org.onebusaway.models import org.junit.jupiter.api.Test -import org.onebusaway.models.* class CurrentTimeRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt index c976e33..9715973 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ReportProblemWithStopRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt index bfd0980..6c00abc 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ReportProblemWithTripRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt index ade68cb..27815d0 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class RouteIdsForAgencyListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt index 5af4c59..2648eee 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class RouteRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt index 798f270..25e5db1 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt @@ -4,21 +4,20 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class RoutesForAgencyListParamsTest { @Test fun createRoutesForAgencyListParams() { - RoutesForAgencyListParams.builder().agencyId("agencyID").build() + RoutesForAgencyListParams.builder().agencyId("40").build() } @Test fun getPathParam() { - val params = RoutesForAgencyListParams.builder().agencyId("agencyID").build() + val params = RoutesForAgencyListParams.builder().agencyId("40").build() assertThat(params).isNotNull // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + assertThat(params.getPathParam(0)).isEqualTo("40") // out-of-bound path param assertThat(params.getPathParam(1)).isEqualTo("") } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt index 2f0cce9..7ae2da5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class RoutesForLocationListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt index 0d0db68..ad74668 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt @@ -6,14 +6,13 @@ import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ScheduleForRouteRetrieveParamsTest { @Test fun createScheduleForRouteRetrieveParams() { ScheduleForRouteRetrieveParams.builder() - .routeId("routeID") + .routeId("1_100223") .date(LocalDate.parse("2019-12-27")) .build() } @@ -22,7 +21,7 @@ class ScheduleForRouteRetrieveParamsTest { fun getQueryParams() { val params = ScheduleForRouteRetrieveParams.builder() - .routeId("routeID") + .routeId("1_100223") .date(LocalDate.parse("2019-12-27")) .build() val expected = QueryParams.builder() @@ -32,17 +31,17 @@ class ScheduleForRouteRetrieveParamsTest { @Test fun getQueryParamsWithoutOptionalFields() { - val params = ScheduleForRouteRetrieveParams.builder().routeId("routeID").build() + val params = ScheduleForRouteRetrieveParams.builder().routeId("1_100223").build() val expected = QueryParams.builder() assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = ScheduleForRouteRetrieveParams.builder().routeId("routeID").build() + val params = ScheduleForRouteRetrieveParams.builder().routeId("1_100223").build() assertThat(params).isNotNull // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("routeID") + assertThat(params.getPathParam(0)).isEqualTo("1_100223") // out-of-bound path param assertThat(params.getPathParam(1)).isEqualTo("") } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt index 152488d..b70616d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt @@ -6,7 +6,6 @@ import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class ScheduleForStopRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt index e6c1118..d75e481 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class SearchForRouteListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt index 2ac9d86..368c33b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class SearchForStopListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt index 41e8572..be4ffff 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class ShapeRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt index f87b32a..67d9e2b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class StopIdsForAgencyListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt index 7fa9cd9..1c0577b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class StopRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt index 4559d12..9a74b02 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class StopsForAgencyListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt index 0f598fe..e0f8bf1 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class StopsForLocationListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt index 4a88cad..14c60aa 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class StopsForRouteListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt index 34626fe..e8d54bc 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripDetailRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt index 9f20cad..7ffc796 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripForVehicleRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt index 61d3ab0..0bc7f7f 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt @@ -4,7 +4,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.onebusaway.models.* class TripRetrieveParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt index 2b4ef9b..c4eb862 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripsForLocationListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt index e7ce7f6..43f6c77 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class TripsForRouteListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt index 3adc5c3..4797643 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt @@ -5,7 +5,6 @@ package org.onebusaway.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -import org.onebusaway.models.* class VehiclesForAgencyListParamsTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt index 728df53..1162b3b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt @@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.ok -import com.github.tomakehurst.wiremock.client.WireMock.put import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo @@ -18,7 +17,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.core.JsonString +import org.onebusaway.core.JsonValue import org.onebusaway.core.http.Headers import org.onebusaway.core.jsonMapper import org.onebusaway.errors.BadRequestException @@ -31,7 +30,9 @@ import org.onebusaway.errors.RateLimitException import org.onebusaway.errors.UnauthorizedException import org.onebusaway.errors.UnexpectedStatusCodeException import org.onebusaway.errors.UnprocessableEntityException -import org.onebusaway.models.* +import org.onebusaway.models.CurrentTimeRetrieveParams +import org.onebusaway.models.CurrentTimeRetrieveResponse +import org.onebusaway.models.References @WireMockTest class ErrorHandlingTest { @@ -39,7 +40,7 @@ class ErrorHandlingTest { private val JSON_MAPPER: JsonMapper = jsonMapper() private val ONEBUSAWAY_SDK_ERROR: OnebusawaySdkError = - OnebusawaySdkError.builder().putAdditionalProperty("key", JsonString.of("value")).build() + OnebusawaySdkError.builder().putAdditionalProperty("key", JsonValue.from("value")).build() private lateinit var client: OnebusawaySdkClient @@ -56,7 +57,186 @@ class ErrorHandlingTest { fun currentTimesRetrieve200() { val params = CurrentTimeRetrieveParams.builder().build() - val expected = CurrentTimeRetrieveResponse.builder().build() + val expected = + CurrentTimeRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + CurrentTimeRetrieveResponse.Data.builder() + .entry( + CurrentTimeRetrieveResponse.Data.Entry.builder() + .readableTime("readableTime") + .time(0L) + .build() + ) + .references( + References.builder() + .agencies( + listOf( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + ) + .routes( + listOf( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + ) + .situations( + listOf( + References.Situation.builder() + .id("id") + .creationTime(0L) + .activeWindows( + listOf( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + ) + .allAffects( + listOf( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + ) + .consequenceMessage("consequenceMessage") + .consequences( + listOf( + 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() + ) + .diversionStopIds(listOf("string")) + .build() + ) + .build() + ) + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .publicationWindows( + listOf( + 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() + ) + ) + .stops( + listOf( + References.Stop.builder() + .id("id") + .lat(0.0) + .lon(0.0) + .name("name") + .parent("parent") + .routeIds(listOf("string")) + .staticRouteIds(listOf("string")) + .code("code") + .direction("direction") + .locationType(0L) + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + ) + .stopTimes( + listOf( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + ) + .trips( + listOf( + 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() stubFor(get(anyUrl()).willReturn(ok().withBody(toJson(expected)))) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt index 519ab15..34c128c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt @@ -8,7 +8,6 @@ import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor import com.github.tomakehurst.wiremock.client.WireMock.ok -import com.github.tomakehurst.wiremock.client.WireMock.put import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo @@ -18,7 +17,9 @@ import org.junit.jupiter.api.Test import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient import org.onebusaway.core.jsonMapper -import org.onebusaway.models.* +import org.onebusaway.models.CurrentTimeRetrieveParams +import org.onebusaway.models.CurrentTimeRetrieveResponse +import org.onebusaway.models.References @WireMockTest class ServiceParamsTest { @@ -52,7 +53,186 @@ class ServiceParamsTest { .additionalQueryParams(additionalQueryParams) .build() - val apiResponse = CurrentTimeRetrieveResponse.builder().build() + val apiResponse = + CurrentTimeRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + CurrentTimeRetrieveResponse.Data.builder() + .entry( + CurrentTimeRetrieveResponse.Data.Entry.builder() + .readableTime("readableTime") + .time(0L) + .build() + ) + .references( + References.builder() + .agencies( + listOf( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + ) + .routes( + listOf( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + ) + .situations( + listOf( + References.Situation.builder() + .id("id") + .creationTime(0L) + .activeWindows( + listOf( + References.Situation.ActiveWindow.builder() + .from(0L) + .to(0L) + .build() + ) + ) + .allAffects( + listOf( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() + ) + ) + .consequenceMessage("consequenceMessage") + .consequences( + listOf( + 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() + ) + .diversionStopIds(listOf("string")) + .build() + ) + .build() + ) + ) + .description( + References.Situation.Description.builder() + .lang("lang") + .value("value") + .build() + ) + .publicationWindows( + listOf( + 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() + ) + ) + .stops( + listOf( + References.Stop.builder() + .id("id") + .lat(0.0) + .lon(0.0) + .name("name") + .parent("parent") + .routeIds(listOf("string")) + .staticRouteIds(listOf("string")) + .code("code") + .direction("direction") + .locationType(0L) + .wheelchairBoarding("wheelchairBoarding") + .build() + ) + ) + .stopTimes( + listOf( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + ) + .trips( + listOf( + 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() stubFor( get(anyUrl()) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt index 7b094a1..a4753b7 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.AgenciesWithCoverageListParams @ExtendWith(TestServerExtension::class) class AgenciesWithCoverageServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt index 0572732..63c9d69 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.AgencyRetrieveParams @ExtendWith(TestServerExtension::class) class AgencyServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt index 7517806..9e3e729 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt @@ -7,7 +7,8 @@ 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.* +import org.onebusaway.models.ArrivalAndDepartureListParams +import org.onebusaway.models.ArrivalAndDepartureRetrieveParams @ExtendWith(TestServerExtension::class) class ArrivalAndDepartureServiceTest { @@ -23,7 +24,7 @@ class ArrivalAndDepartureServiceTest { val arrivalAndDepartureRetrieveResponse = arrivalAndDepartureService.retrieve( ArrivalAndDepartureRetrieveParams.builder() - .stopId("stopID") + .stopId("1_75403") .serviceDate(0L) .tripId("tripId") .stopSequence(0L) @@ -45,7 +46,7 @@ class ArrivalAndDepartureServiceTest { val arrivalAndDepartureListResponse = arrivalAndDepartureService.list( ArrivalAndDepartureListParams.builder() - .stopId("stopID") + .stopId("1_75403") .minutesAfter(0L) .minutesBefore(0L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt index f6f35a3..14682c9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.BlockRetrieveParams @ExtendWith(TestServerExtension::class) class BlockServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt index bc5911c..70704a4 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.ConfigRetrieveParams @ExtendWith(TestServerExtension::class) class ConfigServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt index cdb4072..10b9f47 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.CurrentTimeRetrieveParams @ExtendWith(TestServerExtension::class) class CurrentTimeServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt index 5079042..3c67aff 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.ReportProblemWithStopRetrieveParams @ExtendWith(TestServerExtension::class) class ReportProblemWithStopServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt index 4603162..ae4a9fc 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.ReportProblemWithTripRetrieveParams @ExtendWith(TestServerExtension::class) class ReportProblemWithTripServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt index c3a7118..295d8b9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.RouteIdsForAgencyListParams @ExtendWith(TestServerExtension::class) class RouteIdsForAgencyServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt index 4047e42..26ff366 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.RouteRetrieveParams @ExtendWith(TestServerExtension::class) class RouteServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt index 4171539..873ce86 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.RoutesForAgencyListParams @ExtendWith(TestServerExtension::class) class RoutesForAgencyServiceTest { @@ -20,9 +20,7 @@ class RoutesForAgencyServiceTest { .build() val routesForAgencyService = client.routesForAgency() val routesForAgencyListResponse = - routesForAgencyService.list( - RoutesForAgencyListParams.builder().agencyId("agencyID").build() - ) + routesForAgencyService.list(RoutesForAgencyListParams.builder().agencyId("40").build()) println(routesForAgencyListResponse) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt index c98eb0f..f93bec8 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.RoutesForLocationListParams @ExtendWith(TestServerExtension::class) class RoutesForLocationServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt index f684ec5..c44474c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt @@ -7,7 +7,7 @@ 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.* +import org.onebusaway.models.ScheduleForRouteRetrieveParams @ExtendWith(TestServerExtension::class) class ScheduleForRouteServiceTest { @@ -23,7 +23,7 @@ class ScheduleForRouteServiceTest { val scheduleForRouteRetrieveResponse = scheduleForRouteService.retrieve( ScheduleForRouteRetrieveParams.builder() - .routeId("routeID") + .routeId("1_100223") .date(LocalDate.parse("2019-12-27")) .build() ) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt index 84fa8e0..95db8e9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt @@ -7,7 +7,7 @@ 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.* +import org.onebusaway.models.ScheduleForStopRetrieveParams @ExtendWith(TestServerExtension::class) class ScheduleForStopServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt index caa3906..ad95562 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.SearchForRouteListParams @ExtendWith(TestServerExtension::class) class SearchForRouteServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt index 0ef506a..3fcdb97 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.SearchForStopListParams @ExtendWith(TestServerExtension::class) class SearchForStopServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt index 25431d2..25f3dab 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.ShapeRetrieveParams @ExtendWith(TestServerExtension::class) class ShapeServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt index 143e7ce..5c32068 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.StopIdsForAgencyListParams @ExtendWith(TestServerExtension::class) class StopIdsForAgencyServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt index 898436b..191397a 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.StopRetrieveParams @ExtendWith(TestServerExtension::class) class StopServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt index 7cba930..c3a7cc9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.StopsForAgencyListParams @ExtendWith(TestServerExtension::class) class StopsForAgencyServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt index 197d75b..d56ef06 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.StopsForLocationListParams @ExtendWith(TestServerExtension::class) class StopsForLocationServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt index d5a42a4..a8ce387 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.StopsForRouteListParams @ExtendWith(TestServerExtension::class) class StopsForRouteServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt index fa12e4b..fbd85e5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.TripDetailRetrieveParams @ExtendWith(TestServerExtension::class) class TripDetailServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt index 7f6035c..5842671 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.TripForVehicleRetrieveParams @ExtendWith(TestServerExtension::class) class TripForVehicleServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt index ce7d73b..994e4b0 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.TripRetrieveParams @ExtendWith(TestServerExtension::class) class TripServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt index f83e638..9ceb3fb 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.TripsForLocationListParams @ExtendWith(TestServerExtension::class) class TripsForLocationServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt index 812ef98..afe7a9f 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.TripsForRouteListParams @ExtendWith(TestServerExtension::class) class TripsForRouteServiceTest { diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt index 701f148..36a099f 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt @@ -6,7 +6,7 @@ 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.* +import org.onebusaway.models.VehiclesForAgencyListParams @ExtendWith(TestServerExtension::class) class VehiclesForAgencyServiceTest { diff --git a/onebusaway-sdk-java-example/build.gradle.kts b/onebusaway-sdk-java-example/build.gradle.kts index 2245a97..a310e71 100644 --- a/onebusaway-sdk-java-example/build.gradle.kts +++ b/onebusaway-sdk-java-example/build.gradle.kts @@ -1,24 +1,18 @@ plugins { + id("onebusaway-sdk.kotlin") id("java") -} - -group = "org.onebusaway" -version = "0.1.0-alpha.4" - -repositories { - mavenCentral() + application } dependencies { - implementation(project(":onebusaway-sdk-java")) - implementation(project(mapOf("path" to ":onebusaway-sdk-java-core"))) - +} - testImplementation(platform("org.junit:junit-bom:5.9.1")) - testImplementation("org.junit.jupiter:junit-jupiter") +tasks.withType().configureEach { + // Allow using more modern APIs, like `List.of` and `Map.of`, in examples. + options.release.set(9) } -tasks.test { - useJUnitPlatform() -} \ No newline at end of file +application { + mainClass = "org.onebusaway.example.Main" +} diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java index c7986e5..5e8d626 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java @@ -7,8 +7,11 @@ public class AgenciesWithCoverage { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -19,10 +22,12 @@ public class AgenciesWithCoverage { public static void main(String[] args) { // Define the required Params - AgenciesWithCoverageListParams params = AgenciesWithCoverageListParams.builder().build(); + AgenciesWithCoverageListParams params = + AgenciesWithCoverageListParams.builder().build(); // Get the agencies with coverage - AgenciesWithCoverageListResponse agencies = client.agenciesWithCoverage().list(params); + AgenciesWithCoverageListResponse agencies = + client.agenciesWithCoverage().list(params); for (AgenciesWithCoverageListResponse.Data.List agency : agencies.data().list()) { System.out.println(agency); diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java index 24323c4..fd80deb 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java @@ -7,8 +7,11 @@ public class Agency { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,18 +19,18 @@ public class Agency { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { - // Define the agency ID - String agencyId = "1"; + // Define the agency ID + String agencyId = "1"; - // Define the parameters for the agency retrieval request - AgencyRetrieveParams params = AgencyRetrieveParams.builder().agencyId(agencyId).build(); + // Define the parameters for the agency retrieval request + AgencyRetrieveParams params = + AgencyRetrieveParams.builder().agencyId(agencyId).build(); - // Retrieve the agency information - AgencyRetrieveResponse agency = client.agency().retrieve(params); + // Retrieve the agency information + AgencyRetrieveResponse agency = client.agency().retrieve(params); - System.out.println(agency); + System.out.println(agency); } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java index 1797047..ec62a01 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java @@ -7,8 +7,11 @@ public class ArrivalAndDepartureForStop { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -32,8 +35,9 @@ public static void main(String[] args) { .serviceDate(serviceDate) // Use the Unix timestamp directly .build(); - // Retrieve arrival and departure information - ArrivalAndDepartureRetrieveResponse arrivalAndDepartureForStop = client.arrivalAndDeparture().retrieve(params); - System.out.println(arrivalAndDepartureForStop); + // Retrieve arrival and departure information + ArrivalAndDepartureRetrieveResponse arrivalAndDepartureForStop = + client.arrivalAndDeparture().retrieve(params); + System.out.println(arrivalAndDepartureForStop); } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java index 0646d70..5343f7d 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java @@ -3,11 +3,15 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.models.*; + public class ArrivalsAndDeparturesForStop { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -15,7 +19,6 @@ public class ArrivalsAndDeparturesForStop { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the stop ID @@ -31,11 +34,12 @@ public static void main(String[] args) { .build(); // Retrieve arrival and departure information - ArrivalAndDepartureListResponse arrivalsAndDeparturesForStop = client.arrivalAndDeparture().list(params); + ArrivalAndDepartureListResponse arrivalsAndDeparturesForStop = + client.arrivalAndDeparture().list(params); - for (ArrivalAndDepartureListResponse.Data.Entry.ArrivalsAndDeparture arrivalAndDeparture : arrivalsAndDeparturesForStop.data().entry().arrivalsAndDepartures()) { + for (ArrivalAndDepartureListResponse.Data.Entry.ArrivalsAndDeparture arrivalAndDeparture : + arrivalsAndDeparturesForStop.data().entry().arrivalsAndDepartures()) { System.out.println(arrivalAndDeparture); } } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java index 504088d..afc4611 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java @@ -4,11 +4,15 @@ import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.errors.OnebusawaySdkServiceException; import org.onebusaway.models.*; + public class Block { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,7 +20,6 @@ public class Block { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the block ID @@ -24,7 +27,8 @@ public static void main(String[] args) { try { // Define the parameters for the block retrieval request - BlockRetrieveParams params = BlockRetrieveParams.builder().blockId(blockId).build(); + BlockRetrieveParams params = + BlockRetrieveParams.builder().blockId(blockId).build(); // Retrieve the block information BlockRetrieveResponse block = client.block().retrieve(params); diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java index 4e8cbc0..db9bc4a 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java @@ -7,8 +7,11 @@ public class CurrentTime { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,7 +19,6 @@ public class CurrentTime { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the parameters for the current time retrieval request @@ -27,6 +29,4 @@ public static void main(String[] args) { System.out.println(currentTime); } - - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java index a5a3232..906af64 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java @@ -4,12 +4,14 @@ import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.models.*; - public class Route { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -17,23 +19,24 @@ public class Route { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { - // Define the route ID - String routeId = "1_100224"; + // Define the route ID + String routeId = "1_100224"; - try { + try { - RouteRetrieveParams params = org.onebusaway.models.RouteRetrieveParams.builder().routeId(routeId).build(); + RouteRetrieveParams params = org.onebusaway.models.RouteRetrieveParams.builder() + .routeId(routeId) + .build(); - RouteRetrieveResponse route = client.route().retrieve(params); + RouteRetrieveResponse route = client.route().retrieve(params); - System.out.println(route); + System.out.println(route); - } catch (org.onebusaway.errors.OnebusawaySdkServiceException e) { - System.err.println("Error occurred: " + e.getMessage()); - System.err.println("Status Code: " + e.statusCode()); - } + } catch (org.onebusaway.errors.OnebusawaySdkServiceException e) { + System.err.println("Error occurred: " + e.getMessage()); + System.err.println("Status Code: " + e.statusCode()); + } } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java index 06e9f4a..e34a32b 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java @@ -8,8 +8,11 @@ public class RouteForAgency { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -17,7 +20,6 @@ public class RouteForAgency { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { try { @@ -26,24 +28,22 @@ public static void main(String[] args) { String agencyId = "1"; // Create the parameters for the routes for agency list request - RoutesForAgencyListParams params = RoutesForAgencyListParams.builder() - .agencyId(agencyId) - .build(); + RoutesForAgencyListParams params = + RoutesForAgencyListParams.builder().agencyId(agencyId).build(); // Retrieve the routes for the agency - RoutesForAgencyListResponse routesForAgency = client.routesForAgency().list(params); + RoutesForAgencyListResponse routesForAgency = + client.routesForAgency().list(params); - for (RoutesForAgencyListResponse.Data.List route : routesForAgency.data().list()) { + for (RoutesForAgencyListResponse.Data.List route : + routesForAgency.data().list()) { System.out.println(route); } - } - catch (OnebusawaySdkServiceException e) { + } catch (OnebusawaySdkServiceException e) { System.err.println("Error occurred: " + e.getMessage()); System.err.println("Status Code: " + e.statusCode()); - } - catch (Exception e) { + } catch (Exception e) { System.err.println("Error occurred: " + e.getMessage()); } } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java index e5fcf33..bd5eb0e 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java @@ -7,8 +7,11 @@ public class RoutesForLocation { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,7 +19,6 @@ public class RoutesForLocation { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { try { @@ -33,15 +35,15 @@ public static void main(String[] args) { .build(); // Retrieve the routes for location - RoutesForLocationListResponse routesForLocation = client.routesForLocation().list(params); + RoutesForLocationListResponse routesForLocation = + client.routesForLocation().list(params); - for (RoutesForLocationListResponse.Data.List route : routesForLocation.data().list()) { + for (RoutesForLocationListResponse.Data.List route : + routesForLocation.data().list()) { System.out.println(route); } - } - catch (Exception e) { + } catch (Exception e) { System.err.println("Error occurred: " + e.getMessage()); } } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java index 6c755c1..cc0cc04 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java @@ -7,8 +7,11 @@ public class ScheduleForRoute { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -24,12 +27,12 @@ public static void main(String[] args) { try { // Define the parameters for the schedule for route request - ScheduleForRouteRetrieveParams params = ScheduleForRouteRetrieveParams.builder() - .routeId(routeId) - .build(); + ScheduleForRouteRetrieveParams params = + ScheduleForRouteRetrieveParams.builder().routeId(routeId).build(); // Retrieve the schedule for the route - ScheduleForRouteRetrieveResponse scheduleForRoute = client.scheduleForRoute().retrieve(params); + ScheduleForRouteRetrieveResponse scheduleForRoute = + client.scheduleForRoute().retrieve(params); System.out.println(scheduleForRoute); @@ -43,6 +46,5 @@ public static void main(String[] args) { catch (Exception e) { System.err.println("Error occurred: " + e.getMessage()); } - } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java index 476086a..a4d6840 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java @@ -7,8 +7,11 @@ public class SearchForRoute { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,19 +19,19 @@ public class SearchForRoute { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { - // Define the search input - String searchInput = "crysta"; - - // Create the parameters for the route search request - SearchForRouteListParams params = SearchForRouteListParams.builder().input(searchInput).build(); + // Define the search input + String searchInput = "crysta"; - // Retrieve the route search results - SearchForRouteListResponse searchForRouteListResponse = client.searchForRoute().list(params); + // Create the parameters for the route search request + SearchForRouteListParams params = + SearchForRouteListParams.builder().input(searchInput).build(); - System.out.println(searchForRouteListResponse); + // Retrieve the route search results + SearchForRouteListResponse searchForRouteListResponse = + client.searchForRoute().list(params); + System.out.println(searchForRouteListResponse); } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java index 2894aa9..cc8a08a 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java @@ -7,8 +7,11 @@ public class SearchForStop { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,19 +19,19 @@ public class SearchForStop { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the search input String searchInput = "crysta"; // Create the parameters for the stop search request - SearchForStopListParams params = SearchForStopListParams.builder().input(searchInput).build(); + SearchForStopListParams params = + SearchForStopListParams.builder().input(searchInput).build(); // Retrieve the stop search results - SearchForStopListResponse searchForStopListResponse = client.searchForStop().list(params); + SearchForStopListResponse searchForStopListResponse = + client.searchForStop().list(params); System.out.println(searchForStopListResponse); - } } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java index 9c8e4aa..a3971a2 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java @@ -7,28 +7,29 @@ public class Shape { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .apiKey(API_KEY) .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the shape ID String shapeId = "1_10002005"; // Define the parameters for the shape retrieval request - ShapeRetrieveParams params = ShapeRetrieveParams.builder().shapeId(shapeId).build(); + ShapeRetrieveParams params = + ShapeRetrieveParams.builder().shapeId(shapeId).build(); // Retrieve the shape information ShapeRetrieveResponse shape = client.shape().retrieve(params); System.out.println(shape.data()); } - - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java index 4f28923..352ab02 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java @@ -7,8 +7,11 @@ public class Stop { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -16,7 +19,6 @@ public class Stop { .baseUrl(BASE_URL) .build(); - public static void main(String[] args) { // Define the stop ID @@ -30,5 +32,4 @@ public static void main(String[] args) { System.out.println(stop); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java index 9238b18..8fb4045 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java @@ -1,18 +1,20 @@ package org.onebusaway.example; -import org.onebusaway.client.OnebusawaySdkClient; -import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; - import java.util.HashMap; import java.util.List; import java.util.Map; +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; +import org.onebusaway.models.*; public class StopsForLocation { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -56,14 +58,14 @@ public static void main(String[] args) { // For each stop, print associated routes for (String routeId : stop.routeIds()) { References.Route route = referenceMap.get(routeId); - if (route == null) continue; // Skip if route is not found + if (route == null) continue; // Skip if route is not found // Build a description for the route String routeDescription = buildRouteDescription(route); System.out.printf(" %s\n", routeDescription); } - System.out.println(); // Add a blank line between stops for clarity + System.out.println(); // Add a blank line between stops for clarity } } @@ -76,7 +78,7 @@ private static String buildRouteDescription(References.Route route) { // Append description if present route.description().ifPresent(desc -> { - if (!description.isEmpty()) { + if (description.length() > 0) { description.append(" - "); } description.append(desc); diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java index d103715..0819576 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java @@ -3,11 +3,15 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.models.*; + public class StopsForRoute { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -19,12 +23,12 @@ public static void main(String[] args) { // Define the route ID String routeId = "1_100229"; - StopsForRouteListParams params = StopsForRouteListParams.builder().routeId(routeId).build(); + StopsForRouteListParams params = + StopsForRouteListParams.builder().routeId(routeId).build(); // Get the stops for the route StopsForRouteListResponse stops = client.stopsForRoute().list(params); System.out.println(stops); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java index 134ab61..36b1795 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java @@ -7,8 +7,11 @@ public class StopsIdsForAgency { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -20,7 +23,8 @@ public static void main(String[] args) { // Define the agency ID String agencyId = "1"; - StopIdsForAgencyListParams params = StopIdsForAgencyListParams.builder().agencyId(agencyId).build(); + StopIdsForAgencyListParams params = + StopIdsForAgencyListParams.builder().agencyId(agencyId).build(); // Get the list of stop IDs for the agency StopIdsForAgencyListResponse stopIds = client.stopIdsForAgency().list(params); @@ -29,5 +33,4 @@ public static void main(String[] args) { System.out.println(stopId); } } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java index 90deb20..68f7c6d 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java @@ -7,8 +7,11 @@ public class Trip { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -22,14 +25,11 @@ public static void main(String[] args) { String tripId = "40_608344966"; // Create the parameters for the trip retrieve request - TripRetrieveParams params = TripRetrieveParams.builder() - .tripId(tripId) - .build(); + TripRetrieveParams params = TripRetrieveParams.builder().tripId(tripId).build(); // Retrieve the trip TripRetrieveResponse trip = client.trip().retrieve(params); System.out.println(trip); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java index 3dfba06..cbd86df 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java @@ -3,11 +3,15 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.models.*; + public class TripDetails { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -17,19 +21,16 @@ public class TripDetails { public static void main(String[] args) { - // Define the trip ID - String tripId = "40_608344966"; - - // Create the parameters for the trip details request - TripDetailRetrieveParams params = TripDetailRetrieveParams .builder() - .tripId(tripId) - .build(); + // Define the trip ID + String tripId = "40_608344966"; + // Create the parameters for the trip details request + TripDetailRetrieveParams params = + TripDetailRetrieveParams.builder().tripId(tripId).build(); - // Retrieve the trip details - TripDetailRetrieveResponse tripDetails = client.tripDetails().retrieve(params); + // Retrieve the trip details + TripDetailRetrieveResponse tripDetails = client.tripDetails().retrieve(params); - System.out.println(tripDetails); + System.out.println(tripDetails); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java index ae4a33d..d997a02 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java @@ -7,8 +7,11 @@ public class TripForVehicle { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -22,14 +25,12 @@ public static void main(String[] args) { String vehicleId = "1_3520"; // Retrieve the trip for the vehicle - TripForVehicleRetrieveParams params = TripForVehicleRetrieveParams.builder() - .vehicleId(vehicleId) - .build(); + TripForVehicleRetrieveParams params = + TripForVehicleRetrieveParams.builder().vehicleId(vehicleId).build(); // Retrieve the trip for the vehicle TripForVehicleRetrieveResponse tripForVehicle = client.tripForVehicle().retrieve(params); System.out.println(tripForVehicle); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java index 44c3ffb..886ee1e 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java @@ -7,8 +7,11 @@ public class TripsForRoute { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -20,12 +23,12 @@ public static void main(String[] args) { // Define the route ID String routeId = "1_100224"; - TripsForRouteListParams params = TripsForRouteListParams.builder().routeId(routeId).build(); + TripsForRouteListParams params = + TripsForRouteListParams.builder().routeId(routeId).build(); // Get the trips for the route TripsForRouteListResponse trips = client.tripsForRoute().list(params); System.out.println(trips); } - } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java index 6ed210f..0d40893 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java @@ -7,8 +7,11 @@ public class VehiclesForAgency { // Retrieve constants from environment variables or fallback to default values - static final String API_KEY = System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; - static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null ? System.getenv("ONEBUSAWAY_BASE_URL") : "https://api.pugetsound.onebusaway.org"; + static final String API_KEY = + System.getenv("ONEBUSAWAY_API_KEY") != null ? System.getenv("ONEBUSAWAY_API_KEY") : "TEST"; + static final String BASE_URL = System.getenv("ONEBUSAWAY_BASE_URL") != null + ? System.getenv("ONEBUSAWAY_BASE_URL") + : "https://api.pugetsound.onebusaway.org"; // Initialize the Onebusaway SDK client static final OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() @@ -20,12 +23,12 @@ public static void main(String[] args) { // Define the agency ID String agencyId = "1"; - VehiclesForAgencyListParams params = VehiclesForAgencyListParams.builder().agencyId(agencyId).build(); + VehiclesForAgencyListParams params = + VehiclesForAgencyListParams.builder().agencyId(agencyId).build(); // Get the vehicles for the agency VehiclesForAgencyListResponse vehicles = client.vehiclesForAgency().list(params); System.out.println(vehicles); } - } From a433a99937fdc1729f36a4e7d16a8d90137758e8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 06:58:34 +0000 Subject: [PATCH 05/11] chore(internal): codegen related update (#75) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 9e6f6ec..443d70c 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2024 Onebusaway SDK + Copyright 2025 Onebusaway SDK Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From a8f595e2ee1038f8161ab784fd189d074f375d07 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 06:57:31 +0000 Subject: [PATCH 06/11] chore(internal): codegen related update (#76) --- .../models/ArrivalAndDepartureListParams.kt | 3 +++ .../models/ReportProblemWithStopRetrieveParams.kt | 5 +++++ .../models/ReportProblemWithTripRetrieveParams.kt | 10 ++++++++++ .../models/ScheduleForRouteRetrieveParams.kt | 4 ++++ .../models/ScheduleForStopRetrieveParams.kt | 4 ++++ .../onebusaway/models/SearchForRouteListParams.kt | 2 ++ .../onebusaway/models/SearchForStopListParams.kt | 2 ++ .../onebusaway/models/StopsForLocationListParams.kt | 4 ++++ .../onebusaway/models/StopsForRouteListParams.kt | 2 ++ .../onebusaway/models/TripDetailRetrieveParams.kt | 7 +++++++ .../models/TripForVehicleRetrieveParams.kt | 13 +++++++++++++ .../onebusaway/models/TripsForLocationListParams.kt | 7 +++++++ .../onebusaway/models/TripsForRouteListParams.kt | 6 ++++++ .../models/VehiclesForAgencyListParams.kt | 1 + 14 files changed, 70 insertions(+) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt index b322956..f87d6db 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt @@ -22,10 +22,13 @@ constructor( fun stopId(): String = stopId + /** Include vehicles arriving or departing in the next n minutes. */ fun minutesAfter(): Optional = Optional.ofNullable(minutesAfter) + /** Include vehicles having arrived or departed in the previous n minutes. */ fun minutesBefore(): Optional = Optional.ofNullable(minutesBefore) + /** The specific time for querying the system status. */ fun time(): Optional = Optional.ofNullable(time) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt index f5ddb96..07dbe77 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt @@ -26,14 +26,19 @@ constructor( fun stopId(): String = stopId + /** A string code identifying the nature of the problem */ fun code(): Optional = Optional.ofNullable(code) + /** Additional comment text supplied by the user describing the problem */ fun userComment(): Optional = Optional.ofNullable(userComment) + /** The reporting user’s current latitude */ fun userLat(): Optional = Optional.ofNullable(userLat) + /** The reporting user’s location accuracy, in meters */ fun userLocationAccuracy(): Optional = Optional.ofNullable(userLocationAccuracy) + /** The reporting user’s current longitude */ fun userLon(): Optional = Optional.ofNullable(userLon) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt index 961bb1b..6d0e87a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt @@ -31,24 +31,34 @@ constructor( fun tripId(): String = tripId + /** A string code identifying the nature of the problem */ fun code(): Optional = Optional.ofNullable(code) + /** The service date of the trip */ fun serviceDate(): Optional = Optional.ofNullable(serviceDate) + /** A stop ID indicating where the user is experiencing the problem */ fun stopId(): Optional = Optional.ofNullable(stopId) + /** Additional comment text supplied by the user describing the problem */ fun userComment(): Optional = Optional.ofNullable(userComment) + /** The reporting user’s current latitude */ fun userLat(): Optional = Optional.ofNullable(userLat) + /** The reporting user’s location accuracy, in meters */ fun userLocationAccuracy(): Optional = Optional.ofNullable(userLocationAccuracy) + /** The reporting user’s current longitude */ fun userLon(): Optional = Optional.ofNullable(userLon) + /** Indicator if the user is on the transit vehicle experiencing the problem */ fun userOnVehicle(): Optional = Optional.ofNullable(userOnVehicle) + /** The vehicle number, as reported by the user */ fun userVehicleNumber(): Optional = Optional.ofNullable(userVehicleNumber) + /** The vehicle actively serving the trip */ fun vehicleId(): Optional = Optional.ofNullable(vehicleId) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt index 35954aa..daacc53 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt @@ -19,6 +19,10 @@ constructor( fun routeId(): String = routeId + /** + * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, + * defaults to current date) + */ fun date(): Optional = Optional.ofNullable(date) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt index cb6f935..f33d2c8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt @@ -19,6 +19,10 @@ constructor( fun stopId(): String = stopId + /** + * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, + * defaults to the current date) + */ fun date(): Optional = Optional.ofNullable(date) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt index 02347a2..e7084d4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt @@ -16,8 +16,10 @@ constructor( private val additionalQueryParams: QueryParams, ) { + /** The string to search for. */ fun input(): String = input + /** The max number of results to return. Defaults to 20. */ fun maxCount(): Optional = Optional.ofNullable(maxCount) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt index 55a6e79..5de1fb8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt @@ -16,8 +16,10 @@ constructor( private val additionalQueryParams: QueryParams, ) { + /** The string to search for. */ fun input(): String = input + /** The max number of results to return. Defaults to 20. */ fun maxCount(): Optional = Optional.ofNullable(maxCount) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt index 7b09c87..1da3e8f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt @@ -24,12 +24,16 @@ constructor( fun lon(): Double = lon + /** An alternative to radius to set the search bounding box (optional) */ fun latSpan(): Optional = Optional.ofNullable(latSpan) + /** An alternative to radius to set the search bounding box (optional) */ fun lonSpan(): Optional = Optional.ofNullable(lonSpan) + /** A search query string to filter the results */ fun query(): Optional = Optional.ofNullable(query) + /** The radius in meters to search within */ fun radius(): Optional = Optional.ofNullable(radius) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt index 4f2998a..7dcf9a4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt @@ -19,8 +19,10 @@ constructor( fun routeId(): String = routeId + /** Include polyline elements in the response (default true) */ fun includePolylines(): Optional = Optional.ofNullable(includePolylines) + /** Specify service date (YYYY-MM-DD or epoch) (default today) */ fun time(): Optional = Optional.ofNullable(time) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt index 4c7c3e3..d51762c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt @@ -22,14 +22,21 @@ constructor( fun tripId(): String = tripId + /** + * Whether to include the full schedule element in the tripDetails section (defaults to true). + */ fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) + /** Whether to include the full status element in the tripDetails section (defaults to true). */ fun includeStatus(): Optional = Optional.ofNullable(includeStatus) + /** Whether to include the full trip element in the references section (defaults to true). */ fun includeTrip(): Optional = Optional.ofNullable(includeTrip) + /** Service date for the trip as Unix time in milliseconds (optional). */ fun serviceDate(): Optional = Optional.ofNullable(serviceDate) + /** Time parameter to query the system at a specific time (optional). */ fun time(): Optional = Optional.ofNullable(time) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt index 57401e2..80e1fe0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt @@ -21,12 +21,25 @@ constructor( fun vehicleId(): String = vehicleId + /** + * Determines whether full element is included in the section. + * Defaults to false. + */ fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) + /** + * Determines whether the full element is included in the section. + * Defaults to true. + */ fun includeStatus(): Optional = Optional.ofNullable(includeStatus) + /** + * Determines whether full element is included in the section. Defaults to + * false. + */ fun includeTrip(): Optional = Optional.ofNullable(includeTrip) + /** Time parameter to query the system at a specific time (optional). */ fun time(): Optional = Optional.ofNullable(time) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt index e819ee8..90ed900 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt @@ -21,18 +21,25 @@ constructor( private val additionalQueryParams: QueryParams, ) { + /** The latitude coordinate of the search center */ fun lat(): Double = lat + /** Latitude span of the search bounding box */ fun latSpan(): Double = latSpan + /** The longitude coordinate of the search center */ fun lon(): Double = lon + /** Longitude span of the search bounding box */ fun lonSpan(): Double = lonSpan + /** Whether to include full schedule elements in the tripDetails section. Defaults to false. */ fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) + /** Whether to include full trip elements in the references section. Defaults to false. */ fun includeTrip(): Optional = Optional.ofNullable(includeTrip) + /** Specific time for the query. Defaults to the current time. */ fun time(): Optional = Optional.ofNullable(time) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt index 562eb3c..12d2d35 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt @@ -20,10 +20,16 @@ constructor( fun routeId(): String = routeId + /** Determine whether full schedule elements are included. Defaults to false. */ fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) + /** + * Determine whether full tripStatus elements with real-time information are included. Defaults + * to false. + */ fun includeStatus(): Optional = Optional.ofNullable(includeStatus) + /** Query the system at a specific time. Useful for testing. */ fun time(): Optional = Optional.ofNullable(time) fun _additionalHeaders(): Headers = additionalHeaders diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt index b7d39fa..959a68a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt @@ -18,6 +18,7 @@ constructor( fun agencyId(): String = agencyId + /** Specific time for querying the status (timestamp format) */ fun time(): Optional = Optional.ofNullable(time) fun _additionalHeaders(): Headers = additionalHeaders From 14ea7b7438268138410dca70f28807ec06f5c5b0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 12:05:36 +0000 Subject: [PATCH 07/11] chore(internal): codegen related update (#77) --- README.md | 62 +- build.gradle.kts | 6 - buildSrc/build.gradle.kts | 2 +- .../kotlin/onebusaway-sdk.java.gradle.kts | 4 - .../kotlin/onebusaway-sdk.kotlin.gradle.kts | 9 +- .../kotlin/onebusaway-sdk.publish.gradle.kts | 9 +- gradle/wrapper/gradle-wrapper.jar | Bin 43453 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 6 +- gradlew.bat | 2 + .../onebusaway/client/okhttp/OkHttpClient.kt | 113 +- .../okhttp/OnebusawaySdkOkHttpClient.kt | 3 +- .../okhttp/OnebusawaySdkOkHttpClientAsync.kt | 3 +- .../onebusaway/client/OnebusawaySdkClient.kt | 33 + .../client/OnebusawaySdkClientAsync.kt | 33 + .../client/OnebusawaySdkClientAsyncImpl.kt | 5 +- .../client/OnebusawaySdkClientImpl.kt | 5 +- .../main/kotlin/org/onebusaway/core/Check.kt | 29 + .../org/onebusaway/core/ClientOptions.kt | 31 +- .../main/kotlin/org/onebusaway/core/Params.kt | 16 + .../org/onebusaway/core/PrepareRequest.kt | 24 + .../org/onebusaway/core/RequestOptions.kt | 3 +- .../main/kotlin/org/onebusaway/core/Values.kt | 2 + .../org/onebusaway/core/http/Headers.kt | 2 +- .../org/onebusaway/core/http/HttpRequest.kt | 5 +- .../org/onebusaway/core/http/QueryParams.kt | 2 +- .../core/http/RetryingHttpClient.kt | 41 +- .../onebusaway/errors/OnebusawaySdkError.kt | 3 +- .../models/AgenciesWithCoverageListParams.kt | 16 +- .../AgenciesWithCoverageListResponse.kt | 157 +- .../onebusaway/models/AgencyRetrieveParams.kt | 16 +- .../models/AgencyRetrieveResponse.kt | 268 +-- .../models/ArrivalAndDepartureListParams.kt | 42 +- .../models/ArrivalAndDepartureListResponse.kt | 1869 +++++++++-------- .../ArrivalAndDepartureRetrieveParams.kt | 40 +- .../ArrivalAndDepartureRetrieveResponse.kt | 1733 +++++++-------- .../onebusaway/models/BlockRetrieveParams.kt | 16 +- .../models/BlockRetrieveResponse.kt | 533 +++-- .../onebusaway/models/ConfigRetrieveParams.kt | 13 +- .../models/ConfigRetrieveResponse.kt | 241 ++- .../models/CurrentTimeRetrieveParams.kt | 13 +- .../models/CurrentTimeRetrieveResponse.kt | 96 +- .../org/onebusaway/models/References.kt | 1377 +++++++----- .../ReportProblemWithStopRetrieveParams.kt | 92 +- .../ReportProblemWithTripRetrieveParams.kt | 128 +- .../org/onebusaway/models/ResponseWrapper.kt | 42 +- .../models/RouteIdsForAgencyListParams.kt | 16 +- .../models/RouteIdsForAgencyListResponse.kt | 106 +- .../onebusaway/models/RouteRetrieveParams.kt | 16 +- .../models/RouteRetrieveResponse.kt | 192 +- .../models/RoutesForAgencyListParams.kt | 16 +- .../models/RoutesForAgencyListResponse.kt | 223 +- .../models/RoutesForLocationListParams.kt | 44 +- .../models/RoutesForLocationListResponse.kt | 233 +- .../models/ScheduleForRouteRetrieveParams.kt | 25 +- .../ScheduleForRouteRetrieveResponse.kt | 898 +++++--- .../models/ScheduleForStopRetrieveParams.kt | 25 +- .../models/ScheduleForStopRetrieveResponse.kt | 527 +++-- .../models/SearchForRouteListParams.kt | 26 +- .../models/SearchForRouteListResponse.kt | 229 +- .../models/SearchForStopListParams.kt | 26 +- .../models/SearchForStopListResponse.kt | 312 +-- .../onebusaway/models/ShapeRetrieveParams.kt | 16 +- .../models/ShapeRetrieveResponse.kt | 132 +- .../models/StopIdsForAgencyListParams.kt | 16 +- .../models/StopIdsForAgencyListResponse.kt | 106 +- .../onebusaway/models/StopRetrieveParams.kt | 16 +- .../onebusaway/models/StopRetrieveResponse.kt | 276 ++- .../models/StopsForAgencyListParams.kt | 16 +- .../models/StopsForAgencyListResponse.kt | 315 +-- .../models/StopsForLocationListParams.kt | 51 +- .../models/StopsForLocationListResponse.kt | 340 +-- .../models/StopsForRouteListParams.kt | 33 +- .../models/StopsForRouteListResponse.kt | 338 ++- .../models/TripDetailRetrieveParams.kt | 80 +- .../models/TripDetailRetrieveResponse.kt | 1075 +++++----- .../models/TripForVehicleRetrieveParams.kt | 74 +- .../models/TripForVehicleRetrieveResponse.kt | 1075 +++++----- .../onebusaway/models/TripRetrieveParams.kt | 16 +- .../onebusaway/models/TripRetrieveResponse.kt | 220 +- .../models/TripsForLocationListParams.kt | 56 +- .../models/TripsForLocationListResponse.kt | 1129 +++++----- .../models/TripsForRouteListParams.kt | 52 +- .../models/TripsForRouteListResponse.kt | 1134 +++++----- .../models/VehiclesForAgencyListParams.kt | 22 +- .../models/VehiclesForAgencyListResponse.kt | 973 +++++---- .../AgenciesWithCoverageServiceAsyncImpl.kt | 27 +- .../services/async/AgencyServiceAsyncImpl.kt | 27 +- .../ArrivalAndDepartureServiceAsyncImpl.kt | 51 +- .../services/async/BlockServiceAsyncImpl.kt | 27 +- .../services/async/ConfigServiceAsyncImpl.kt | 27 +- .../async/CurrentTimeServiceAsyncImpl.kt | 27 +- .../ReportProblemWithStopServiceAsyncImpl.kt | 27 +- .../ReportProblemWithTripServiceAsyncImpl.kt | 27 +- .../RouteIdsForAgencyServiceAsyncImpl.kt | 27 +- .../services/async/RouteServiceAsyncImpl.kt | 27 +- .../async/RoutesForAgencyServiceAsyncImpl.kt | 27 +- .../RoutesForLocationServiceAsyncImpl.kt | 27 +- .../async/ScheduleForRouteServiceAsyncImpl.kt | 27 +- .../async/ScheduleForStopServiceAsyncImpl.kt | 27 +- .../async/SearchForRouteServiceAsyncImpl.kt | 27 +- .../async/SearchForStopServiceAsyncImpl.kt | 27 +- .../services/async/ShapeServiceAsyncImpl.kt | 27 +- .../async/StopIdsForAgencyServiceAsyncImpl.kt | 27 +- .../services/async/StopServiceAsyncImpl.kt | 27 +- .../async/StopsForAgencyServiceAsyncImpl.kt | 27 +- .../async/StopsForLocationServiceAsyncImpl.kt | 27 +- .../async/StopsForRouteServiceAsyncImpl.kt | 27 +- .../async/TripDetailServiceAsyncImpl.kt | 27 +- .../async/TripForVehicleServiceAsyncImpl.kt | 27 +- .../services/async/TripServiceAsyncImpl.kt | 27 +- .../async/TripsForLocationServiceAsyncImpl.kt | 27 +- .../async/TripsForRouteServiceAsyncImpl.kt | 27 +- .../VehiclesForAgencyServiceAsyncImpl.kt | 27 +- .../AgenciesWithCoverageServiceImpl.kt | 23 +- .../services/blocking/AgencyServiceImpl.kt | 23 +- .../ArrivalAndDepartureServiceImpl.kt | 43 +- .../services/blocking/BlockServiceImpl.kt | 23 +- .../services/blocking/ConfigServiceImpl.kt | 23 +- .../blocking/CurrentTimeServiceImpl.kt | 23 +- .../ReportProblemWithStopServiceImpl.kt | 23 +- .../ReportProblemWithTripServiceImpl.kt | 23 +- .../blocking/RouteIdsForAgencyServiceImpl.kt | 23 +- .../services/blocking/RouteServiceImpl.kt | 23 +- .../blocking/RoutesForAgencyServiceImpl.kt | 23 +- .../blocking/RoutesForLocationServiceImpl.kt | 23 +- .../blocking/ScheduleForRouteServiceImpl.kt | 23 +- .../blocking/ScheduleForStopServiceImpl.kt | 23 +- .../blocking/SearchForRouteServiceImpl.kt | 23 +- .../blocking/SearchForStopServiceImpl.kt | 23 +- .../services/blocking/ShapeServiceImpl.kt | 23 +- .../blocking/StopIdsForAgencyServiceImpl.kt | 23 +- .../services/blocking/StopServiceImpl.kt | 23 +- .../blocking/StopsForAgencyServiceImpl.kt | 23 +- .../blocking/StopsForLocationServiceImpl.kt | 23 +- .../blocking/StopsForRouteServiceImpl.kt | 23 +- .../blocking/TripDetailServiceImpl.kt | 23 +- .../blocking/TripForVehicleServiceImpl.kt | 23 +- .../services/blocking/TripServiceImpl.kt | 23 +- .../blocking/TripsForLocationServiceImpl.kt | 23 +- .../blocking/TripsForRouteServiceImpl.kt | 23 +- .../blocking/VehiclesForAgencyServiceImpl.kt | 23 +- .../core/http/RetryingHttpClientTest.kt | 139 +- .../onebusaway/core/http/SerializerTest.kt | 3 +- .../AgenciesWithCoverageListParamsTest.kt | 2 +- .../models/AgencyRetrieveParamsTest.kt | 2 +- .../ArrivalAndDepartureListParamsTest.kt | 10 +- .../ArrivalAndDepartureRetrieveParamsTest.kt | 10 +- .../models/BlockRetrieveParamsTest.kt | 2 +- .../models/ConfigRetrieveParamsTest.kt | 2 +- .../models/CurrentTimeRetrieveParamsTest.kt | 2 +- .../org/onebusaway/models/ReferencesTest.kt | 331 ++- ...ReportProblemWithStopRetrieveParamsTest.kt | 10 +- ...ReportProblemWithTripRetrieveParamsTest.kt | 10 +- .../models/RouteIdsForAgencyListParamsTest.kt | 2 +- .../models/RouteRetrieveParamsTest.kt | 2 +- .../models/RoutesForAgencyListParamsTest.kt | 2 +- .../models/RoutesForLocationListParamsTest.kt | 10 +- .../ScheduleForRouteRetrieveParamsTest.kt | 10 +- .../ScheduleForStopRetrieveParamsTest.kt | 10 +- .../models/SearchForRouteListParamsTest.kt | 10 +- .../models/SearchForStopListParamsTest.kt | 10 +- .../models/ShapeRetrieveParamsTest.kt | 2 +- .../models/StopIdsForAgencyListParamsTest.kt | 2 +- .../models/StopRetrieveParamsTest.kt | 2 +- .../models/StopsForAgencyListParamsTest.kt | 2 +- .../models/StopsForLocationListParamsTest.kt | 10 +- .../models/StopsForRouteListParamsTest.kt | 10 +- .../models/TripDetailRetrieveParamsTest.kt | 10 +- .../TripForVehicleRetrieveParamsTest.kt | 10 +- .../models/TripRetrieveParamsTest.kt | 2 +- .../models/TripsForLocationListParamsTest.kt | 10 +- .../models/TripsForRouteListParamsTest.kt | 10 +- .../models/VehiclesForAgencyListParamsTest.kt | 10 +- .../onebusaway/services/ErrorHandlingTest.kt | 272 ++- .../onebusaway/services/ServiceParamsTest.kt | 272 ++- 176 files changed, 11532 insertions(+), 8737 deletions(-) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Params.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PrepareRequest.kt diff --git a/README.md b/README.md index a9b8ed2..6224414 100644 --- a/README.md +++ b/README.md @@ -6,31 +6,25 @@ -The Onebusaway SDK Java SDK provides convenient access to the Onebusaway SDK REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property. +The Onebusaway SDK Java SDK provides convenient access to the Onebusaway SDK REST API from applications written in Java. The Onebusaway SDK Java SDK is similar to the Onebusaway SDK Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. It is generated with [Stainless](https://www.stainlessapi.com/). -## Documentation +The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). -The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). - ---- - -## Getting started - -### Install dependencies - -#### Gradle +## Installation +### Gradle + ```kotlin implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.23") ``` -#### Maven +### Maven ```xml @@ -42,6 +36,12 @@ implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.23") +## Requirements + +This library requires Java 8 or later. + +## Usage + ### Configure the client Use `OnebusawaySdkOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`: @@ -98,19 +98,7 @@ CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(params); To make a request to the Onebusaway SDK API, you generally build an instance of the appropriate `Params` class. -In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to the `retrieve` method of the `currentTime` service. - -Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using the `putAdditionalProperty` method. - -```java -import org.onebusaway.core.JsonValue; -import org.onebusaway.models.CurrentTimeRetrieveParams; - -CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder() - // ... normal properties - .putAdditionalProperty("secret_param", JsonValue.from("4242")) - .build(); -``` +See [Undocumented request params](#undocumented-request-params) for how to send arbitrary parameters. ## Responses @@ -238,18 +226,26 @@ This library is typed for convenient access to the documented API. If you need t ### Undocumented request params -To make requests using undocumented parameters, you can provide or override parameters on the params object while building it. +In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to the `retrieve` method of the `currentTime` service. + +Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using raw setters: ```java -FooCreateParams address = FooCreateParams.builder() - .id("my_id") - .putAdditionalProperty("secret_prop", JsonValue.from("hello")) +import org.onebusaway.core.JsonValue; +import org.onebusaway.models.CurrentTimeRetrieveParams; + +CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build(); ``` +You can also use the `putAdditionalProperty` method on nested headers, query params, or body objects. + ### Undocumented response properties -To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. +To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `res._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. ## Logging @@ -271,13 +267,9 @@ $ export ONEBUSAWAY_SDK_LOG=debug This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: -1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_. +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ 2. Changes that we do not expect to impact the vast majority of users in practice. We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. We are keen for your feedback; please open an [issue](https://www.github.com/OneBusAway/java-sdk/issues) with questions, bugs, or suggestions. - -## Requirements - -This library requires Java 8 or later. diff --git a/build.gradle.kts b/build.gradle.kts index 8c8ea48..6c2c685 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,4 @@ -plugins { - -} - allprojects { group = "org.onebusaway" version = "0.1.0-alpha.23" // x-release-please-version } - - diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 493cb32..8a1d7a1 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `kotlin-dsl` - kotlin("jvm") version "1.9.22" + kotlin("jvm") version "2.1.0" id("com.vanniktech.maven.publish") version "0.28.0" } diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts index 32a150e..a2c35b9 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts @@ -1,9 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar -import com.vanniktech.maven.publish.MavenPublishBaseExtension -import com.vanniktech.maven.publish.SonatypeHost plugins { `java-library` diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts index 6da1ac7..5eecc1c 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts @@ -1,6 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import com.vanniktech.maven.publish.* plugins { id("onebusaway-sdk.java") @@ -22,8 +21,12 @@ configure { tasks.withType().configureEach { kotlinOptions { - allWarningsAsErrors = true - freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=1.8") + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + "-Xsuppress-warning=DEPRECATION" + ) jvmTarget = "1.8" } } diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts index 4c6d7fa..457c5c2 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts @@ -1,10 +1,3 @@ -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.get -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost @@ -25,7 +18,7 @@ configure { signAllPublications() publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - this.coordinates(project.group.toString(), project.name, project.version.toString()) + coordinates(project.group.toString(), project.name, project.version.toString()) pom { name.set("OneBusAway") diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136f3d4ba8a0da8d277868979cfbc8ad796..a4b76b9530d66f5e68d973ea569d8e19de379189 100644 GIT binary patch delta 12612 zcmY+pRa6|n(lttO3GVLh?(Xh3xVuAe26uONcL=V5;I6?T_zdn2`Oi5I_gl9gx~lft zRjVKRp?B~8Wyrx5$mS3|py!Njy{0Wt4i%@s8v88pK z6fPNA45)|*9+*w5kcg$o)}2g}%JfXe6l9ig4T8ia3Hlw#3f^fAKW63%<~GZJd-0YA z9YjleCs~#Y?V+`#nr+49hhsr$K$k!lg}AZDw@>2j=f7t~5IW6#K|lAX7|^N}lJ)I!km`nrwx> z))1Es16__aXGVzQM0EC8xH+O!nqTFBg9Ci{NwRK*CP<6s`Gq(~#lqb(zOlh6ZDBK* zr$|NDj^s6VanrKa+QC;5>twePaexqRI%RO~OY075y?NN90I|f^(P# zF=b>fZ73b5JzD`#GC3lTQ_B3lMeBWgQUGYnFw*HQC}^z{$6G4j(n4y-pRxPT(d2Wgb%vCH(?+t&Pj z)QM`zc`U`+<~D+9E{4Uj2kc#*6eZMU$4Oj6QMfA^K!rbl`iBix=2sPrs7j@aqIrE zTaZJ2M09>rp$mgyUZ!r2$UK{+DGqgl`n;*qFF~M(r#eh`T{MO?2&j?xgr8FU$u3-` zhRDc_I23LL4)K&xg$^&l-W=!Jp-P(_Ie07q>Je;QLxi8LaEc%;WIacJD_T69egF?7 z;I_Sg_!+qrur8$Hq4grigaiVF>U7uWJ@Hkd&%kmFnQN-P^fq0gB1|uRt!U#X;DnlV zo?yHWTw7g5B;#xxY`adhi4yZn@f(7-Xa(J6S=#d@&rlFw!qfvholE>MEb|VWn^g}G zMSrK&zQ^vDId&ojL!{%{o7?s{7;{+u%L{|tar(gp?Uxq3p?xAysB>0E$eG#$tvkk9 z2Q2gEP17{U6@UD*v({5MP-CTZfvWMItVjb4c;i~WLq&{?Q1(koX&vt7+$z}10{^Id z{KDjGi0JpD7@;~odF__0m|p;5rIrHidOP9^mwKe#-&JX-X@acc)06G{LO1Wu)#gvZ za~y9(fhA%UwkDOVU1LBJ`0ROE z4&)dJKK%mG@+CIm?+wt9f~@xIMr8}UH*K1j| z0pppo{7gv3v{URwxVMeg>Ps!L5IKxm zjac2egjgb0vH5i75$s|sY_RYec#>faqJk|AGgV;v=^%BM(^p{p;(^SVt-88G9f!q; z>p}9E4^f0=01S2pQBE4}9YqE%TV)*hlU^8k9{&=K76+*Ax^r=AkBb%OCP^P2nm0Ri z;D-|Zk?gGeU<12ti2CnPVNA(Pb)02+r|&yTWW-OJO7 zNLb0pps6aN?A~NJp5kj{{IOlf!5KWMleV@-hYLift)D>-7K+tgs=7Ake}oBnIy-y1 z(Hn@Hjw=_(x>dO5ysQsrnE%A*bk0K<-j{1Yqz@#n#jOL^AzCr#wR|WYzqk6i7v)Lf zkXdKxzuu20aP{Tbg$(+9&oh7cd(Uoqqf<#ujb$q4sZ~gxFbQfS zS)kNklyL*{2AELgjZ(LBu*>S(oH5AaJ;YiB@;l@=O%F6B?oanzoYRM^fQ9-<~^=3$H0g^JPMLQo@SZ@QuNvy)tyJ)LSj`+()#fy?{aV4Yg^7dlQ7AQM^3GLCR2dAFR zJjtfKiVqF`l-H_fz0HD|9g>)pOxn}k!vdZ=DO!7Sikm{Z%P6BrRkBS6W?ZB5W&7rT z@uYpf@M@a!z7H&o@-yrcCL^Ff3e7p3T`R9p?@o-acXmbTSa0>ZANzCSgovsd%;i$| zVus`not!oL#(W`L-!9w0jdaECaG4hk{V7IOs676ZquZH~0TX5hDq|)x z6T497l|E?f4)LA>j=S8}b$0LS=I4h|hUFJYJODT8Li@#6kF$k0)@*l{RnM1HQ%?VT ze-Pqlc!~t(oumVC*?5fwR;P6u{tHaZ~*LlD;B)4f? z?lpWfa2P@)g57flVl83Ej%P`2)gGyaPjhvD(%i~{`2b>#3!+y&` z!2nuwHMFA-zUY}f1^0B8<`N)Gr=A4TS@b1qykmd0Pq{?r)+1^^+D(=xasb^Tf!oK9 zBLL+*p6M_#ufgLzgq1zcSwZsZnQWFLC3`Yxdg-2=*tT`J9nrfYt)RF)YryBf8_gW{ zvKbB+oZLehfT)S#<|y1)E0hW^?+AnqPXq9Hu;v3dsMGdr{SVyF63;K<8VcgI#~}1i zLYSBL0K;RTT(;>2x=*!1Di9w0mwr;`CN}kM65|Ay{~z}_^JKOsRaN<~#9O^iiW<5P zYN7r~HV!#Nz~IZU`P>1Xe%4f~K}KcF#X&5kO*G}-)74S*tQ8CietdPcA1Yl;S=Mr# z`#MYY!{s^uo=jn7;k6O%(}fN+*0cWMpt~#n9DR<3NyU?+3D^AgI}S)Cu-Tljg`VY} zX1=fq$?8$DtOeGxE6f8lbS_6Q3C4+LDTO$}_IpM$Xv<|QSC%+Oll^q$y`7o@jD{dp zNDl|&X)r7wETa-#h*d`KXntxI(Y{vLha{$0i7@G8xx^m=c<{lJ9?p-i!^W{%j7-oo z0W^SzZ^(Wkyz*We{lEn%Yhu-ycUOHtrRiVJL4~&S91*D0MrLu}Q>v-Mc?GcWfpyz% zX|UvcN@krFO#@v|CtYM}g|=L3%aMo$E5<@CM%c*;?u>LOTz00@+dt1{yg1y=$h+{|D17U}$*^fE^H&8b431EUE z<9tv0V_#%#&1N#j7AKCj!tTK@J%oFW*ESW<(#Gl#Xs%v<@AitI?s92nLzm<)w3Wkkom1f$gcdUi%g_*jofy&}N#luL<$GVIe{iQkQ)sIHVy zBgItnPBFamrv6Kb{eE($Q(f`ZPeW!Hm%Y@F*OF1sKB{Yy|C>WEv_mfvv-N-jh)B-5 z4a!1WcT@9a+hGaBrc~sz=>G?Q!*Zp^JFRUvBMyNR1;`)j$RhH$6gEyVKhd$&K-CFT zXaWC-Y=fyOnqT84iMn9o5oLEOI(_3fk!W^8-74|q1QhQ|CmT0i=b;6Z3u?E{p7V{? z;f#Q-33!L+4&QQcZ~GAqu$NS{M;u%`+#9=7^Oa5PKvCCCWNG_~l(CidS!+xr-*gg{ z$UQ`_1tLT_9jB=Hckkwu>G{s0b0F4bnR7GibmHo?>TR&<3?D;5Fb#gd8*wYa$$~ar z7epl1qM)L{kwiNjQk}?)CFpNTd?0wAOUZ|gC{Ub|c-7h~+Rm(JbdoRe!RNVBQi!M8 z+~U6E2X&KSA*T6KJvsqwqZl#1&==Dm(#b^&VAKQ>7ygv*Fyr;)q9*^F@dCTg2g!w~ z%hg)UXAUyIpIbLXJv1nZX+a_C)BOH2hUim|>=JHCRf(!dtTidb&*~I!JrfRe+PO>w z@ox$G2a3i9d_N9J=|2$y2m-P&#PTNwe!oLBZFs;z|F5kXvBDn<)WwE0E3$ow=zg3R zK(9;sf0t;VEV3@gAg7jRtnj%-6O@!Hvg*;XcUAw}!=2*aErvB(eQIm(-UGmq^J=XN zTqJo$Y|WKo^HlBF3BXJrA#}7ZLg=r*w`I*~Ix`o&2k8^(0mt8Rp=A>F`&gehhp@Jy z^e^#B2!~$LvNCKugg)8)-G%&THdk~kfextilegP9?#C#()F59U$&eo(h|5>ceo*Em z{PEE79T$YP|Kr7K`WBHbtQwyxFkCl6xX&+oUf90B5xoi3_5KHHCyEE*oPbOQkfMz& z6^hT8_NXd2iWk{q9IKae1{_7hMPH8I7_BMtVOM4 z6jm?E0QJOn$qrgsJ`9w##GB9?G})-GXSQo6(tYS(Q0-Ct$co?Zzl0?NHsDRron?;_ zZZgQg)%XW>P?8_&zoGuF(>Och2kEJXsu1_X&~w87x!b z>~h!a>e7{`p@+#hXF88wI*JeWRZ;J4ev4<}HWf|Z;(7$E!S5l9wzBHFe>^I{2`a;a)QnAwa2xv1e(bq$<}!8o^ofGvYpk7dBR+`*%iE;hUY5 zaHF}OjGO9r*{%lmcK^uFiTHgoUD`^9Nx@~;Bg!V* zuuJ&ti{DQiq7RyJAR94wem{}cPK1J(Yxnn_{=>?USqz-~&QXRStS^s-7TksZ$AEI! z#og36s3JGtGU{CnDHRFtipFqvrE*gw7_K@NN0h+ItTq@4fqN!HeQU1y7*X?9+IfZT4Vxebpt z%#VzgdDK~-&+=Z*#>=n#XUhNvBZp3=Cr41jMqwJkHLf3L7Vm~V#GgJ(Jpii~PmJ#s zA7Ft!{xD@z>9DUb4JbiUBdNEcU4BO$651iN*mp*f)HbRRM`Cx5cR?5IfEcU{IZWwf zz(M6CDv)>xa3x}K6%tP^i15P1&&DOLK=k~+jNR$UK3frSl+|PjSC-dBItvD~LL! z>_g(YYdO4k(5EbPOw+v+;G7~jYm>F@Ai|o`gs%F)F8tDz$dl7Q%aCe|v|$UkAul_R zNlA-beBX^IJU?kgS`E$it7nF4DaI!SJAGq)2P&Few(-|tp z?K+%D3e4{pfkayrcbm0ftu6Ol2ZzdKM+4i!hNP3NRL`EvvZJ3yvNr2MV%igZ4kj``Qrdb_OI$7jWP z;l0DYf&0(-*QcP5zrP`HVznW+SbH63Qx$7_9~NjRNg7eKqI!UJ=XH`g^=t8GiFTu( z?2L{JKEu%jJx&XjNzU(*!ZNmL1@RlJA0G$2_LrAb_7lmjil(GSlSM zwTes`m+3R;3#N~Xg#9owh3ycXV8@ZlaY_16kpPFA={721b~URO4HD3sp%fmkZM}k) zZB0#)kP=RkNB~R-MCk8aljG_bagt4vIb~8)BV%(b8_;)&Kf9GX+%O_cNG|(D$!3&D zL(I8}*LqN5NntipFlN13=`D>6!{D@CFMBH0kW3=HccJV+xW~|$qeFR5i-2{X+iWMu zI2$gepQ)H_B%ip_BlWOQ*|pErXs|4ir{IHccgaIJ84irE{?+$KDABXr&f`jB^V-c% z$$u`uU1YB^{<+UN2cNg#7&0bz@yF?5>j|;)5&IV3wIQp58X#OE-M^$HdyvL|Um5t? zhZlAG!Mz%XkUe3t471JM*Yur}o30vzu6RN7gJyNcf!IItsDO730mcJ*O!~V``y5=3 zNJGp34DZ}wd1H6V`Uuy%es>BiO_aE-S8jzir#$& zyk)@2a5tP$@g%jW^b^JGdo)X@Q%sE`^lDQmY9m%uDFpPX`w9%=yQ+nneMm#OaXcD` z9}{tn5A2b2z9783vL2_jSao?uxJhWJoq%47*RafM4o0@gY(p)F>qT4^XM5GLzV#6j zC+HoGhAne7o_w{WUo(B++z7lU3Y0k1rYv9|TSv0vR-Du(5=VakbbelgZTeDn+a_Wv zq_j-^+Qz1WAl;Zg>ahX|CERbX1V%B!hTKN?M}fGoA07M(WU&NfT&TmN`P@56U2 z^)vLDs|Ln~0iTtn-?KTeQl@T&bskJFuTUS!m+$CS9vnd}8(UMO|Kv6TCfGN9NUu&4 zL{)GTxPq>fwsJ~aU=4Qhuq8*RzDsP(LZh$BHezq&9gK$IS<|DYbm})$QTGCS6T;Dr zEkLct!b+#<1r9OKG@P!f1wm8>=Nz!7OzJm!g<+`?N3;YaA3(P@EL=(sTaRMDD!c8=-XN^4BXp(eVkj$NmEMYPP>YJ4bJ3yUud z<3BeJAJ$6z^TuywnfH5lv#$lgwraNw{IV=tIznPH1DT`v-5yS=!)J<}xxl}uZf9azA2A97Haf!;<3y01hlw?dWNEv@TLi1s-mO4vmIT%O_42nS z$VRWrs9NngqRRkWAnWkn%`Rw@?wH|)7XL`EL5EZu$qyJW31&CB^T_)qwIv!{;E_6 zo-9XAryQRlk-O0>o#-SZO>|6OYq;}<*>Wu1AsVRiXY4f8qb;+sItv3AyS!4Ry+q}) zA!pAB|BmC;=RIOk^^vlsEH(!Q!7_1FK~ZB2err*o!+b(r=m1b?$6d!%zmN+69LXnT z&gRmM+n_R-F@sT*IYv0_mGPvur!u`iWbQO7SqiGFLeY&yga zf`lM&B74FA2C?N@8_z652fjhBEoDUKbP8hL{0{HAF%qDo7)o3=3rg#6)T7%%5^wl% z9R0*S*<~>nzYOdQk2l`9h#t+gJy_xujw6xjV(8S<_DbVg61&pT%Hi42l%D73G?adn znB%UdNM0p}lEF-P2%TAMam2zpQev71e>a$$%i+r~b+D9G9pF|oY_*(-u*89oKsXLY+UIbqq)MQ%(GYS{(*n_S_*RN$*~`zUtab%0aKwhx znc)Yo?{xq1sJCgQD)TeTci1ucvbez9q=A72H(-SB18Kl&6^vHV8^i!p@>iF!DIw17 z+8Q)TNisB7>pwyww4y)yJx*wX6SJO78eLBC-ar1+k$Z9fy;wBD|3kzI{<+l*>PSY^ z_?nLOZaeWbU@C3hfK?X;Di*8CHCPkx2qco6(ZyJdqSzp^TJ_5Lpa0UP{Gy+!b0Lr% z@xYxSjUKoY6L#>$qx~KD$-0=|OF7zhVP~ntMgEALYPIfhj@+ z!;JJ7te>CcovruwHsJH6Lta$nm|%^C@=V-rmhU{+I~0(|XHQ9jt@L7pb{gx#{4r!) zg($FyFTslcgu(~6lYr$nW?)%*l#VJ=R-jxK(x=t1bWlu(nL66T#qj%3aZ@uVhy}Co zDU_q61DD5FqqJ*#c|(M5tV)XBN?Ac^12*q)VN4yKPJ|#==S_`_QD9|0ls!`2)SwuHDRA_OfXQDq3%qW&MZB}Z!=k-9xqev8jHz(H z{^D@cIB~QiK>~wa)A&^Ll^Wi6QgCzU;iv-BHsLBs zH7=jN%|>0S`SjP%M&AF1PNVDp_FZ?2Bm@7`DC&v(pYrw!!yD#4 z6+<=HS0Ln6MhoKxF<%~H`y20{vf#pxh=;j{zY381gvAFekgG|>G1zo8$&az{V=;JR zy_puF4$L$?EMhT?;TpQoR*j16ll`#AS4e96C}yp_aGKkBe?1H|k_;gG-~Xorc<;lI zkB}fB{$c-D2mGA&{rm<*@F5)c3X+6??g~XoEwuzSuch0D@W~P5(2I8v8F$c2$Vw51 zP#YLSBDqtWW^EYBl^QYHF+MA7am6f4DOhwnJM=W9$uvMOsZ%_~?)2C#wb?CkI$7{K zEi)=#|5pFvg^){zK5kpBLjB2kZ+$ZB|L=W|aNwyyb(gC2l7bcpx{E-H@)q6@D6N^xh`{1E%ItF2$eeB_SjI@b2WgTpS1thwg&n`jiIzw^TtXUyB{00($GIq>vbj|}bav}}Q_~wp3>k8!E@hVC;OMUTu|= zAy#vXH*GrUHu7^cNZWe1>y;2(51js9wbu+R3Aa*(wzH9+X0dIsf&gc_x|_LP z>~CF^?(~U}+l~ehe|i>?4eo!xkq&Lk+RR-1duNP#o~>@1x)s&i&u zRaYL@+D&_M|JLI6fHbEr_`U;HgPTh#E3?sB)A$*gqyBgg*ql|a-m*TX5rACbWKCE6 zdeQ`v8m6>g^ugv`p|HY^#1QZrGGUj0^HVDc@{?Q0yhalbBEV{+|HzC^-{&e{5K%z9 z6Bxtnfu1!@Mp+Q&*&~;FOg&*Vm<@4b;{FG0-!UUXX!|)1w}op!B_|7_s~d(+=9Gba zKp8`LaB4D(H=cGcspJ_TjYaOwMb=sGn^gtUVhK!UI~2KKYEE-NC}F>+BEY7IVvy%KRvm00tg!Q`y=er}wpEetX}K@;}(}{s9AzV#q2@ zBy7}->|N?13POrs`;U?(qAG(I$~Gt+Rgw%aNZ_0fs_utVvRJT-7z4!@x36v@=NBX=IqkK{#Kg0w48de@?#Yb4M(Svj5=T+<ONr8-oh7l?Cji@+erqur zFhZ=9|Lk=$`c}v4u`)-!!UI=!9Jo@h&7p4RlS#u! zZ7-prn75JkV?VjptX;@$#`U`{vB!=Z?V`T*FBF>J?vsML7e6@2GbUteMFfX-TUu{2 zLNIG*;dV)8GV8gAgEf#)X3A>p3^CRka1v?~8x^anBhQ=L=LsOl=&pcOYHo98m##ye z34MtGCDK!`ptl?taGMr5q{!zVc? zG00e){TV?`YA9eB;(lA3lXI?RrB4BYQGk?vOmTIUJED=(`_*gtn2DB-t4WW54as*W zb2kD-lWX>lb$+W!VFakki>B^Vc+u$?NLF>)!U%b@Y}gYJ>m2H=^x0=nsE0TF^Yu0h ztgH8-o1%+jCk(+&`|)tTfEVHq0cMeFa{Uz)X$;fCq%Y=SOWML6bYfeP8j5hktL`KK z(18`XrUn&WN9PtFxh&dX`y~YBsmdhi7Kw%tKzM%^VEhdD<_XkulW-x=JN6OPbFI4@ zzDDRN+f=@{0h*MswwOqG6gJ?{NuHx(y-|FUGsxyZ*x0~$MW(eY>vqq4Fh#t7uzw=- zKB?|!0N~!h^AMdLa)oR!Ca#HZ9&Zf)ghuO<^RN)4twRlygHnQG(BE{cDc5E}OF4;xss6gYyV~EcJvJkX)xNWb=@yw!uq0v-sf^rvkp-;?DPWK@*SEw|V;IH=7 zfQqEV_>DjOPT~8X*J|H8=&RnzK4~S7ML~nLX^%s-Vqc^aWy7N$y57qciZGcqy#=zU zs8hcHiI=D$+RB{|62{ohCTiaML6FI4Uhzo5D{Jik@poCs0w7F)*w}F4r0sJ~#u-72 z5bK=ANt=M$Dh5NKnxGsg9NRR?WD-x|FhTwBjd zD<-K>44DB~i%frJOfnzh1R>PRY34kw!6~p3M$JLaD1r@`=h)~Ngks-(gdXh^Q?BTP zZ^Zj5w1AwtuR2$~E7s9iZdF}z%pv1em^V2rM{1tLUY@-+Sc0(9jA|iZWml1;v13=U zHf?y@#mb--7z6$ue>`qjhE~brk$AY-RG90~5wcBbDReXR2)pKg{L>;H(DI`U!MLNQ zY9rFJP@ZQ}jlcMh%WSCo%vf+nd0Gmd*F%KMIe>slCUh)8Ma|;M_I+v#;|ueg9oLg; zq2HtZX%&#F7vdpNlkX?}(C7dGC^y#NB#m4%69RzTNrk%4ol~hSI%>2r6B|*ZkW(*P z;u#s;+faHo{tfy+1L^RzWDi*^JR0iY(zJDB36y_QJ+|E-2x+cY z!V8uLNktH~q>WQZuY!Ap66WP|E!0PA1jK~)^8oJVGbspJs6QL!!-5Qm7 zHYI|_`Actg?vDzdg5{86w@GS$G6ANzff7->6i5pB$T4O}`fZ_;{217Om0gN5zTr12 z5mW{hCzCE-QubjxN$TAE-XgI-8dTY@OZmq`y+y_>dk*(qXF0{nam|q@~i}Utp*k{yurq(DW54hkDT4bbg z=_etM?Nf5W^o-HEu9_?&xEqPg^P^mTxLH8n%u$!mWvFG|{&)jtnU&6|5-`~eaNz0%D1BDo`{ zS1N5(KW5v^2eLdd_%`uaRndF@h0Uo6=M|8?b~KbOLZk{HXEnGmtgZXf2inI*1r%n! zQ3&%RI4r{f&dwW~HwH0Ked9b!k6{>_19H z_Ai>5IChDMY(FfMyG%;30?SQ{iV9KyGru62+Y)~qSQ91}b~}w<&*}R&1c#$O`H@~c z5)2S_eXx}M#N{MuGeQS9@#UJB@;W_j50b}jIhxMPloEFQZdvwxiU^RYycTzgK)-vl3LT&$L8~@68$C8~5_U{cR$E#w*x65(qw&eoL@>%ZHvj zWnEMlSh*(o&oy|J7eJ5OD`ssy%F?*Vp?`Cq;FShyl{ZoKCG5g{y}>usznni#8ki(i zO{w@n{iAj1_ooX@+s*!uW60WcH~*bNOT6z%0jVML5};wVrQp~`Uss_{cO2oud_nNA8^B$?07fJ6?iI)Q zuo9G)O-z)DqstrBqf>B%S05hf-wep0@$BFHKSrkZ{za3D)yVzRz)2{wf8(Wp+xyAM z$rtyx$gi3A=V~V!`Q3;BM0$>*VVtxEM|xDL^gew7ydy3Q6YzD&THRz*q33Ms_D;M- zbCx1Ft#UNB)V3bf`~{ImI72OTp^|bF8?G8#FRj+Biy8ET5#rA3sd|0FR@U(LAJ%w8 zS1%n8Z=Amhw)92rIsof=YVWF4jw&F*j1LG@-`+cR0-~2LqXRH8(Ccne{y#MCPncF64U`0uO zWmi$dlii~1D0rLR{qc|_2M!C$t8^=G7xQY)9!#Y331A|>N)EhmyVdLWL9I3YLJ`7? zZmpqUJB>Ni9oiL)^1IK1UoMyhWE{$9M2M6Xi zPKk7GpMsA6vjZbU7~i+u|J6Nk|Ci!Y3UMUT2|`M;JsNQACdJ%ooo9Yt{?A+0hMpxi znEa~~sxC>rKrU6bd=WRb;%wsH>A#j4{({&1GYSNR57Gama(3)2A;SM>qop}l>Jk2* zn1+C$fIxuwzg3mCU#SOqb-wOCb6mBcYlA5+mt<&_J~sBxc(GQtBFINUO~Mr7<-uu($>P HJ4oML2Lo<@i8BwbL^1~GkG`E7C$SEa_ zF^}Ea+#Je`Xy6;#D0FPnSrR%Y!QGA~NA^{oWmW8C<3dr{x6wWQ{4+bzemqV5W$i5~ z=J0jXZ>uZb>DT@0Ks?4QJ{`z?8JWl3$y;2pj#$XP*pv$>$g(z43{YH9KmmR6<#sIn zA`#=0#sgycaBQ^&}Xba!|KaZ8~b30v~nLt z9%#gz_*=~KD{3t^X~l>480*}PhKN=??g`RV|4Ud{Gyyl187MJ}r(#e+H$GEdI+p1s zq_25h;fV)$EPK%Dw-(G=f`yHB-_tttsC!?k7*#!|4a>`Ahj8nm?&n>NRs%jkZW^3-0P_yMP5&*6a26{MRj1&TPF zyE#|c)5uUHzMWx=rMKpuPih*V=S;W3MzIZTw2uTbr}8`p2bm+Z6Sa%vvWAWSf4H)p(+ zSQ8;EvUa#wqWV+9vmIio(%7wukK2SwjUS8Yl%Rq%=~PU)2$Tvm6`1!r3H@U#_|bB0 zmlT1PS3wPB(b&^+@YY7Y$n4l3mV3-X0$>z|gZp6O*Lhzn&?Gad2ZCF;+#95-Y?#y+ z?*l@Yf=a4w{Px=o!N|3~_XKfk&G;fN>Ps&dp2FpA~qD=0~=!NOS@B#XAKKkND>Y{4>rqxrViKD7;?>j8`R` z&G)3FN|dfsxnaI^!d1G%=>AbTTxZWo;n-DLrQ!sj=f~VAOe5zhGS(dgx|!ls62fbX zV@<7Ck^!}R=`Swr?(7w1rY6Nmq~sfXJ?TiKJLn=&SQdEt9$@0 zA+h1Wbwbri0s-stc8yVq;mRa6@kEf8^KXUz&jcic!+avDvvJFa>k0ioWug=T3oPw; zyj4it&0@>_*uI@2=^+T7sL1_!^aJW@Xfo8aC#3^WtQC7fET8b9C} z*u^ue6Ojn z7@(eskJ2+cNnH9~VyfIh<-|7!je~vGy*odz(sk-u$~SrYF3glruZ*W`{sqnS+9=;Z zh{D@MSG91%lr&ua8%$sJF%y1I<|e;EdfJykY8#D$Hc_81n5`$7;1N|b0tvvPLzSg& zn7!5x?T*@rQUKcUhTIjV(rw*5oQYlm5DbEO?60#mohHfbR$3_x#+PZoYi@Vd4`#YgKyTd^!4n{fN~WZDY61sAOm6 zl!d^i*a01QxpWM9Pcl?&{RgO}uq%ErOk5WpECvnfEh!*YP&1Sl)uTN4hg??Vqs~i5 zYsfufz3?{TtwuBN=`0~Qg1PlWH#OGG$ zLLWU17$v``)CE1cds_7kj8mJ{-+l8{DS|zAQ&3|qpOY=!J|kXUhXue9|H>4gqk|n) z-i34GmxLFj8asb3D#D&=ya*a5`C<=o?G;Ev^LV%;l#nH#O=7Nh@z1Do>j6Q;I5S2P zhg|AZbC&|c7}uSJt57s2IK#rSWuararn-02dkptTjo*R{c5o(bWV}_k3BBnKcE|6l zrHl&ezUyw^DmaMdDFVn<8ZY=7_{u{uW&*F<7Al6};lD(u;SB=RpIwI)PTyL=e25h* zGi{lRT}snjbMK~IUx|EGonH+w;iC2Ws)x>=5_{5$m?K z5(*1jMn%u0V1Y%m@`YS3kskt~`1p(rA4uk;Cs!w^KL$w>MH)+cP6|XKr4FfHIATJH z!EGAK4N>1yFR`-zW|w%ByRe#=&kA&#WyUldDGpt!wf-8SFWiSi!5QZL+l7*CE?u!NW1T$<1rdLJ9y3u{_zvHaM?#Rm4 zFk}^1!ffcrB|XK3gsO-s=wr*sUe&^$yN|KxrA)uW00Gu60%pw_+DcUjW`oW<35OC8 zq2{j8SgC}W$?10pvFU83(SL$%C?Kctu3*cs0aa%q!fjn1%xD*Jrm!F3HGR9-C{b?- zHp(cL;ezXMpL@0-1v0DMWddSDNZ5h?q50cOZyVi#bU3&PWE=(hpVn|M4_KYG5h9LffKNRsfhr^=SYiKg?#r&HNMi2@cd4aYL9lw(5_IvQJ zcB*DD()hUSAD^PdA0y|QrVnqwgI@pUXZXjHq3lG2OU&7sPOxxU$Y3&ytj6Qb=2#cC z;{d-{k|xI*bu+Vy&N+}{i(+1me!M;nshY_*&ZQLTGG*xNw#{RpI`3^eGfHck+*38NRgiGahkFethtVY=czJs#)VVc{T65rhU#3Vf?X)8f0)X{w!J3J{z|Sq|%?)nA+zo?$>L9@o`Kc|*7sJo4UjIqu0Ir~S5k^vEH};6K?-dZ0h*m%-1L zf!VC%YbM1~sZOG5zu&Sh>R;(md*_)kGHP)<;OA44W?y53PI%{&@MEN}9TOiqu+1a3AGetBr$c)Ao3OX>iGxmA;^^_alwS818r4Pn&uYe^;z6dh z)68T|AN=hjNdGpF7n>y+RTAZc9&opTXf zqWfK_dUv=mW{p_vN>|(cIkd(+Jy}qnK{IW%X*3!l`^H~FbAHwof+vLZ0C2ZXN1$v7 zgN&R9c8IO`fkR{6U%ERq8FN<1DQYbAN0-pH7EfcA{A&nhT!Be>jj>J!bNRw4NF|}! z1c70_#fkk!VQ!q1h2ff@`yDyrI1`np>*e#D4-Z~*!T^8#o*$V~!8bWQaie?P@KGBb z8rXc!YDL!$3ZgZZ%;-%~0Kn<+d+{xJ$stQbtN8GWV?MCJvzPU|(E(1z;rFw{&6vy) z3*@y%7Tx8rH-p$boS>bLyod?OKRE8v`QSBvGfY6f}_{Zo1q85xoyOF16n~yHx2W ziydUoYLkJmzq|n&2S(O!ZmLdP1(o1Jsq88cX)x3V-BK5eF&0e_0G!5?U7&3KN0`mc zH&Lt)q8!d_VgzxyL^(@xrbp2y)Hmr^V48));RSfE=*Ly0uh9!$3dv-vMZr2URf@l5zdwLjGZB zugY>7_fd_vbV*Qv1?H~>Z%RD%nEeFSI$n$$Lrpc6g>i4+XdBB!%zM$Bhrz5Swzyg? z$~I~n@~-wTBY3-T&pr+|gC+OHDoR?I(eLWa{Z#Rsh>lc~%u0!&R|s0pA*w<7QZ}{i z*AFr~0F3y~f$MGh_HDL7J_1?SxKL}fWIk!$G}`^{)xh*dZ5kK>xGL9>V`WZZg_ z)^Vm)EQK`yfh5KiR(vb&aHvhich z_5o+{d~0+4BEBqYJXyXBIEb1UgVDs;a!N2$9WA>CbfrWryqT25)S4E4)QXBd*3jN} z?phkAt`1rKW?xoLzEm!*IfkH|P>BtECVr0l8-IGk_`UjE#IWkUGqvyS+dMrCnFl<7RCgSMX^qn|Ld_4iYRldO zY&cHhv)GDo8nKvKwAbfyLR%t?9gG?R7~PSD#4D-;?F&!kV59O}neYut5AGbKwy-(U zqyBi=&Mgj|VIo>$u!DHM`R7O?W8-idbePuxiJMH``6c_5L-chKd}=rGC5Gfrc{f!* zWFEBm?l@_b7kzY7%1RQQbG5V<4=ZlkZ%sF74Q|mKOc7Ak7dP2#quiGcZ0_J%7Q?j{ zv9{WFw;n5G-Mn%r#0R;{jLt{yy}9J6rQ(>X9pJ`7Xy?Zv z=lNit#qXaq?CnElK^zF~sG}U5oCpR0T>FH=ZX}Prju$);?;VOhFH8L3I><9P_A|C+ z{;>~dk%9rrq(snjsEm}oUz2FQ21MCG*e?g)?{!&|eg7PX@I+Q0!hL6C7ZVY|g2E>i zr!Ri2@OfEu$)d52+>+cpgh6Z;cLYCZ&EMR0i<^~4&wEu_bdo;y^6}+U2GIQgW$|Od z_jg{O=pU>0-H$P-EOlWyQy#W0r@@_uT}Lg+!d5NxMii7aT1=|qm6BRaWOf{Pws54v zTu=}LR!V(JzI07>QR;;px0+zq=(s+XH-0~rVbmGp8<)7G+Jf)UYs<$Dd>-K+4}CsD zS}KYLmkbRvjwBO3PB%2@j(vOpm)!JABH_E7X^f#V-bzifSaKtE)|QrczC1$sC<<*Y z$hY*3E10fYk`2W09gM_U<2>+r^+ro$Bqh-O7uSa)cfPE_<#^O) zF+5V;-8LaCLKdIh3UB@idQZL`0Vx8`OE#6*1<;8(zi&E7MWB1S%~HAm%axyIHN2vd zA(pJGm_PraB0Aat3~?obWBs?iSc*NhM!{-l_WNCx4@F7I?)5&oI|z{o@JKd1HZ}zf*#}JjK3$ z-;3V*WJZvUcKvSOBH4c7C{fl8oRw8-vfgKQjNiR|KhQ%k6hWNEke(k8w-Ro| z7Y3)FsY-?7%;VT64vRM)l0%&HI~BXkSAOV#F3Bf#|3QLZM%6C{paqLTb3MU-_)`{R zRdfVQ)uX90VCa3ja$8m;cdtxQ*(tNjIfVb%#TCJWeH?o4RY#LWpyZBJHR| z6G-!4W5O^Z8U}e5GfZ!_M{B``ve{r0Z#CXV0x@~X#Pc;}{{ClY_uw^=wWurj0RKnoFzeY` z;gS!PCLCo*c}-hLc?C&wv&>P1hH75=p#;D3{Q8UZ0ctX!b)_@Ur=WCMEuz>pTs$@s z#7bIutL9Pm2FDb~d+H}uBI#pu6R}T{nzpz9U0XLb9lu@=9bTY&PEyFwhHHtXFX~6C zrcg|qqTk(|MIM%KQ<@j=DOjt|V)+8K26wE_CBNnZTg+Z+s}AU|jp6CFoIptG1{J*# z7Ne~l;ba*=bSwAMQ|Vq#fW~+je4PXA91YFzBubNF?ovIOw-$C-8=Ehed{lGD0}(Id zRe4sh8L>&T%{>8o))he}eE;5_ zxoXk3wX?MyNl-xF!q1d$G?=wp^`@09(jU&X zOqZIBI#dN`2PJNdATR3ivtub|nO$dulSaP|e4)WXF1YAGN1pDQIbIjXFG!oC85Mt; zW$eteoL{y^5t4TMRwP$jNPjZFpGsWnGe=jMMqKtcZm9Y9PFZLi*1p@qoKKub^T@2+ zk$@*KYdQ?Z`}<%4ALwk*Yc{(WTf@#u;as(fvE^9{Gk)lWbJP*SjttWofV0s?AB({~l zZI1hZVWFT~W-T?nfMMcnCS4-#6H-MU7H$KxD;yaM46K4Kc@~Q>xzB+QnD_I`b_l3m zo9pRx46b!p?a^&zCDwygqqV3epjs(s0NQI6ARA1n!Yy-qduipxQ& zUAlqRpNjBS+y-ZheD(!R;F}&^V_}b_gqH%tVZ5%%ziO7k^w=es+wZtK^i*vmrWNLMs{oWu_CIov|s1raZiS)>38>pYu;i+-t zI_DiNe6aA4KTZ2P09qPj(0~K4nUq^0+f(2$g`229zkG4jLzRvJUWE0oF1XHL4t3UN zDH466G56sy9hTZoAJB!C3;@F;ONxEk5u6Mv%zdo}Rq`=* zw1n7MOhfNSV48TS989ArIcj`C%Gk8~93~u>)!Yt2b4ZriKj9x2d`H2HQNJ=I>hkDlcZn zqRj>!;oRMTIOu zx|Zfsu~v76T{z7AC(jxj^c@tnJHZtGPsq$DE!8kqvkDx5W?KUJPL+!Ffpwfa+|5z5 zKPCiOPqZZrAG;2%OH0T$W|`C@C*!Z`@Wkop{CTjB&Tk`+{XPnt`ND`Haz;xV`H^RS zyXYtw@WlqTvToi;=mq1<-|IQ(gcOpU%)b#_46|IuWL#4$oYLbqwuk6=Q@xZaJSKVF zZcHs~ZBl;&lF3=+nK; zF`4gSCeZXlwmC_t4I`#PUNQ*)Uv&oGxMALip|sxv^lyVV73tKI7)+QY5=tEMas{vTD-BaTJ^*Y6gq~PU;F5X!sxqiq$iFCo+Uv7m%1w((=e}Vf*=dtds|6 zbX}91!G?C*KG03eHoN}RZS9DJxa&8YwNCT8?JxMXyZqZr13NA|GB{+vG`08C{V(yy zf*Lw$+tYSU_+dI`3n{bMrPdDb`A=Mkg!O=k>1|*3MC8j~- zXL79J4E=U^H=iBLTeHE_OKzE&dws8RNynsSJ!d;`zK?P92U{f)xvD7VQVosrXZrL+ z6lMVdD1YgL;%(1cq{#bS6yXmp|DS@nax#AqqlZhtUQdh<^2vr5`EpAO

LGYq)sa(w9^3-f}NHy=GR4v%t2YZly3m1G@5y`xBh_HGrD%f z>;|Ty?9FiJAc&UVD(StT4I` zfVQwxhE9bXE6r2mKO8Ag7{L^jCyqQb0QqKDPE=RAgqn8q1O^>(z7h5kE(6va%QqRZ zkIOmp(})rLSS(2{=C12e&@!W2=Jel-^_R``0xHO^+t!(oXbcv5yhD4g*$t_F)_5Dl zSVCgesW%;DtYPCFs{G;GX_o?1J3;QQPPv)rWw;>} zJ&KwnUqwNXloNXlK_+pNDfI~hON#SokVJb&ilg8d7^NWo2ZQymCqQMnjfi>ePibjr z-Z@q!?RGN$Mj}Nk){X_vaj6?Mj$>ACR*z|6MsXy3VZ^PFn@yHkPo(>m(iWepn8SC@ z>D2;R4m+gDRZ=SIX!b+CP(qE=JDIUkn=D$aUu+Ihn9-+k1LS3PreQg0N5eWIG@x${nC3v^7caS>1!PKNAY9J z#}E}Q9w#SP>(GY7Hbj&z4$Li6o5taBO|4+F`yS9zq*LJ<38wy4I>HA9(&GYrk4dLajKGww))BWli6Ln1A^Lda@N~p+snkb9C z@OthI+<##vp8!HVQT4Wk(=@zQ{OvZ$EKWS73+JHb)eYLGD-cqi6^|vd$<+IHuc?Nq zW7JertT~3))4?J|28n$I@nAD0c1%9C&IVhEZX~mUsf{efyS(XNG%ch;!N~d7S(Ri7 zb&=BuON95aVA&kLn6&MVU|x}xPMp7xwWxNU1wS+F6#y}1@^wQZB*(&ecT?RnQcI}Y z2*z!^!D?gDUhc@;M^OpLs4mq>C&p{}OWVv<)S9KMars@0JQ{c_ScGsFo3BJ)Irg++ zAWwypJdTO-_{Uh8m(Z!3KL7K{ZZzKHj;{M8I$mV>k znTM?sa0);^=X^cglL`uC+^J)M7nEa$w=VwFULg~%DJllw+7dJAj3{qnP5i3@wr7%y zjXp?Wl2%Th=my&3u?Q$RV6N5tzKMSPTsc#J+-cDDp~qFB6bL2C8AS7Y3PKtVhdhl) zIaLqH5+OnWPWSt(lQCgkN8lczc-V%_iZ{>#1%Z$N*>lu#S;0MZ$T2Y8Kg!U;hAZj> z6S#%$DQ_`Ic%Zr@?}GgjRXg@qTj^17n`65oJ@Wj0u1X8&+UVd|Xs?J+i_^GZ94m6= zUc96~Q`OJvlKB_Lr15*Yw_PUPEr?f?H&00b^-W%26mD)(n(rGGNfK9~2h=C>p-7BZ zFd&*&Msdu{w~(eyFOglwCPH^Rb}O(N7LtS+nnEwDx*pGD?|&9Si~M43a+*L(b0$5A zv`T`(G3xO;I_sx;FwTP21ZlfDpz zOo?}Vlgf~fo{YWm@n_JyD*frOg{XsvBA~|Tn4V6hu>Gd>89-rblfVJUaGvj6X%NZ} z$tFF9sx=4_$*c~G`9iPLGh@=sV+O{D2-t*K@J7H=`V+oVt}8?04WwU3h1BgS!f%1P zFak-T#7`TtLcR=Yz>g0R!ZQrH!YiZOQN=_V-UyncN1Rc18?KY?#O`v#JK+pq0K$~H z3D@v9DZF42R)b9#BBX{^$DOMlJ!g)Gc za{o-1e%F6NvgKq9tC8pV+9S$;9*zNv{J*)n&dmf~anP1)4~N%~h#c(=B#3*KgzhCKhFdgDoWi2IDog{RVyzK|Y`rCUs3T~pJMmdZJy4?b z&s5G=zhf**(t7Y^oC_mcTsE-{^}wiaoUu&?kojLKs>SJPxjcP>{a5CbXCx92AcBE) zHtqP}LjZ{W>PH?Tu(E0X=%{PBMW@F_?#7b&#!^q`<-5$ur+-q6 z{dn=(^UZw6*3-XM_(=@<1_*i&XM4=0t5u!gm6 z{UlmNGPKgO_;e;q9|#esq~Sq`<}%d{+sRmhvsA{5i*91=tub>OZZ%)xUA#4q$dDyy z1`w4%?OPLg3JeZb#cqSMO?*Xn%|-FCcuH2i2fn_{IFusub6;NQdN|7TD1N?%E8*g? z$apAt@cEe!I%jB=*q$p_3=t_5R0ph%{qaq+QDg!c99Y!Xa!&oDZOeis_ot)gNXr{l zdY$|So2Qed2Y7KMNBrS^E169kG%h<+z{Z_p_;shB!uY)>yAVcK=&!bg`lVg)4T1|7 z0}7FpfydVH4F87K@c!nEG+WGKm{Ouo)Slpl;#qcEIQ0zdMfLA#;dBxYw;p;KoVv6| z3_D5&7rJdG12CnDSvZUW?$UC6^UVSW^|vw|o-_4bz)(w5(3AiVhpeT(|=f#x_}E?s#qHZF#xA6AF_ujl$G z-jHD%q(d2}v2PhXx&6YWps~m(^+RXl91Q#xRRJBhjKl$FG4bk);|ag;ieUZ&!Ii3$ z(iGz1+0m7#g5>ASldBbNZL=ZHh=tmmJt$!71; zIML2GhEz1pg@1rQN(M^_691wAGkJ@Pga_05WuQ6! zG5RkGY2^`@(H~pp7&Ga+Pwh3L!Njj!-rc;^bTIfo5hP@H##1X8xUZJckrx>id`bAd3QUx9GuomqBYZ!uN1-&o zvTxC?;p8vL67&fW8fw(YOqt>L@bdLrEF*3OgYe$4n4{ zEB40LiU#6-0@5jdN`0w}N0qi@c0~oT2FP z)LNk&a82my?jv(tQpiMi$TK_L@lub#lsM$R{Dk?Ya@%%%huZkct~tSWM714c!45k}-ZLVA-bVM`>|_ZBbW_m-7| z3U%xrAhi}n?T(2F{_n4EZ10inkIFl#y09?7$uwBoJgqY8vylwev)fDOn;>0R!aEnV zBz%j0Mqpx~EZU3q@%+oV7;}|vt7$~ou@faEIq{p?FY$XXg&6*K)b_LP=}gi9`Bij3 zN`zEo|B6*|-;>S`rNa^BKRDbDAk>X#MsR`EvL>6bqU@SaDDs z8>bu@3YdRaWs*Te@G-UHjU%F~kTHw5(0PVJ+pwh#ha2u;DB+UMo@A5UYIl#5rtBV- zGX_hIpw}3C@H*Us(Cc-d#-gNrG#w$(9+S=GxO>3SR`SE2fHZ2KrDc#_C^$jI>Y}#; zMwY=R6@+dWi~0RXw(c@3GZ&%~9K(q&ee0Zw;pwL`E_tZak-#8^_b)Dpyi73^he?xV zXJ08&wh5-M&}qy4f7!D&=E)puDD(Nmg1d_(j`4LvxM5x_huNg-pGG%9rYqO6mImyJ@}*3Y>^3OvcnTG%EV1) zq_Ap?Z!Iw__7#D=pOWnQN$gB!Mr0!9yx|g<4icJh{cFOu3B8}&RiYm+Mb;VEK``LK zL(NcpcTiGieOIssSjr?ob}^``nNf&UcJhXyncO9m{6gD$kqSD`S69(aF8dkWz5>!9 zBLe4Sib7Hs2x_L2Ls6Ish$MGVKrGt5+_2zCyP1byaCg3upo+-I}R4&$m)8 zQ7|jc1Z^VWggpuQj*cP;>Zo9LS!VSzrqmZczaf;u`d0J(f%Z9r%An@s!e>n9%y=n!IZ_tVGu{Jmsbp}Fk%HJIU?a+-~bjfLTuH|JExA8EROowzr zqW9{YyZhR0a4clRK>1I4Ncx&WER~{iE;F^$T7K%X@3PGOA%6#Z%p3TS^&M;Dnjw@i z^o!$9nhcsmcHcY4?4j9+ofL_CWsZ4Hcch(rjsGfGD(nsH>w}^ERqGnz%iGj0j{g}h z7wMkJ-2Z2~eS>2!i}0~B63i;>SyFJU2+>VCS^AxaDOx%g6-t0eM^P<3+*z`ztvOqrG3)&#$K?& z_Y0wbWID47@cU`E1A6A&!`aZk0ZE@z-h#l1NqX2#`$Uev2gepW`rf8*!=rD5&;Jb{ zl08rU>dPo=K%-1Ao1~G-@4ve~y5#9E8x;TE0k5d^TC(=Zc>mwjW^c=+U-<9}b0ku~}gj z3sbW>R2M6DR!g#NUP;nxo>)@7*=RP{U18SDop6b2&PHce^&h97@xx3t+VK+!keE#} z;(Uf&89as9k8{$nkLbuB!-d7TP`_VJpL^Xs8OKB~ri$YUbW8fch64}7|0EWoT(TRj{ z*GT<7Y<7DsrCi79ZsM)z#c(!nNOGySOCkY1fAuQOq12&iUVC!a`#O;dBLf=d?&4*B zI~LgAO7E0qxK(uRTM;IgJ}+z^gD+bi-6I!3x{r9`l~%8TRP%UE0V8E*Sz>Nl1NVG<<7(wDHZ+HcOkQm$O&k+vyx)y)x{Pz!U8hS$*m zByc0h6BUI*BOpuL==P+H|Hx%`>7!W+1H!l9vi&)`V zyn2o9{z=lc+VX*!Vh~SF=)L}Z40XeG>LF6cP^b+R$NxSeUqbK^Q*UTalKzP8X%{9@RSCXm_NhF>{=S2 zi}ezam_^P`S!!-cyEW9y7DBbK93roz@Raccy*v}?mKXScU9E_4g;hBU7}zSofAFda zKYEe?{{I54 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23..cea7a79 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..f3b75f3 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30d..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## 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 08b9c51..16d85ce 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 @@ -19,6 +19,7 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient import org.onebusaway.core.http.HttpMethod @@ -31,39 +32,11 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { - val clientBuilder = okHttpClient.newBuilder() - - // 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)) - } - - val timeout = requestOptions.timeout - if (timeout != null) { - clientBuilder - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) - } - - return clientBuilder.build() - } - override fun execute( request: HttpRequest, requestOptions: RequestOptions, ): HttpResponse { - val call = getClient(requestOptions).newCall(request.toRequest()) + val call = newCall(request, requestOptions) return try { call.execute().toResponse() @@ -82,18 +55,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } - val call = getClient(requestOptions).newCall(request.toRequest()) - call.enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(OnebusawaySdkIoException("Request failed", e)) + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(OnebusawaySdkIoException("Request failed", e)) + } } - } - ) + ) return future } @@ -104,10 +77,38 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val okHttpClient.cache?.close() } - private fun HttpRequest.toRequest(): Request { + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + val clientBuilder = okHttpClient.newBuilder() + + // 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)) + } + + val timeout = requestOptions.timeout + if (timeout != null) { + clientBuilder + .connectTimeout(timeout) + .readTimeout(timeout) + .writeTimeout(timeout) + .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + } + + val client = clientBuilder.build() + return client.newCall(request.toRequest(client)) + } + + private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { var body: RequestBody? = body?.toRequestBody() - // OkHttpClient always requires a request body for PUT and POST methods. - if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) { + if (body == null && requiresBody(method)) { body = "".toRequestBody() } @@ -116,9 +117,33 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val headers.values(name).forEach { builder.header(name, it) } } + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.header( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString() + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.header( + "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 { url?.let { return it @@ -172,7 +197,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var baseUrl: HttpUrl? = null // The default timeout is 1 minute. @@ -194,7 +219,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) .proxy(proxy) .build(), - checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }, + checkRequired("baseUrl", baseUrl), ) } } 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 dfb3f1b..807aa13 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 @@ -21,7 +21,8 @@ class OnebusawaySdkOkHttpClient private constructor() { @JvmStatic fun fromEnv(): OnebusawaySdkClient = builder().fromEnv().build() } - class Builder { + /** A builder for [OnebusawaySdkOkHttpClient]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL 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 37c60ab..6611264 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 @@ -21,7 +21,8 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { @JvmStatic fun fromEnv(): OnebusawaySdkClientAsync = builder().fromEnv().build() } - class Builder { + /** A builder for [OnebusawaySdkOkHttpClientAsync]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL 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 085a275..b09d68b 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 @@ -31,8 +31,28 @@ import org.onebusaway.services.blocking.TripsForLocationService import org.onebusaway.services.blocking.TripsForRouteService import org.onebusaway.services.blocking.VehiclesForAgencyService +/** + * A client for interacting with the Onebusaway SDK REST API synchronously. You can also switch to + * asynchronous execution via the [async] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ interface OnebusawaySdkClient { + /** + * Returns a version of this client that uses asynchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ fun async(): OnebusawaySdkClientAsync fun agenciesWithCoverage(): AgenciesWithCoverageService @@ -90,4 +110,17 @@ interface OnebusawaySdkClient { fun block(): BlockService fun shape(): ShapeService + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() } 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 d259172..aee0c2e 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 @@ -31,8 +31,28 @@ import org.onebusaway.services.async.TripsForLocationServiceAsync import org.onebusaway.services.async.TripsForRouteServiceAsync import org.onebusaway.services.async.VehiclesForAgencyServiceAsync +/** + * A client for interacting with the Onebusaway SDK REST API asynchronously. You can also switch to + * synchronous execution via the [sync] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ interface OnebusawaySdkClientAsync { + /** + * Returns a version of this client that uses synchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ fun sync(): OnebusawaySdkClient fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync @@ -90,4 +110,17 @@ interface OnebusawaySdkClientAsync { fun block(): BlockServiceAsync fun shape(): ShapeServiceAsync + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() } 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 b319d18..5c218c1 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 @@ -61,8 +61,7 @@ import org.onebusaway.services.async.TripsForRouteServiceAsyncImpl import org.onebusaway.services.async.VehiclesForAgencyServiceAsync import org.onebusaway.services.async.VehiclesForAgencyServiceAsyncImpl -class OnebusawaySdkClientAsyncImpl -constructor( +class OnebusawaySdkClientAsyncImpl( private val clientOptions: ClientOptions, ) : OnebusawaySdkClientAsync { @@ -242,4 +241,6 @@ constructor( override fun block(): BlockServiceAsync = block override fun shape(): ShapeServiceAsync = shape + + override fun close() = clientOptions.httpClient.close() } 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 f5665e9..bcc58db 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 @@ -61,8 +61,7 @@ import org.onebusaway.services.blocking.TripsForRouteServiceImpl import org.onebusaway.services.blocking.VehiclesForAgencyService import org.onebusaway.services.blocking.VehiclesForAgencyServiceImpl -class OnebusawaySdkClientImpl -constructor( +class OnebusawaySdkClientImpl( private val clientOptions: ClientOptions, ) : OnebusawaySdkClient { @@ -234,4 +233,6 @@ constructor( override fun block(): BlockService = block override fun shape(): ShapeService = shape + + override fun close() = clientOptions.httpClient.close() } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt new file mode 100644 index 0000000..b6fd22d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt @@ -0,0 +1,29 @@ +@file:JvmName("Check") + +package org.onebusaway.core + +fun checkRequired(name: String, value: T?): T = + checkNotNull(value) { "`$name` is required, but was not set" } + +@JvmSynthetic +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } + +@JvmSynthetic +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } + } 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 7f4054b..2e214a5 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 @@ -35,7 +35,8 @@ private constructor( @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } - class Builder { + /** A builder for [ClientOptions]. */ + class Builder internal constructor() { private var httpClient: HttpClient? = null private var jsonMapper: JsonMapper = jsonMapper() @@ -68,6 +69,14 @@ private constructor( fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } + fun headers(headers: Headers) = apply { this.headers.clear() putAllHeaders(headers) @@ -148,19 +157,11 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation - } - - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - - fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } - fun fromEnv() = apply { System.getenv("ONEBUSAWAY_API_KEY")?.let { apiKey(it) } } fun build(): ClientOptions { - checkNotNull(httpClient) { "`httpClient` is required but was not set" } - checkNotNull(apiKey) { "`apiKey` is required but was not set" } + val httpClient = checkRequired("httpClient", httpClient) + val apiKey = checkRequired("apiKey", apiKey) val headers = Headers.builder() val queryParams = QueryParams.builder() @@ -171,7 +172,7 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - apiKey?.let { + apiKey.let { if (!it.isEmpty()) { headers.put("key", it) } @@ -180,10 +181,10 @@ private constructor( queryParams.replaceAll(this.queryParams.build()) return ClientOptions( - httpClient!!, + httpClient, PhantomReachableClosingHttpClient( RetryingHttpClient.builder() - .httpClient(httpClient!!) + .httpClient(httpClient) .clock(clock) .maxRetries(maxRetries) .build() @@ -195,7 +196,7 @@ private constructor( queryParams.build(), responseValidation, maxRetries, - apiKey!!, + apiKey, ) } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Params.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Params.kt new file mode 100644 index 0000000..48d18a8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Params.kt @@ -0,0 +1,16 @@ +package org.onebusaway.core + +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** An interface representing parameters passed to a service method. */ +interface Params { + /** The full set of headers in the parameters, including both fixed and additional headers. */ + fun _headers(): Headers + + /** + * The full set of query params in the parameters, including both fixed and additional query + * params. + */ + fun _queryParams(): QueryParams +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PrepareRequest.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PrepareRequest.kt new file mode 100644 index 0000000..b78d6b6 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PrepareRequest.kt @@ -0,0 +1,24 @@ +@file:JvmName("PrepareRequest") + +package org.onebusaway.core + +import java.util.concurrent.CompletableFuture +import org.onebusaway.core.http.HttpRequest + +@JvmSynthetic +internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = + toBuilder() + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params._queryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params._headers()) + .build() + +@JvmSynthetic +internal fun HttpRequest.prepareAsync( + clientOptions: ClientOptions, + params: Params +): CompletableFuture = + // This async version exists to make it easier to add async specific preparation logic in the + // future. + CompletableFuture.completedFuture(prepare(clientOptions, params)) 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 ec2f645..653da53 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 @@ -23,7 +23,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { + private var responseValidation: Boolean? = null private var timeout: Duration? = null diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt index f5d6cde..387b30b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt @@ -119,6 +119,8 @@ sealed class JsonField { is JsonValue -> this } + @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + fun accept(visitor: Visitor): R = when (this) { is KnownValue -> visitor.visitKnown(value) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt index 1e17303..e6f6448 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt @@ -22,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = TreeMap(String.CASE_INSENSITIVE_ORDER) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt index f654c32..1b4396b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt @@ -1,5 +1,6 @@ package org.onebusaway.core.http +import org.onebusaway.core.checkRequired import org.onebusaway.core.toImmutable class HttpRequest @@ -21,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var method: HttpMethod? = null private var url: String? = null @@ -134,7 +135,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( - checkNotNull(method) { "`method` is required but was not set" }, + checkRequired("method", method), url, pathSegments.toImmutable(), headers.build(), diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt index a5e7ddf..1e9bbb7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt @@ -21,7 +21,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = mutableMapOf() private var size: Int = 0 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 fa4ed7a..eb4f5ed 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 @@ -17,6 +17,7 @@ import java.util.function.Function import kotlin.math.min import kotlin.math.pow import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.errors.OnebusawaySdkIoException class RetryingHttpClient @@ -56,15 +57,17 @@ private constructor( } response - } catch (t: Throwable) { - if (++retries > maxRetries || !shouldRetry(t)) { - throw t + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable } null } val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() Thread.sleep(backoffMillis.toMillis()) } } @@ -112,6 +115,8 @@ private constructor( } val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() return sleepAsync(backoffMillis.toMillis()).thenCompose { executeWithRetries(requestWithRetryCount, requestOptions) } @@ -223,27 +228,27 @@ private constructor( return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) } - private fun sleepAsync(millis: Long): CompletableFuture { - val future = CompletableFuture() - TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis - ) - return future - } - companion object { private val TIMER = Timer("RetryingHttpClient", true) + private fun sleepAsync(millis: Long): CompletableFuture { + val future = CompletableFuture() + TIMER.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + millis + ) + return future + } + @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var httpClient: HttpClient? = null private var clock: Clock = Clock.systemUTC() @@ -260,7 +265,7 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( - checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + checkRequired("httpClient", httpClient), clock, maxRetries, idempotencyHeader, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt index 2b12984..bf85359 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt @@ -30,7 +30,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [OnebusawaySdkError]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt index 4d859dc..ed0199c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt @@ -4,22 +4,27 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** + * Returns a list of all transit agencies currently supported by OneBusAway along with the center of + * their coverage area. + */ class AgenciesWithCoverageListParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -28,8 +33,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AgenciesWithCoverageListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt index 999e26c..b2224d0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt @@ -12,6 +12,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -41,15 +42,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -66,14 +67,16 @@ private constructor( private var validated: Boolean = false fun validate(): AgenciesWithCoverageListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -83,13 +86,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AgenciesWithCoverageListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -145,11 +149,11 @@ private constructor( fun build(): AgenciesWithCoverageListResponse = AgenciesWithCoverageListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -177,11 +181,17 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -190,12 +200,14 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -205,17 +217,18 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list + list = data.list.map { it.toMutableList() } references = data.references additionalProperties = data.additionalProperties.toMutableMap() } @@ -228,7 +241,22 @@ private constructor( fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun references(references: References) = references(JsonField.of(references)) @@ -257,9 +285,9 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, - references, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -297,15 +325,15 @@ private constructor( fun lonSpan(): Double = lonSpan.getRequired("lonSpan") - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - @JsonProperty("latSpan") @ExcludeMissing fun _latSpan() = latSpan + @JsonProperty("latSpan") @ExcludeMissing fun _latSpan(): JsonField = latSpan - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - @JsonProperty("lonSpan") @ExcludeMissing fun _lonSpan() = lonSpan + @JsonProperty("lonSpan") @ExcludeMissing fun _lonSpan(): JsonField = lonSpan @JsonAnyGetter @ExcludeMissing @@ -314,14 +342,16 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - agencyId() - lat() - latSpan() - lon() - lonSpan() - validated = true + if (validated) { + return@apply } + + agencyId() + lat() + latSpan() + lon() + lonSpan() + validated = true } fun toBuilder() = Builder().from(this) @@ -331,13 +361,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { - private var agencyId: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var latSpan: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var lonSpan: JsonField = JsonMissing.of() + private var agencyId: JsonField? = null + private var lat: JsonField? = null + private var latSpan: JsonField? = null + private var lon: JsonField? = null + private var lonSpan: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -394,11 +425,11 @@ private constructor( fun build(): List = List( - agencyId, - lat, - latSpan, - lon, - lonSpan, + checkRequired("agencyId", agencyId), + checkRequired("lat", lat), + checkRequired("latSpan", latSpan), + checkRequired("lon", lon), + checkRequired("lonSpan", lonSpan), additionalProperties.toImmutable(), ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt index 9958aee..3dbe375 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Retrieve information for a specific transit agency identified by its unique ID. */ class AgencyRetrieveParams -constructor( +private constructor( private val agencyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun agencyId(): String = agencyId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AgencyRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var agencyId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): AgencyRetrieveParams = AgencyRetrieveParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, + checkRequired("agencyId", agencyId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt index 599e05e..15b8791 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): AgencyRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AgencyRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): AgencyRetrieveResponse = AgencyRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -157,12 +161,12 @@ private constructor( class Data @JsonCreator private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("entry") @ExcludeMissing private val entry: JsonField = JsonMissing.of(), + @JsonProperty("limitExceeded") + @ExcludeMissing + private val limitExceeded: JsonField = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing private val references: JsonField = JsonMissing.of(), @@ -170,17 +174,21 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - fun entry(): Entry = entry.getRequired("entry") + fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") + fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -189,12 +197,14 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + limitExceeded() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -204,31 +214,32 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + 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 { - limitExceeded = data.limitExceeded entry = data.entry + limitExceeded = data.limitExceeded references = data.references additionalProperties = data.additionalProperties.toMutableMap() } + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + fun entry(entry: JsonField) = apply { this.entry = entry } + fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) fun limitExceeded(limitExceeded: JsonField) = apply { this.limitExceeded = limitExceeded } - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - fun references(references: References) = references(JsonField.of(references)) fun references(references: JsonField) = apply { @@ -256,9 +267,9 @@ private constructor( fun build(): Data = Data( - limitExceeded, - entry, - references, + checkRequired("entry", entry), + checkRequired("limitExceeded", limitExceeded), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -267,6 +278,18 @@ private constructor( class Entry @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + private val timezone: JsonField = JsonMissing.of(), + @JsonProperty("url") + @ExcludeMissing + private val url: JsonField = JsonMissing.of(), @JsonProperty("disclaimer") @ExcludeMissing private val disclaimer: JsonField = JsonMissing.of(), @@ -276,31 +299,27 @@ private constructor( @JsonProperty("fareUrl") @ExcludeMissing private val fareUrl: JsonField = JsonMissing.of(), - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), @JsonProperty("lang") @ExcludeMissing private val lang: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), @JsonProperty("phone") @ExcludeMissing private val phone: JsonField = JsonMissing.of(), @JsonProperty("privateService") @ExcludeMissing private val privateService: JsonField = JsonMissing.of(), - @JsonProperty("timezone") - @ExcludeMissing - private val timezone: JsonField = JsonMissing.of(), - @JsonProperty("url") - @ExcludeMissing - private val url: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + + fun name(): String = name.getRequired("name") + + fun timezone(): String = timezone.getRequired("timezone") + + fun url(): String = url.getRequired("url") + fun disclaimer(): Optional = Optional.ofNullable(disclaimer.getNullable("disclaimer")) @@ -308,40 +327,36 @@ private constructor( fun fareUrl(): Optional = Optional.ofNullable(fareUrl.getNullable("fareUrl")) - fun id(): String = id.getRequired("id") - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - fun name(): String = name.getRequired("name") - fun phone(): Optional = Optional.ofNullable(phone.getNullable("phone")) fun privateService(): Optional = Optional.ofNullable(privateService.getNullable("privateService")) - fun timezone(): String = timezone.getRequired("timezone") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun url(): String = url.getRequired("url") - - @JsonProperty("disclaimer") @ExcludeMissing fun _disclaimer() = disclaimer + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone - @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl() = fareUrl + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang + @JsonProperty("disclaimer") + @ExcludeMissing + fun _disclaimer(): JsonField = disclaimer - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - @JsonProperty("phone") @ExcludeMissing fun _phone() = phone + @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl(): JsonField = fareUrl - @JsonProperty("privateService") @ExcludeMissing fun _privateService() = privateService + @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang - @JsonProperty("timezone") @ExcludeMissing fun _timezone() = timezone + @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("privateService") + @ExcludeMissing + fun _privateService(): JsonField = privateService @JsonAnyGetter @ExcludeMissing @@ -350,19 +365,21 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - disclaimer() - email() - fareUrl() - id() - lang() - name() - phone() - privateService() - timezone() - url() - validated = true + if (validated) { + return@apply } + + id() + name() + timezone() + url() + disclaimer() + email() + fareUrl() + lang() + phone() + privateService() + validated = true } fun toBuilder() = Builder().from(this) @@ -372,35 +389,52 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var name: JsonField? = null + private var timezone: JsonField? = null + private var url: JsonField? = null private var disclaimer: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() private var fareUrl: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var lang: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() private var phone: JsonField = JsonMissing.of() private var privateService: JsonField = JsonMissing.of() - private var timezone: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { + id = entry.id + name = entry.name + timezone = entry.timezone + url = entry.url disclaimer = entry.disclaimer email = entry.email fareUrl = entry.fareUrl - id = entry.id lang = entry.lang - name = entry.name phone = entry.phone privateService = entry.privateService - timezone = entry.timezone - url = entry.url additionalProperties = entry.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + + fun url(url: String) = url(JsonField.of(url)) + + fun url(url: JsonField) = apply { this.url = url } + fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) fun disclaimer(disclaimer: JsonField) = apply { @@ -415,18 +449,10 @@ private constructor( fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun lang(lang: String) = lang(JsonField.of(lang)) fun lang(lang: JsonField) = apply { this.lang = lang } - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - fun phone(phone: String) = phone(JsonField.of(phone)) fun phone(phone: JsonField) = apply { this.phone = phone } @@ -438,14 +464,6 @@ private constructor( this.privateService = privateService } - fun timezone(timezone: String) = timezone(JsonField.of(timezone)) - - fun timezone(timezone: JsonField) = apply { this.timezone = timezone } - - fun url(url: String) = url(JsonField.of(url)) - - fun url(url: JsonField) = apply { this.url = url } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -470,16 +488,16 @@ private constructor( fun build(): Entry = Entry( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("timezone", timezone), + checkRequired("url", url), disclaimer, email, fareUrl, - id, lang, - name, phone, privateService, - timezone, - url, additionalProperties.toImmutable(), ) } @@ -489,17 +507,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && id == other.id && lang == other.lang && name == other.name && phone == other.phone && privateService == other.privateService && timezone == other.timezone && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && id == other.id && name == other.name && timezone == other.timezone && url == other.url && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && lang == other.lang && phone == other.phone && privateService == other.privateService && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(disclaimer, email, fareUrl, id, lang, name, phone, privateService, timezone, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, timezone, url, disclaimer, email, fareUrl, lang, phone, privateService, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, id=$id, lang=$lang, name=$name, phone=$phone, privateService=$privateService, timezone=$timezone, url=$url, additionalProperties=$additionalProperties}" + "Entry{id=$id, name=$name, timezone=$timezone, url=$url, disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, lang=$lang, phone=$phone, privateService=$privateService, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -507,17 +525,17 @@ private constructor( return true } - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && entry == other.entry && limitExceeded == other.limitExceeded && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, entry, references, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(entry, limitExceeded, references, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, entry=$entry, references=$references, additionalProperties=$additionalProperties}" + "Data{entry=$entry, limitExceeded=$limitExceeded, references=$references, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt index f87d6db..8264ee2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt @@ -7,18 +7,21 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** arrivals-and-departures-for-stop */ class ArrivalAndDepartureListParams -constructor( +private constructor( private val stopId: String, private val minutesAfter: Long?, private val minutesBefore: Long?, private val time: OffsetDateTime?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun stopId(): String = stopId @@ -35,10 +38,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.minutesAfter?.let { queryParams.put("minutesAfter", listOf(it.toString())) } this.minutesBefore?.let { queryParams.put("minutesBefore", listOf(it.toString())) } @@ -63,8 +65,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ArrivalAndDepartureListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var stopId: String? = null private var minutesAfter: Long? = null @@ -86,13 +89,32 @@ constructor( fun stopId(stopId: String) = apply { this.stopId = stopId } /** Include vehicles arriving or departing in the next n minutes. */ - fun minutesAfter(minutesAfter: Long) = apply { this.minutesAfter = minutesAfter } + fun minutesAfter(minutesAfter: Long?) = apply { this.minutesAfter = minutesAfter } + + /** Include vehicles arriving or departing in the next n minutes. */ + fun minutesAfter(minutesAfter: Long) = minutesAfter(minutesAfter as Long?) + + /** Include vehicles arriving or departing in the next n minutes. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun minutesAfter(minutesAfter: Optional) = + minutesAfter(minutesAfter.orElse(null) as Long?) + + /** Include vehicles having arrived or departed in the previous n minutes. */ + fun minutesBefore(minutesBefore: Long?) = apply { this.minutesBefore = minutesBefore } + + /** Include vehicles having arrived or departed in the previous n minutes. */ + fun minutesBefore(minutesBefore: Long) = minutesBefore(minutesBefore as Long?) /** Include vehicles having arrived or departed in the previous n minutes. */ - fun minutesBefore(minutesBefore: Long) = apply { this.minutesBefore = minutesBefore } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun minutesBefore(minutesBefore: Optional) = + minutesBefore(minutesBefore.orElse(null) as Long?) + + /** The specific time for querying the system status. */ + fun time(time: OffsetDateTime?) = apply { this.time = time } /** The specific time for querying the system status. */ - fun time(time: OffsetDateTime) = apply { this.time = time } + fun time(time: Optional) = time(time.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -194,7 +216,7 @@ constructor( fun build(): ArrivalAndDepartureListParams = ArrivalAndDepartureListParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, + checkRequired("stopId", stopId), minutesAfter, minutesBefore, time, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt index 584beee..a5dff47 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): ArrivalAndDepartureListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ArrivalAndDepartureListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -146,11 +150,11 @@ private constructor( fun build(): ArrivalAndDepartureListResponse = ArrivalAndDepartureListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -173,9 +177,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -184,11 +190,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -198,10 +206,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -242,8 +251,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -265,7 +274,8 @@ private constructor( @JsonProperty("arrivalsAndDepartures") @ExcludeMissing - fun _arrivalsAndDepartures() = arrivalsAndDepartures + fun _arrivalsAndDepartures(): JsonField> = + arrivalsAndDepartures @JsonAnyGetter @ExcludeMissing @@ -274,10 +284,12 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - arrivalsAndDepartures().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + arrivalsAndDepartures().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -287,15 +299,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { - private var arrivalsAndDepartures: JsonField> = - JsonMissing.of() + private var arrivalsAndDepartures: JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { - arrivalsAndDepartures = entry.arrivalsAndDepartures + arrivalsAndDepartures = entry.arrivalsAndDepartures.map { it.toMutableList() } additionalProperties = entry.additionalProperties.toMutableMap() } @@ -304,7 +317,22 @@ private constructor( fun arrivalsAndDepartures( arrivalsAndDepartures: JsonField> - ) = apply { this.arrivalsAndDepartures = arrivalsAndDepartures } + ) = apply { + this.arrivalsAndDepartures = arrivalsAndDepartures.map { it.toMutableList() } + } + + fun addArrivalsAndDeparture(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { + arrivalsAndDepartures = + (arrivalsAndDepartures ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(arrivalsAndDeparture) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -330,7 +358,9 @@ private constructor( fun build(): Entry = Entry( - arrivalsAndDepartures.map { it.toImmutable() }, + checkRequired("arrivalsAndDepartures", arrivalsAndDepartures).map { + it.toImmutable() + }, additionalProperties.toImmutable() ) } @@ -339,9 +369,6 @@ private constructor( class ArrivalsAndDeparture @JsonCreator private constructor( - @JsonProperty("actualTrack") - @ExcludeMissing - private val actualTrack: JsonField = JsonMissing.of(), @JsonProperty("arrivalEnabled") @ExcludeMissing private val arrivalEnabled: JsonField = JsonMissing.of(), @@ -351,6 +378,48 @@ private constructor( @JsonProperty("departureEnabled") @ExcludeMissing private val departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + private val numberOfStopsAway: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + private val predictedArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + private val predictedDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + private val scheduledArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + private val scheduledDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopSequence") + @ExcludeMissing + private val stopSequence: JsonField = JsonMissing.of(), + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + private val totalStopsInTrip: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("actualTrack") + @ExcludeMissing + private val actualTrack: JsonField = JsonMissing.of(), @JsonProperty("distanceFromStop") @ExcludeMissing private val distanceFromStop: JsonField = JsonMissing.of(), @@ -363,9 +432,6 @@ private constructor( @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - private val numberOfStopsAway: JsonField = JsonMissing.of(), @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), @@ -375,21 +441,12 @@ private constructor( @JsonProperty("predictedArrivalInterval") @ExcludeMissing private val predictedArrivalInterval: JsonField = JsonMissing.of(), - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - private val predictedArrivalTime: JsonField = JsonMissing.of(), @JsonProperty("predictedDepartureInterval") @ExcludeMissing private val predictedDepartureInterval: JsonField = JsonMissing.of(), - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - private val predictedDepartureTime: JsonField = JsonMissing.of(), @JsonProperty("predictedOccupancy") @ExcludeMissing private val predictedOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), @JsonProperty("routeLongName") @ExcludeMissing private val routeLongName: JsonField = JsonMissing.of(), @@ -399,56 +456,25 @@ private constructor( @JsonProperty("scheduledArrivalInterval") @ExcludeMissing private val scheduledArrivalInterval: JsonField = JsonMissing.of(), - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - private val scheduledArrivalTime: JsonField = JsonMissing.of(), @JsonProperty("scheduledDepartureInterval") @ExcludeMissing private val scheduledDepartureInterval: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - private val scheduledDepartureTime: JsonField = JsonMissing.of(), @JsonProperty("scheduledTrack") @ExcludeMissing private val scheduledTrack: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), @JsonProperty("situationIds") @ExcludeMissing private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonProperty("stopSequence") - @ExcludeMissing - private val stopSequence: JsonField = JsonMissing.of(), - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - private val totalStopsInTrip: JsonField = JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - private val tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), @JsonProperty("tripStatus") @ExcludeMissing private val tripStatus: JsonField = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(): Optional = - Optional.ofNullable(actualTrack.getNullable("actualTrack")) - /** Indicates if riders can arrive on this transit vehicle. */ fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") @@ -458,6 +484,71 @@ private constructor( /** Indicates if riders can depart from this transit vehicle. */ fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + */ + fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time + * available). + */ + fun predictedArrivalTime(): Long = + predictedArrivalTime.getRequired("predictedArrivalTime") + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time + * available). + */ + fun predictedDepartureTime(): Long = + predictedDepartureTime.getRequired("predictedDepartureTime") + + /** The ID of the route for the arriving vehicle. */ + fun routeId(): String = routeId.getRequired("routeId") + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(): Long = + scheduledArrivalTime.getRequired("scheduledArrivalTime") + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + 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. + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** The ID of the stop the vehicle is arriving at. */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + */ + fun stopSequence(): Long = stopSequence.getRequired("stopSequence") + + /** Total number of stops visited on the trip for this arrival. */ + fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + */ + fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") + + /** The ID of the trip for the arriving vehicle. */ + fun tripId(): String = tripId.getRequired("tripId") + + /** ID of the transit vehicle serving this trip. */ + fun vehicleId(): String = vehicleId.getRequired("vehicleId") + + /** The actual track information of the arriving transit vehicle. */ + fun actualTrack(): Optional = + Optional.ofNullable(actualTrack.getNullable("actualTrack")) + /** Distance of the arriving transit vehicle from the stop, in meters. */ fun distanceFromStop(): Optional = Optional.ofNullable(distanceFromStop.getNullable("distanceFromStop")) @@ -474,12 +565,6 @@ private constructor( fun lastUpdateTime(): Optional = Optional.ofNullable(lastUpdateTime.getNullable("lastUpdateTime")) - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") - /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): Optional = Optional.ofNullable(occupancyStatus.getNullable("occupancyStatus")) @@ -494,33 +579,16 @@ private constructor( predictedArrivalInterval.getNullable("predictedArrivalInterval") ) - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(): Long = - predictedArrivalTime.getRequired("predictedArrivalTime") - /** Interval for predicted departure time, if available. */ fun predictedDepartureInterval(): Optional = Optional.ofNullable( predictedDepartureInterval.getNullable("predictedDepartureInterval") ) - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(): Long = - predictedDepartureTime.getRequired("predictedDepartureTime") - /** Predicted occupancy status of the transit vehicle. */ fun predictedOccupancy(): Optional = Optional.ofNullable(predictedOccupancy.getNullable("predictedOccupancy")) - /** The ID of the route for the arriving vehicle. */ - fun routeId(): String = routeId.getRequired("routeId") - /** * Optional route long name that potentially overrides the route long name in the * referenced route element. @@ -541,30 +609,16 @@ private constructor( scheduledArrivalInterval.getNullable("scheduledArrivalInterval") ) - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(): Long = - scheduledArrivalTime.getRequired("scheduledArrivalTime") - /** Interval for scheduled departure time. */ fun scheduledDepartureInterval(): Optional = Optional.ofNullable( scheduledDepartureInterval.getNullable("scheduledDepartureInterval") ) - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(): Long = - scheduledDepartureTime.getRequired("scheduledDepartureTime") - /** Scheduled track information of the arriving transit vehicle. */ fun scheduledTrack(): Optional = Optional.ofNullable(scheduledTrack.getNullable("scheduledTrack")) - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - /** References to situation elements (if any) applicable to this arrival. */ fun situationIds(): Optional> = Optional.ofNullable(situationIds.getNullable("situationIds")) @@ -572,69 +626,24 @@ private constructor( /** Current status of the arrival. */ fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(): String = stopId.getRequired("stopId") - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - fun stopSequence(): Long = stopSequence.getRequired("stopSequence") - - /** Total number of stops visited on the trip for this arrival. */ - fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(): String = tripId.getRequired("tripId") - /** Trip-specific status for the arriving transit vehicle. */ fun tripStatus(): Optional = Optional.ofNullable(tripStatus.getNullable("tripStatus")) - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") @ExcludeMissing fun _actualTrack() = actualTrack - /** Indicates if riders can arrive on this transit vehicle. */ @JsonProperty("arrivalEnabled") @ExcludeMissing - fun _arrivalEnabled() = arrivalEnabled + fun _arrivalEnabled(): JsonField = arrivalEnabled /** Index of this arrival’s trip into the sequence of trips for the active block. */ @JsonProperty("blockTripSequence") @ExcludeMissing - fun _blockTripSequence() = blockTripSequence + fun _blockTripSequence(): JsonField = blockTripSequence /** Indicates if riders can depart from this transit vehicle. */ @JsonProperty("departureEnabled") @ExcludeMissing - fun _departureEnabled() = departureEnabled - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing - fun _distanceFromStop() = distanceFromStop - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy - - /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime + fun _departureEnabled(): JsonField = departureEnabled /** * Number of stops between the arriving transit vehicle and the current stop @@ -642,20 +651,7 @@ private constructor( */ @JsonProperty("numberOfStopsAway") @ExcludeMissing - fun _numberOfStopsAway() = numberOfStopsAway - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - fun _predictedArrivalInterval() = predictedArrivalInterval + fun _numberOfStopsAway(): JsonField = numberOfStopsAway /** * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time @@ -663,12 +659,7 @@ private constructor( */ @JsonProperty("predictedArrivalTime") @ExcludeMissing - fun _predictedArrivalTime() = predictedArrivalTime - - /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - fun _predictedDepartureInterval() = predictedDepartureInterval + fun _predictedArrivalTime(): JsonField = predictedArrivalTime /** * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time @@ -676,95 +667,154 @@ private constructor( */ @JsonProperty("predictedDepartureTime") @ExcludeMissing - fun _predictedDepartureTime() = predictedDepartureTime - - /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing - fun _predictedOccupancy() = predictedOccupancy + fun _predictedDepartureTime(): JsonField = predictedDepartureTime /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - @JsonProperty("routeLongName") @ExcludeMissing fun _routeLongName() = routeLongName - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - @JsonProperty("routeShortName") - @ExcludeMissing - fun _routeShortName() = routeShortName - - /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - fun _scheduledArrivalInterval() = scheduledArrivalInterval + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId /** Scheduled arrival time, in milliseconds since Unix epoch. */ @JsonProperty("scheduledArrivalTime") @ExcludeMissing - fun _scheduledArrivalTime() = scheduledArrivalTime - - /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - fun _scheduledDepartureInterval() = scheduledDepartureInterval + fun _scheduledArrivalTime(): JsonField = scheduledArrivalTime /** Scheduled departure time, in milliseconds since Unix epoch. */ @JsonProperty("scheduledDepartureTime") @ExcludeMissing - fun _scheduledDepartureTime() = scheduledDepartureTime - - /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") - @ExcludeMissing - fun _scheduledTrack() = scheduledTrack + fun _scheduledDepartureTime(): JsonField = scheduledDepartureTime /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status of the arrival. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId /** * Index of the stop into the sequence of stops that make up the trip for this * arrival. */ - @JsonProperty("stopSequence") @ExcludeMissing fun _stopSequence() = stopSequence + @JsonProperty("stopSequence") + @ExcludeMissing + fun _stopSequence(): JsonField = stopSequence /** Total number of stops visited on the trip for this arrival. */ @JsonProperty("totalStopsInTrip") @ExcludeMissing - fun _totalStopsInTrip() = totalStopsInTrip + fun _totalStopsInTrip(): JsonField = totalStopsInTrip /** * Optional trip headsign that potentially overrides the trip headsign in the * referenced trip element. */ - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") @ExcludeMissing fun _tripStatus() = tripStatus + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + /** The actual track information of the arriving transit vehicle. */ + @JsonProperty("actualTrack") + @ExcludeMissing + fun _actualTrack(): JsonField = actualTrack + + /** Distance of the arriving transit vehicle from the stop, in meters. */ + @JsonProperty("distanceFromStop") + @ExcludeMissing + fun _distanceFromStop(): JsonField = distanceFromStop + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Historical occupancy information of the transit vehicle. */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** Timestamp of the last update time for this arrival. */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** Current occupancy status of the transit vehicle. */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** Indicates if real-time arrival info is available for this trip. */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** Interval for predicted arrival time, if available. */ + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + fun _predictedArrivalInterval(): JsonField = predictedArrivalInterval + + /** Interval for predicted departure time, if available. */ + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + fun _predictedDepartureInterval(): JsonField = predictedDepartureInterval + + /** Predicted occupancy status of the transit vehicle. */ + @JsonProperty("predictedOccupancy") + @ExcludeMissing + fun _predictedOccupancy(): JsonField = predictedOccupancy + + /** + * Optional route long name that potentially overrides the route long name in the + * referenced route element. + */ + @JsonProperty("routeLongName") + @ExcludeMissing + fun _routeLongName(): JsonField = routeLongName + + /** + * Optional route short name that potentially overrides the route short name in the + * referenced route element. + */ + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName + + /** Interval for scheduled arrival time. */ + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + fun _scheduledArrivalInterval(): JsonField = scheduledArrivalInterval + + /** Interval for scheduled departure time. */ + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + fun _scheduledDepartureInterval(): JsonField = scheduledDepartureInterval + + /** Scheduled track information of the arriving transit vehicle. */ + @JsonProperty("scheduledTrack") + @ExcludeMissing + fun _scheduledTrack(): JsonField = scheduledTrack + + /** References to situation elements (if any) applicable to this arrival. */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** Current status of the arrival. */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** Trip-specific status for the arriving transit vehicle. */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus @JsonAnyGetter @ExcludeMissing @@ -773,43 +823,45 @@ private constructor( private var validated: Boolean = false fun validate(): ArrivalsAndDeparture = apply { - if (!validated) { - actualTrack() - arrivalEnabled() - blockTripSequence() - departureEnabled() - distanceFromStop() - frequency() - historicalOccupancy() - lastUpdateTime() - numberOfStopsAway() - occupancyStatus() - predicted() - predictedArrivalInterval() - predictedArrivalTime() - predictedDepartureInterval() - predictedDepartureTime() - predictedOccupancy() - routeId() - routeLongName() - routeShortName() - scheduledArrivalInterval() - scheduledArrivalTime() - scheduledDepartureInterval() - scheduledDepartureTime() - scheduledTrack() - serviceDate() - situationIds() - status() - stopId() - stopSequence() - totalStopsInTrip() - tripHeadsign() - tripId() - tripStatus().map { it.validate() } - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -819,121 +871,263 @@ private constructor( @JvmStatic fun builder() = Builder() } - class 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 arrivalEnabled: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var departureEnabled: 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 numberOfStopsAway: JsonField = JsonMissing.of() private var occupancyStatus: JsonField = JsonMissing.of() private var predicted: JsonField = JsonMissing.of() private var predictedArrivalInterval: JsonField = JsonMissing.of() - private var predictedArrivalTime: JsonField = JsonMissing.of() private var predictedDepartureInterval: JsonField = JsonMissing.of() - private var predictedDepartureTime: JsonField = JsonMissing.of() private var predictedOccupancy: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() private var routeLongName: JsonField = JsonMissing.of() private var routeShortName: JsonField = JsonMissing.of() private var scheduledArrivalInterval: JsonField = JsonMissing.of() - private var scheduledArrivalTime: JsonField = JsonMissing.of() private var scheduledDepartureInterval: JsonField = JsonMissing.of() - private var scheduledDepartureTime: JsonField = JsonMissing.of() private var scheduledTrack: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() + private var situationIds: JsonField>? = null private var status: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var stopSequence: JsonField = JsonMissing.of() - private var totalStopsInTrip: JsonField = JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() private var tripStatus: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { - actualTrack = arrivalsAndDeparture.actualTrack 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 - numberOfStopsAway = arrivalsAndDeparture.numberOfStopsAway occupancyStatus = arrivalsAndDeparture.occupancyStatus predicted = arrivalsAndDeparture.predicted predictedArrivalInterval = arrivalsAndDeparture.predictedArrivalInterval - predictedArrivalTime = arrivalsAndDeparture.predictedArrivalTime predictedDepartureInterval = arrivalsAndDeparture.predictedDepartureInterval - predictedDepartureTime = arrivalsAndDeparture.predictedDepartureTime predictedOccupancy = arrivalsAndDeparture.predictedOccupancy - routeId = arrivalsAndDeparture.routeId routeLongName = arrivalsAndDeparture.routeLongName routeShortName = arrivalsAndDeparture.routeShortName scheduledArrivalInterval = arrivalsAndDeparture.scheduledArrivalInterval - scheduledArrivalTime = arrivalsAndDeparture.scheduledArrivalTime scheduledDepartureInterval = arrivalsAndDeparture.scheduledDepartureInterval - scheduledDepartureTime = arrivalsAndDeparture.scheduledDepartureTime scheduledTrack = arrivalsAndDeparture.scheduledTrack - serviceDate = arrivalsAndDeparture.serviceDate - situationIds = arrivalsAndDeparture.situationIds + situationIds = arrivalsAndDeparture.situationIds.map { it.toMutableList() } status = arrivalsAndDeparture.status - stopId = arrivalsAndDeparture.stopId - stopSequence = arrivalsAndDeparture.stopSequence - totalStopsInTrip = arrivalsAndDeparture.totalStopsInTrip - tripHeadsign = arrivalsAndDeparture.tripHeadsign - tripId = arrivalsAndDeparture.tripId tripStatus = arrivalsAndDeparture.tripStatus - vehicleId = arrivalsAndDeparture.vehicleId additionalProperties = arrivalsAndDeparture.additionalProperties.toMutableMap() } - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) + /** Indicates if riders can arrive on this transit vehicle. */ + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(actualTrack: JsonField) = apply { - this.actualTrack = actualTrack + /** Indicates if riders can arrive on this transit vehicle. */ + 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)) + + /** + * Index of this arrival’s trip into the sequence of trips for the active block. + */ + 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)) + + /** Indicates if riders can depart from this transit vehicle. */ + 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)) + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + */ + 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)) + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no + * real-time available). + */ + 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)) + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no + * real-time available). + */ + 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)) + + /** The ID of the route for the arriving vehicle. */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(scheduledArrivalTime: Long) = + scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { + this.scheduledArrivalTime = scheduledArrivalTime + } + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + fun scheduledDepartureTime(scheduledDepartureTime: Long) = + scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + 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)) + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + 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)) + + /** The ID of the stop the vehicle is arriving at. */ + 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)) + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + */ + fun stopSequence(stopSequence: JsonField) = apply { + this.stopSequence = stopSequence } - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(arrivalEnabled: Boolean) = - arrivalEnabled(JsonField.of(arrivalEnabled)) + /** Total number of stops visited on the trip for this arrival. */ + fun totalStopsInTrip(totalStopsInTrip: Long) = + totalStopsInTrip(JsonField.of(totalStopsInTrip)) - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(arrivalEnabled: JsonField) = apply { - this.arrivalEnabled = arrivalEnabled + /** Total number of stops visited on the trip for this arrival. */ + fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { + this.totalStopsInTrip = totalStopsInTrip } /** - * Index of this arrival’s trip into the sequence of trips for the active block. + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. */ - fun blockTripSequence(blockTripSequence: Long) = - blockTripSequence(JsonField.of(blockTripSequence)) + fun tripHeadsign(tripHeadsign: String) = + tripHeadsign(JsonField.of(tripHeadsign)) /** - * Index of this arrival’s trip into the sequence of trips for the active block. + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. */ - fun blockTripSequence(blockTripSequence: JsonField) = apply { - this.blockTripSequence = blockTripSequence + fun tripHeadsign(tripHeadsign: JsonField) = apply { + this.tripHeadsign = tripHeadsign } - /** Indicates if riders can depart from this transit vehicle. */ - fun departureEnabled(departureEnabled: Boolean) = - departureEnabled(JsonField.of(departureEnabled)) + /** The ID of the trip for the arriving vehicle. */ + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - /** Indicates if riders can depart from this transit vehicle. */ - fun departureEnabled(departureEnabled: JsonField) = apply { - this.departureEnabled = departureEnabled + /** The ID of the trip for the arriving vehicle. */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + /** ID of the transit vehicle serving this trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** ID of the transit vehicle serving this trip. */ + 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)) + + /** The actual track information of the arriving transit vehicle. */ + fun actualTrack(actualTrack: JsonField) = apply { + this.actualTrack = actualTrack } /** Distance of the arriving transit vehicle from the stop, in meters. */ @@ -971,21 +1165,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(numberOfStopsAway: Long) = - numberOfStopsAway(JsonField.of(numberOfStopsAway)) - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { - this.numberOfStopsAway = numberOfStopsAway - } - /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(occupancyStatus: String) = occupancyStatus(JsonField.of(occupancyStatus)) @@ -1013,21 +1192,6 @@ private constructor( this.predictedArrivalInterval = predictedArrivalInterval } - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - fun predictedArrivalTime(predictedArrivalTime: Long) = - predictedArrivalTime(JsonField.of(predictedArrivalTime)) - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { - this.predictedArrivalTime = predictedArrivalTime - } - /** Interval for predicted departure time, if available. */ fun predictedDepartureInterval(predictedDepartureInterval: String) = predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) @@ -1038,21 +1202,6 @@ private constructor( this.predictedDepartureInterval = predictedDepartureInterval } - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - fun predictedDepartureTime(predictedDepartureTime: Long) = - predictedDepartureTime(JsonField.of(predictedDepartureTime)) - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { - this.predictedDepartureTime = predictedDepartureTime - } - /** Predicted occupancy status of the transit vehicle. */ fun predictedOccupancy(predictedOccupancy: String) = predictedOccupancy(JsonField.of(predictedOccupancy)) @@ -1062,12 +1211,6 @@ private constructor( this.predictedOccupancy = predictedOccupancy } - /** The ID of the route for the arriving vehicle. */ - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - /** The ID of the route for the arriving vehicle. */ - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - /** * Optional route long name that potentially overrides the route long name in * the referenced route element. @@ -1108,15 +1251,6 @@ private constructor( this.scheduledArrivalInterval = scheduledArrivalInterval } - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: Long) = - scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { - this.scheduledArrivalTime = scheduledArrivalTime - } - /** Interval for scheduled departure time. */ fun scheduledDepartureInterval(scheduledDepartureInterval: String) = scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) @@ -1127,15 +1261,6 @@ private constructor( this.scheduledDepartureInterval = scheduledDepartureInterval } - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(scheduledDepartureTime: Long) = - scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { - this.scheduledDepartureTime = scheduledDepartureTime - } - /** Scheduled track information of the arriving transit vehicle. */ fun scheduledTrack(scheduledTrack: String) = scheduledTrack(JsonField.of(scheduledTrack)) @@ -1145,27 +1270,27 @@ private constructor( this.scheduledTrack = scheduledTrack } - /** - * 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - /** References to situation elements (if any) applicable to this arrival. */ fun situationIds(situationIds: List) = situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this arrival. */ fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** References to situation elements (if any) applicable to this arrival. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } } /** Current status of the arrival. */ @@ -1174,56 +1299,6 @@ private constructor( /** Current status of the arrival. */ fun status(status: JsonField) = apply { this.status = status } - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - /** The ID of the stop the vehicle is arriving at. */ - 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)) - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - 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)) - - /** Total number of stops visited on the trip for this arrival. */ - 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)) - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - 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)) - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - /** Trip-specific status for the arriving transit vehicle. */ fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) @@ -1232,14 +1307,6 @@ private constructor( this.tripStatus = tripStatus } - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(vehicleId: JsonField) = apply { - this.vehicleId = vehicleId - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1264,40 +1331,40 @@ private constructor( 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, - arrivalEnabled, - blockTripSequence, - departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, - numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, - predictedArrivalTime, predictedDepartureInterval, - predictedDepartureTime, predictedOccupancy, - routeId, routeLongName, routeShortName, scheduledArrivalInterval, - scheduledArrivalTime, scheduledDepartureInterval, - scheduledDepartureTime, scheduledTrack, - serviceDate, - situationIds.map { it.toImmutable() }, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, status, - stopId, - stopSequence, - totalStopsInTrip, - tripHeadsign, - tripId, tripStatus, - vehicleId, additionalProperties.toImmutable(), ) } @@ -1316,36 +1383,18 @@ private constructor( @JsonProperty("closestStop") @ExcludeMissing private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("distanceAlongTrip") @ExcludeMissing private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), @JsonProperty("lastLocationUpdateTime") @ExcludeMissing private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing private val occupancyCapacity: JsonField = JsonMissing.of(), @@ -1355,36 +1404,54 @@ private constructor( @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + private val phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + private val predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + private val scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("orientation") @ExcludeMissing private val orientation: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDeviation") - @ExcludeMissing - private val scheduleDeviation: JsonField = JsonMissing.of(), @JsonProperty("scheduledDistanceAlongTrip") @ExcludeMissing private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), @JsonProperty("situationIds") @ExcludeMissing private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("vehicleId") @ExcludeMissing private val vehicleId: JsonField = JsonMissing.of(), @@ -1402,15 +1469,6 @@ private constructor( /** ID of the closest stop to the current location of the transit vehicle. */ fun closestStop(): String = closestStop.getRequired("closestStop") - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable( - closestStopTimeOffset.getNullable("closestStopTimeOffset") - ) - /** * Distance, in meters, the transit vehicle has progressed along the active * trip. @@ -1418,10 +1476,6 @@ private constructor( fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1429,18 +1483,6 @@ private constructor( fun lastKnownDistanceAlongTrip(): Double = lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable( - lastKnownOrientation.getNullable("lastKnownOrientation") - ) - /** * Timestamp of the last known real-time location update from the transit * vehicle. @@ -1451,17 +1493,6 @@ private constructor( /** Timestamp of the last known real-time update from the transit vehicle. */ fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") @@ -1472,17 +1503,9 @@ private constructor( /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - /** Current journey phase of the trip. */ fun phase(): String = phase.getRequired("phase") - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(): Boolean = predicted.getRequired("predicted") @@ -1493,25 +1516,12 @@ private constructor( fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - /** Current status modifiers for the trip. */ fun status(): String = status.getRequired("status") @@ -1519,28 +1529,81 @@ private constructor( fun totalDistanceAlongTrip(): Double = totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + fun closestStopTimeOffset(): Optional = + Optional.ofNullable( + closestStopTimeOffset.getNullable("closestStopTimeOffset") + ) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(): Optional = + Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + fun lastKnownOrientation(): Optional = + Optional.ofNullable( + lastKnownOrientation.getNullable("lastKnownOrientation") + ) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(): Optional = + Optional.ofNullable(nextStop.getNullable("nextStop")) + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + fun nextStopTimeOffset(): Optional = + Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(): Optional = + Optional.ofNullable(orientation.getNullable("orientation")) + + /** Current position of the transit vehicle. */ + fun position(): Optional = + Optional.ofNullable(position.getNullable("position")) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(): Optional = + Optional.ofNullable( + scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") + ) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(): Optional> = + Optional.ofNullable(situationIds.getNullable("situationIds")) + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(): Optional = Optional.ofNullable(vehicleId.getNullable("vehicleId")) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId /** Index of the active trip into the sequence of trips for the active block. */ @JsonProperty("blockTripSequence") @ExcludeMissing - fun _blockTripSequence() = blockTripSequence + fun _blockTripSequence(): JsonField = blockTripSequence /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") + @JsonProperty("closestStop") @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset + fun _closestStop(): JsonField = closestStop /** * Distance, in meters, the transit vehicle has progressed along the active @@ -1548,10 +1611,7 @@ private constructor( */ @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun _distanceAlongTrip(): JsonField = distanceAlongTrip /** * Last known distance along the trip received in real-time from the transit @@ -1559,19 +1619,8 @@ private constructor( */ @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation + fun _lastKnownDistanceAlongTrip(): JsonField = + lastKnownDistanceAlongTrip /** * Timestamp of the last known real-time location update from the transit @@ -1579,50 +1628,35 @@ private constructor( */ @JsonProperty("lastLocationUpdateTime") @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime /** Timestamp of the last known real-time update from the transit vehicle. */ @JsonProperty("lastUpdateTime") @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset + fun _lastUpdateTime(): JsonField = lastUpdateTime /** Capacity of the transit vehicle in terms of occupancy. */ @JsonProperty("occupancyCapacity") @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity + fun _occupancyCapacity(): JsonField = occupancyCapacity /** Current count of occupants in the transit vehicle. */ @JsonProperty("occupancyCount") @ExcludeMissing - fun _occupancyCount() = occupancyCount + fun _occupancyCount(): JsonField = occupancyCount /** Current occupancy status of the transit vehicle. */ @JsonProperty("occupancyStatus") @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation + fun _occupancyStatus(): JsonField = occupancyStatus /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted /** * Deviation from the schedule in seconds (positive for late, negative for @@ -1630,35 +1664,92 @@ private constructor( */ @JsonProperty("scheduleDeviation") @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip + fun _scheduleDeviation(): JsonField = scheduleDeviation /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status /** Total length of the trip, in meters. */ @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Last known location of the transit vehicle. */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** Current position of the transit vehicle. */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = + scheduledDistanceAlongTrip + + /** References to situation elements (if any) applicable to this trip. */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId @JsonAnyGetter @ExcludeMissing @@ -1667,36 +1758,38 @@ private constructor( private var validated: Boolean = false fun validate(): TripStatus = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -1706,35 +1799,36 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() + /** 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 distanceAlongTrip: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() private var lastKnownLocation: JsonField = JsonMissing.of() private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() private var nextStop: JsonField = JsonMissing.of() private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1744,29 +1838,29 @@ private constructor( activeTripId = tripStatus.activeTripId blockTripSequence = tripStatus.blockTripSequence closestStop = tripStatus.closestStop - closestStopTimeOffset = tripStatus.closestStopTimeOffset distanceAlongTrip = tripStatus.distanceAlongTrip - frequency = tripStatus.frequency lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - lastKnownLocation = tripStatus.lastKnownLocation - lastKnownOrientation = tripStatus.lastKnownOrientation lastLocationUpdateTime = tripStatus.lastLocationUpdateTime lastUpdateTime = tripStatus.lastUpdateTime - nextStop = tripStatus.nextStop - nextStopTimeOffset = tripStatus.nextStopTimeOffset occupancyCapacity = tripStatus.occupancyCapacity occupancyCount = tripStatus.occupancyCount occupancyStatus = tripStatus.occupancyStatus - orientation = tripStatus.orientation phase = tripStatus.phase - position = tripStatus.position predicted = tripStatus.predicted scheduleDeviation = tripStatus.scheduleDeviation - scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip serviceDate = tripStatus.serviceDate - situationIds = tripStatus.situationIds 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() } @@ -1806,21 +1900,6 @@ private constructor( this.closestStop = closestStop } - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - /** * Distance, in meters, the transit vehicle has progressed along the active * trip. @@ -1836,18 +1915,6 @@ private constructor( this.distanceAlongTrip = distanceAlongTrip } - /** - * Information about frequency-based scheduling, if applicable to the trip. - */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** - * Information about frequency-based scheduling, if applicable to the trip. - */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1863,31 +1930,6 @@ private constructor( lastKnownDistanceAlongTrip: JsonField ) = apply { this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit - * vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - /** * Timestamp of the last known real-time location update from the transit * vehicle. @@ -1917,29 +1959,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit - * vehicle (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -1967,33 +1986,12 @@ private constructor( this.occupancyStatus = occupancyStatus } - /** - * Orientation of the transit vehicle, represented as an angle in degrees. - */ - fun orientation(orientation: Double) = - orientation(JsonField.of(orientation)) - - /** - * Orientation of the transit vehicle, represented as an angle in degrees. - */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - /** Current journey phase of the trip. */ fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ fun phase(phase: JsonField) = apply { this.phase = phase } - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - fun position(position: JsonField) = apply { - this.position = position - } - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) @@ -2017,21 +2015,6 @@ private constructor( this.scheduleDeviation = scheduleDeviation } - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip( - scheduledDistanceAlongTrip: JsonField - ) = apply { this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip } - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of * the service date for the trip. @@ -2046,15 +2029,6 @@ private constructor( this.serviceDate = serviceDate } - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - /** Current status modifiers for the trip. */ fun status(status: String) = status(JsonField.of(status)) @@ -2071,6 +2045,140 @@ private constructor( 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)) + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + 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)) + + /** + * Information about frequency-based scheduling, if applicable to the trip. + */ + fun frequency(frequency: JsonField) = apply { + 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. */ + 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)) + + /** + * Last known orientation value received in real-time from the transit + * vehicle. + */ + 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)) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + 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)) + + /** + * Time offset from the next stop to the current position of the transit + * vehicle (in seconds). + */ + 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)) + + /** + * Orientation of the transit vehicle, represented as an angle in degrees. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** Current position of the transit vehicle. */ + 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)) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + 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)) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** References to situation elements (if any) applicable to this trip. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) @@ -2103,32 +2211,35 @@ private constructor( fun build(): TripStatus = TripStatus( - activeTripId, - blockTripSequence, - closestStop, + 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, - distanceAlongTrip, frequency, - lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, nextStop, nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, orientation, - phase, position, - predicted, - scheduleDeviation, scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, vehicleId, additionalProperties.toImmutable(), ) @@ -2157,10 +2268,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -2169,11 +2280,13 @@ private constructor( private var validated: Boolean = false fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -2183,7 +2296,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -2281,10 +2395,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -2293,11 +2407,13 @@ private constructor( private var validated: Boolean = false fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -2307,7 +2423,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Position]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -2386,17 +2503,17 @@ private constructor( return true } - return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "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 { @@ -2404,17 +2521,17 @@ private constructor( return true } - return /* spotless:off */ other is ArrivalsAndDeparture && actualTrack == other.actualTrack && arrivalEnabled == other.arrivalEnabled && blockTripSequence == other.blockTripSequence && departureEnabled == other.departureEnabled && distanceFromStop == other.distanceFromStop && frequency == other.frequency && historicalOccupancy == other.historicalOccupancy && lastUpdateTime == other.lastUpdateTime && numberOfStopsAway == other.numberOfStopsAway && occupancyStatus == other.occupancyStatus && predicted == other.predicted && predictedArrivalInterval == other.predictedArrivalInterval && predictedArrivalTime == other.predictedArrivalTime && predictedDepartureInterval == other.predictedDepartureInterval && predictedDepartureTime == other.predictedDepartureTime && predictedOccupancy == other.predictedOccupancy && routeId == other.routeId && routeLongName == other.routeLongName && routeShortName == other.routeShortName && scheduledArrivalInterval == other.scheduledArrivalInterval && scheduledArrivalTime == other.scheduledArrivalTime && scheduledDepartureInterval == other.scheduledDepartureInterval && scheduledDepartureTime == other.scheduledDepartureTime && scheduledTrack == other.scheduledTrack && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && stopId == other.stopId && stopSequence == other.stopSequence && totalStopsInTrip == other.totalStopsInTrip && tripHeadsign == other.tripHeadsign && tripId == other.tripId && tripStatus == other.tripStatus && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(actualTrack, arrivalEnabled, blockTripSequence, departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, predictedArrivalTime, predictedDepartureInterval, predictedDepartureTime, predictedOccupancy, routeId, routeLongName, routeShortName, scheduledArrivalInterval, scheduledArrivalTime, scheduledDepartureInterval, scheduledDepartureTime, scheduledTrack, serviceDate, situationIds, status, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, tripStatus, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ArrivalsAndDeparture{actualTrack=$actualTrack, arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, numberOfStopsAway=$numberOfStopsAway, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedArrivalTime=$predictedArrivalTime, predictedDepartureInterval=$predictedDepartureInterval, predictedDepartureTime=$predictedDepartureTime, predictedOccupancy=$predictedOccupancy, routeId=$routeId, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledDepartureTime=$scheduledDepartureTime, scheduledTrack=$scheduledTrack, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, tripStatus=$tripStatus, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "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}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt index 427be87..2ce93d0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt @@ -5,11 +5,14 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** arrival-and-departure-for-stop */ class ArrivalAndDepartureRetrieveParams -constructor( +private constructor( private val stopId: String, private val serviceDate: Long, private val tripId: String, @@ -18,7 +21,7 @@ constructor( private val vehicleId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun stopId(): String = stopId @@ -36,10 +39,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.serviceDate.let { queryParams.put("serviceDate", listOf(it.toString())) } this.tripId.let { queryParams.put("tripId", listOf(it.toString())) } @@ -64,8 +66,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ArrivalAndDepartureRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var stopId: String? = null private var serviceDate: Long? = null @@ -96,11 +99,24 @@ constructor( fun tripId(tripId: String) = apply { this.tripId = tripId } - fun stopSequence(stopSequence: Long) = apply { this.stopSequence = stopSequence } + fun stopSequence(stopSequence: Long?) = apply { this.stopSequence = stopSequence } - fun time(time: Long) = apply { this.time = time } + fun stopSequence(stopSequence: Long) = stopSequence(stopSequence as Long?) - fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun stopSequence(stopSequence: Optional) = + stopSequence(stopSequence.orElse(null) as Long?) + + fun time(time: Long?) = apply { this.time = time } + + fun time(time: Long) = time(time as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun time(time: Optional) = time(time.orElse(null) as Long?) + + fun vehicleId(vehicleId: String?) = apply { this.vehicleId = vehicleId } + + fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -202,9 +218,9 @@ constructor( fun build(): ArrivalAndDepartureRetrieveParams = ArrivalAndDepartureRetrieveParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, - checkNotNull(serviceDate) { "`serviceDate` is required but was not set" }, - checkNotNull(tripId) { "`tripId` is required but was not set" }, + checkRequired("stopId", stopId), + checkRequired("serviceDate", serviceDate), + checkRequired("tripId", tripId), stopSequence, time, vehicleId, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt index 9d491fe..cfc7751 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): ArrivalAndDepartureRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ArrivalAndDepartureRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -147,11 +151,11 @@ private constructor( fun build(): ArrivalAndDepartureRetrieveResponse = ArrivalAndDepartureRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -174,9 +178,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -185,11 +191,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -199,10 +207,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -243,8 +252,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -253,9 +262,6 @@ private constructor( class Entry @JsonCreator private constructor( - @JsonProperty("actualTrack") - @ExcludeMissing - private val actualTrack: JsonField = JsonMissing.of(), @JsonProperty("arrivalEnabled") @ExcludeMissing private val arrivalEnabled: JsonField = JsonMissing.of(), @@ -265,6 +271,48 @@ private constructor( @JsonProperty("departureEnabled") @ExcludeMissing private val departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + private val numberOfStopsAway: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + private val predictedArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + private val predictedDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + private val scheduledArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + private val scheduledDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + private val stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopSequence") + @ExcludeMissing + private val stopSequence: JsonField = JsonMissing.of(), + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + private val totalStopsInTrip: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("actualTrack") + @ExcludeMissing + private val actualTrack: JsonField = JsonMissing.of(), @JsonProperty("distanceFromStop") @ExcludeMissing private val distanceFromStop: JsonField = JsonMissing.of(), @@ -277,9 +325,6 @@ private constructor( @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - private val numberOfStopsAway: JsonField = JsonMissing.of(), @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), @@ -289,21 +334,12 @@ private constructor( @JsonProperty("predictedArrivalInterval") @ExcludeMissing private val predictedArrivalInterval: JsonField = JsonMissing.of(), - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - private val predictedArrivalTime: JsonField = JsonMissing.of(), @JsonProperty("predictedDepartureInterval") @ExcludeMissing private val predictedDepartureInterval: JsonField = JsonMissing.of(), - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - private val predictedDepartureTime: JsonField = JsonMissing.of(), @JsonProperty("predictedOccupancy") @ExcludeMissing private val predictedOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), @JsonProperty("routeLongName") @ExcludeMissing private val routeLongName: JsonField = JsonMissing.of(), @@ -313,56 +349,25 @@ private constructor( @JsonProperty("scheduledArrivalInterval") @ExcludeMissing private val scheduledArrivalInterval: JsonField = JsonMissing.of(), - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - private val scheduledArrivalTime: JsonField = JsonMissing.of(), @JsonProperty("scheduledDepartureInterval") @ExcludeMissing private val scheduledDepartureInterval: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - private val scheduledDepartureTime: JsonField = JsonMissing.of(), @JsonProperty("scheduledTrack") @ExcludeMissing private val scheduledTrack: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), @JsonProperty("situationIds") @ExcludeMissing private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonProperty("stopSequence") - @ExcludeMissing - private val stopSequence: JsonField = JsonMissing.of(), - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - private val totalStopsInTrip: JsonField = JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - private val tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), @JsonProperty("tripStatus") @ExcludeMissing private val tripStatus: JsonField = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(): Optional = - Optional.ofNullable(actualTrack.getNullable("actualTrack")) - /** Indicates if riders can arrive on this transit vehicle. */ fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") @@ -372,6 +377,70 @@ private constructor( /** Indicates if riders can depart from this transit vehicle. */ fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") + /** + * Number of stops between the arriving transit vehicle and the current stop (excluding + * the current stop). + */ + fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time + * available). + */ + fun predictedArrivalTime(): Long = + predictedArrivalTime.getRequired("predictedArrivalTime") + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time + * available). + */ + fun predictedDepartureTime(): Long = + predictedDepartureTime.getRequired("predictedDepartureTime") + + /** The ID of the route for the arriving vehicle. */ + fun routeId(): String = routeId.getRequired("routeId") + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(): Long = + scheduledArrivalTime.getRequired("scheduledArrivalTime") + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + 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. + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** The ID of the stop the vehicle is arriving at. */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * Index of the stop into the sequence of stops that make up the trip for this arrival. + */ + fun stopSequence(): Long = stopSequence.getRequired("stopSequence") + + /** Total number of stops visited on the trip for this arrival. */ + fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") + + /** + * Optional trip headsign that potentially overrides the trip headsign in the referenced + * trip element. + */ + fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") + + /** The ID of the trip for the arriving vehicle. */ + fun tripId(): String = tripId.getRequired("tripId") + + /** ID of the transit vehicle serving this trip. */ + fun vehicleId(): String = vehicleId.getRequired("vehicleId") + + /** The actual track information of the arriving transit vehicle. */ + fun actualTrack(): Optional = + Optional.ofNullable(actualTrack.getNullable("actualTrack")) + /** Distance of the arriving transit vehicle from the stop, in meters. */ fun distanceFromStop(): Optional = Optional.ofNullable(distanceFromStop.getNullable("distanceFromStop")) @@ -388,12 +457,6 @@ private constructor( fun lastUpdateTime(): Optional = Optional.ofNullable(lastUpdateTime.getNullable("lastUpdateTime")) - /** - * Number of stops between the arriving transit vehicle and the current stop (excluding - * the current stop). - */ - fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") - /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): Optional = Optional.ofNullable(occupancyStatus.getNullable("occupancyStatus")) @@ -408,33 +471,16 @@ private constructor( predictedArrivalInterval.getNullable("predictedArrivalInterval") ) - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(): Long = - predictedArrivalTime.getRequired("predictedArrivalTime") - /** Interval for predicted departure time, if available. */ fun predictedDepartureInterval(): Optional = Optional.ofNullable( predictedDepartureInterval.getNullable("predictedDepartureInterval") ) - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(): Long = - predictedDepartureTime.getRequired("predictedDepartureTime") - /** Predicted occupancy status of the transit vehicle. */ fun predictedOccupancy(): Optional = Optional.ofNullable(predictedOccupancy.getNullable("predictedOccupancy")) - /** The ID of the route for the arriving vehicle. */ - fun routeId(): String = routeId.getRequired("routeId") - /** * Optional route long name that potentially overrides the route long name in the * referenced route element. @@ -455,30 +501,16 @@ private constructor( scheduledArrivalInterval.getNullable("scheduledArrivalInterval") ) - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(): Long = - scheduledArrivalTime.getRequired("scheduledArrivalTime") - /** Interval for scheduled departure time. */ fun scheduledDepartureInterval(): Optional = Optional.ofNullable( scheduledDepartureInterval.getNullable("scheduledDepartureInterval") ) - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(): Long = - scheduledDepartureTime.getRequired("scheduledDepartureTime") - /** Scheduled track information of the arriving transit vehicle. */ fun scheduledTrack(): Optional = Optional.ofNullable(scheduledTrack.getNullable("scheduledTrack")) - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the service - * date for the trip. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - /** References to situation elements (if any) applicable to this arrival. */ fun situationIds(): Optional> = Optional.ofNullable(situationIds.getNullable("situationIds")) @@ -486,64 +518,24 @@ private constructor( /** Current status of the arrival. */ fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(): String = stopId.getRequired("stopId") - - /** - * Index of the stop into the sequence of stops that make up the trip for this arrival. - */ - fun stopSequence(): Long = stopSequence.getRequired("stopSequence") - - /** Total number of stops visited on the trip for this arrival. */ - fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") - - /** - * Optional trip headsign that potentially overrides the trip headsign in the referenced - * trip element. - */ - fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(): String = tripId.getRequired("tripId") - /** Trip-specific status for the arriving transit vehicle. */ fun tripStatus(): Optional = Optional.ofNullable(tripStatus.getNullable("tripStatus")) - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") @ExcludeMissing fun _actualTrack() = actualTrack - /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") @ExcludeMissing fun _arrivalEnabled() = arrivalEnabled + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled /** Index of this arrival’s trip into the sequence of trips for the active block. */ @JsonProperty("blockTripSequence") @ExcludeMissing - fun _blockTripSequence() = blockTripSequence + fun _blockTripSequence(): JsonField = blockTripSequence /** Indicates if riders can depart from this transit vehicle. */ @JsonProperty("departureEnabled") @ExcludeMissing - fun _departureEnabled() = departureEnabled - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing - fun _distanceFromStop() = distanceFromStop - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy - - /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") @ExcludeMissing fun _lastUpdateTime() = lastUpdateTime + fun _departureEnabled(): JsonField = departureEnabled /** * Number of stops between the arriving transit vehicle and the current stop (excluding @@ -551,20 +543,7 @@ private constructor( */ @JsonProperty("numberOfStopsAway") @ExcludeMissing - fun _numberOfStopsAway() = numberOfStopsAway - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted - - /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - fun _predictedArrivalInterval() = predictedArrivalInterval + fun _numberOfStopsAway(): JsonField = numberOfStopsAway /** * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time @@ -572,12 +551,7 @@ private constructor( */ @JsonProperty("predictedArrivalTime") @ExcludeMissing - fun _predictedArrivalTime() = predictedArrivalTime - - /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - fun _predictedDepartureInterval() = predictedDepartureInterval + fun _predictedArrivalTime(): JsonField = predictedArrivalTime /** * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time @@ -585,90 +559,153 @@ private constructor( */ @JsonProperty("predictedDepartureTime") @ExcludeMissing - fun _predictedDepartureTime() = predictedDepartureTime - - /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing - fun _predictedOccupancy() = predictedOccupancy + fun _predictedDepartureTime(): JsonField = predictedDepartureTime /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - @JsonProperty("routeLongName") @ExcludeMissing fun _routeLongName() = routeLongName - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - @JsonProperty("routeShortName") @ExcludeMissing fun _routeShortName() = routeShortName - - /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - fun _scheduledArrivalInterval() = scheduledArrivalInterval + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId /** Scheduled arrival time, in milliseconds since Unix epoch. */ @JsonProperty("scheduledArrivalTime") @ExcludeMissing - fun _scheduledArrivalTime() = scheduledArrivalTime - - /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - fun _scheduledDepartureInterval() = scheduledDepartureInterval + fun _scheduledArrivalTime(): JsonField = scheduledArrivalTime /** Scheduled departure time, in milliseconds since Unix epoch. */ @JsonProperty("scheduledDepartureTime") @ExcludeMissing - fun _scheduledDepartureTime() = scheduledDepartureTime - - /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") @ExcludeMissing fun _scheduledTrack() = scheduledTrack + fun _scheduledDepartureTime(): JsonField = scheduledDepartureTime /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the service * date for the trip. */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status of the arrival. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId /** * Index of the stop into the sequence of stops that make up the trip for this arrival. */ - @JsonProperty("stopSequence") @ExcludeMissing fun _stopSequence() = stopSequence + @JsonProperty("stopSequence") + @ExcludeMissing + fun _stopSequence(): JsonField = stopSequence /** Total number of stops visited on the trip for this arrival. */ @JsonProperty("totalStopsInTrip") @ExcludeMissing - fun _totalStopsInTrip() = totalStopsInTrip + fun _totalStopsInTrip(): JsonField = totalStopsInTrip /** * Optional trip headsign that potentially overrides the trip headsign in the referenced * trip element. */ - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") @ExcludeMissing fun _tripStatus() = tripStatus + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + /** The actual track information of the arriving transit vehicle. */ + @JsonProperty("actualTrack") + @ExcludeMissing + fun _actualTrack(): JsonField = actualTrack + + /** Distance of the arriving transit vehicle from the stop, in meters. */ + @JsonProperty("distanceFromStop") + @ExcludeMissing + fun _distanceFromStop(): JsonField = distanceFromStop + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Historical occupancy information of the transit vehicle. */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** Timestamp of the last update time for this arrival. */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** Current occupancy status of the transit vehicle. */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** Indicates if real-time arrival info is available for this trip. */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** Interval for predicted arrival time, if available. */ + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + fun _predictedArrivalInterval(): JsonField = predictedArrivalInterval + + /** Interval for predicted departure time, if available. */ + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + fun _predictedDepartureInterval(): JsonField = predictedDepartureInterval + + /** Predicted occupancy status of the transit vehicle. */ + @JsonProperty("predictedOccupancy") + @ExcludeMissing + fun _predictedOccupancy(): JsonField = predictedOccupancy + + /** + * Optional route long name that potentially overrides the route long name in the + * referenced route element. + */ + @JsonProperty("routeLongName") + @ExcludeMissing + fun _routeLongName(): JsonField = routeLongName + + /** + * Optional route short name that potentially overrides the route short name in the + * referenced route element. + */ + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName + + /** Interval for scheduled arrival time. */ + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + fun _scheduledArrivalInterval(): JsonField = scheduledArrivalInterval + + /** Interval for scheduled departure time. */ + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + fun _scheduledDepartureInterval(): JsonField = scheduledDepartureInterval + + /** Scheduled track information of the arriving transit vehicle. */ + @JsonProperty("scheduledTrack") + @ExcludeMissing + fun _scheduledTrack(): JsonField = scheduledTrack + + /** References to situation elements (if any) applicable to this arrival. */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** Current status of the arrival. */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** Trip-specific status for the arriving transit vehicle. */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus @JsonAnyGetter @ExcludeMissing @@ -677,43 +714,45 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - actualTrack() - arrivalEnabled() - blockTripSequence() - departureEnabled() - distanceFromStop() - frequency() - historicalOccupancy() - lastUpdateTime() - numberOfStopsAway() - occupancyStatus() - predicted() - predictedArrivalInterval() - predictedArrivalTime() - predictedDepartureInterval() - predictedDepartureTime() - predictedOccupancy() - routeId() - routeLongName() - routeShortName() - scheduledArrivalInterval() - scheduledArrivalTime() - scheduledDepartureInterval() - scheduledDepartureTime() - scheduledTrack() - serviceDate() - situationIds() - status() - stopId() - stopSequence() - totalStopsInTrip() - tripHeadsign() - tripId() - tripStatus().map { it.validate() } - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -723,91 +762,84 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - + /** A builder for [Entry]. */ + 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 arrivalEnabled: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var departureEnabled: 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 numberOfStopsAway: JsonField = JsonMissing.of() private var occupancyStatus: JsonField = JsonMissing.of() private var predicted: JsonField = JsonMissing.of() private var predictedArrivalInterval: JsonField = JsonMissing.of() - private var predictedArrivalTime: JsonField = JsonMissing.of() private var predictedDepartureInterval: JsonField = JsonMissing.of() - private var predictedDepartureTime: JsonField = JsonMissing.of() private var predictedOccupancy: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() private var routeLongName: JsonField = JsonMissing.of() private var routeShortName: JsonField = JsonMissing.of() private var scheduledArrivalInterval: JsonField = JsonMissing.of() - private var scheduledArrivalTime: JsonField = JsonMissing.of() private var scheduledDepartureInterval: JsonField = JsonMissing.of() - private var scheduledDepartureTime: JsonField = JsonMissing.of() private var scheduledTrack: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() + private var situationIds: JsonField>? = null private var status: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var stopSequence: JsonField = JsonMissing.of() - private var totalStopsInTrip: JsonField = JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() private var tripStatus: JsonField = JsonMissing.of() - private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { - actualTrack = entry.actualTrack arrivalEnabled = entry.arrivalEnabled blockTripSequence = entry.blockTripSequence departureEnabled = entry.departureEnabled + numberOfStopsAway = entry.numberOfStopsAway + predictedArrivalTime = entry.predictedArrivalTime + predictedDepartureTime = entry.predictedDepartureTime + routeId = entry.routeId + scheduledArrivalTime = entry.scheduledArrivalTime + scheduledDepartureTime = entry.scheduledDepartureTime + serviceDate = entry.serviceDate + stopId = entry.stopId + stopSequence = entry.stopSequence + totalStopsInTrip = entry.totalStopsInTrip + tripHeadsign = entry.tripHeadsign + tripId = entry.tripId + vehicleId = entry.vehicleId + actualTrack = entry.actualTrack distanceFromStop = entry.distanceFromStop frequency = entry.frequency historicalOccupancy = entry.historicalOccupancy lastUpdateTime = entry.lastUpdateTime - numberOfStopsAway = entry.numberOfStopsAway occupancyStatus = entry.occupancyStatus predicted = entry.predicted predictedArrivalInterval = entry.predictedArrivalInterval - predictedArrivalTime = entry.predictedArrivalTime predictedDepartureInterval = entry.predictedDepartureInterval - predictedDepartureTime = entry.predictedDepartureTime predictedOccupancy = entry.predictedOccupancy - routeId = entry.routeId routeLongName = entry.routeLongName routeShortName = entry.routeShortName scheduledArrivalInterval = entry.scheduledArrivalInterval - scheduledArrivalTime = entry.scheduledArrivalTime scheduledDepartureInterval = entry.scheduledDepartureInterval - scheduledDepartureTime = entry.scheduledDepartureTime scheduledTrack = entry.scheduledTrack - serviceDate = entry.serviceDate - situationIds = entry.situationIds + situationIds = entry.situationIds.map { it.toMutableList() } status = entry.status - stopId = entry.stopId - stopSequence = entry.stopSequence - totalStopsInTrip = entry.totalStopsInTrip - tripHeadsign = entry.tripHeadsign - tripId = entry.tripId tripStatus = entry.tripStatus - vehicleId = entry.vehicleId additionalProperties = entry.additionalProperties.toMutableMap() } - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) - - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(actualTrack: JsonField) = apply { - this.actualTrack = actualTrack - } - /** Indicates if riders can arrive on this transit vehicle. */ fun arrivalEnabled(arrivalEnabled: Boolean) = arrivalEnabled(JsonField.of(arrivalEnabled)) @@ -835,6 +867,152 @@ private constructor( 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)) + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + */ + 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)) + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time + * available). + */ + 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)) + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time + * available). + */ + 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)) + + /** The ID of the route for the arriving vehicle. */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(scheduledArrivalTime: Long) = + scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { + this.scheduledArrivalTime = scheduledArrivalTime + } + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + fun scheduledDepartureTime(scheduledDepartureTime: Long) = + scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + 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)) + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + 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)) + + /** The ID of the stop the vehicle is arriving at. */ + 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)) + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + */ + 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)) + + /** Total number of stops visited on the trip for this arrival. */ + 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)) + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + */ + 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)) + + /** The ID of the trip for the arriving vehicle. */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + /** ID of the transit vehicle serving this trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** ID of the transit vehicle serving this trip. */ + 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)) + + /** The actual track information of the arriving transit vehicle. */ + 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)) @@ -868,21 +1046,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(numberOfStopsAway: Long) = - numberOfStopsAway(JsonField.of(numberOfStopsAway)) - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { - this.numberOfStopsAway = numberOfStopsAway - } - /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(occupancyStatus: String) = occupancyStatus(JsonField.of(occupancyStatus)) @@ -907,21 +1070,6 @@ private constructor( this.predictedArrivalInterval = predictedArrivalInterval } - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(predictedArrivalTime: Long) = - predictedArrivalTime(JsonField.of(predictedArrivalTime)) - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { - this.predictedArrivalTime = predictedArrivalTime - } - /** Interval for predicted departure time, if available. */ fun predictedDepartureInterval(predictedDepartureInterval: String) = predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) @@ -932,21 +1080,6 @@ private constructor( this.predictedDepartureInterval = predictedDepartureInterval } - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(predictedDepartureTime: Long) = - predictedDepartureTime(JsonField.of(predictedDepartureTime)) - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { - this.predictedDepartureTime = predictedDepartureTime - } - /** Predicted occupancy status of the transit vehicle. */ fun predictedOccupancy(predictedOccupancy: String) = predictedOccupancy(JsonField.of(predictedOccupancy)) @@ -956,12 +1089,6 @@ private constructor( this.predictedOccupancy = predictedOccupancy } - /** The ID of the route for the arriving vehicle. */ - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - /** The ID of the route for the arriving vehicle. */ - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - /** * Optional route long name that potentially overrides the route long name in the * referenced route element. @@ -1001,15 +1128,6 @@ private constructor( this.scheduledArrivalInterval = scheduledArrivalInterval } - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: Long) = - scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { - this.scheduledArrivalTime = scheduledArrivalTime - } - /** Interval for scheduled departure time. */ fun scheduledDepartureInterval(scheduledDepartureInterval: String) = scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) @@ -1020,15 +1138,6 @@ private constructor( this.scheduledDepartureInterval = scheduledDepartureInterval } - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(scheduledDepartureTime: Long) = - scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { - this.scheduledDepartureTime = scheduledDepartureTime - } - /** Scheduled track information of the arriving transit vehicle. */ fun scheduledTrack(scheduledTrack: String) = scheduledTrack(JsonField.of(scheduledTrack)) @@ -1038,27 +1147,27 @@ private constructor( this.scheduledTrack = scheduledTrack } - /** - * 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - /** References to situation elements (if any) applicable to this arrival. */ fun situationIds(situationIds: List) = situationIds(JsonField.of(situationIds)) /** References to situation elements (if any) applicable to this arrival. */ fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** References to situation elements (if any) applicable to this arrival. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } } /** Current status of the arrival. */ @@ -1067,69 +1176,14 @@ private constructor( /** Current status of the arrival. */ fun status(status: JsonField) = apply { this.status = status } - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - /** The ID of the stop the vehicle is arriving at. */ - 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)) - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - 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)) - - /** Total number of stops visited on the trip for this arrival. */ - 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)) - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - 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)) - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - /** Trip-specific status for the arriving transit vehicle. */ fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(tripStatus: JsonField) = apply { - this.tripStatus = tripStatus - } - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } - + /** Trip-specific status for the arriving transit vehicle. */ + fun tripStatus(tripStatus: JsonField) = apply { + this.tripStatus = tripStatus + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1154,40 +1208,40 @@ private constructor( fun build(): Entry = Entry( + 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, - arrivalEnabled, - blockTripSequence, - departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, - numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, - predictedArrivalTime, predictedDepartureInterval, - predictedDepartureTime, predictedOccupancy, - routeId, routeLongName, routeShortName, scheduledArrivalInterval, - scheduledArrivalTime, scheduledDepartureInterval, - scheduledDepartureTime, scheduledTrack, - serviceDate, - situationIds.map { it.toImmutable() }, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, status, - stopId, - stopSequence, - totalStopsInTrip, - tripHeadsign, - tripId, tripStatus, - vehicleId, additionalProperties.toImmutable(), ) } @@ -1206,36 +1260,18 @@ private constructor( @JsonProperty("closestStop") @ExcludeMissing private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("distanceAlongTrip") @ExcludeMissing private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), @JsonProperty("lastLocationUpdateTime") @ExcludeMissing private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing private val occupancyCapacity: JsonField = JsonMissing.of(), @@ -1245,36 +1281,54 @@ private constructor( @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), @JsonProperty("phase") @ExcludeMissing private val phase: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), @JsonProperty("predicted") @ExcludeMissing private val predicted: JsonField = JsonMissing.of(), @JsonProperty("scheduleDeviation") @ExcludeMissing private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("serviceDate") @ExcludeMissing private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("vehicleId") @ExcludeMissing private val vehicleId: JsonField = JsonMissing.of(), @@ -1291,22 +1345,11 @@ private constructor( /** ID of the closest stop to the current location of the transit vehicle. */ fun closestStop(): String = closestStop.getRequired("closestStop") - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1314,14 +1357,6 @@ private constructor( fun lastKnownDistanceAlongTrip(): Double = lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - /** * Timestamp of the last known real-time location update from the transit vehicle. */ @@ -1331,17 +1366,6 @@ private constructor( /** Timestamp of the last known real-time update from the transit vehicle. */ fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") @@ -1351,17 +1375,9 @@ private constructor( /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - /** Current journey phase of the trip. */ fun phase(): String = phase.getRequired("phase") - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(): Boolean = predicted.getRequired("predicted") @@ -1370,25 +1386,12 @@ private constructor( */ fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - /** Current status modifiers for the trip. */ fun status(): String = status.getRequired("status") @@ -1396,38 +1399,82 @@ private constructor( fun totalDistanceAlongTrip(): Double = totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + fun closestStopTimeOffset(): Optional = + Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(): Optional = + Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) + + /** Last known orientation value received in real-time from the transit vehicle. */ + fun lastKnownOrientation(): Optional = + Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(): Optional = + Optional.ofNullable(nextStop.getNullable("nextStop")) + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + fun nextStopTimeOffset(): Optional = + Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(): Optional = + Optional.ofNullable(orientation.getNullable("orientation")) + + /** Current position of the transit vehicle. */ + fun position(): Optional = + Optional.ofNullable(position.getNullable("position")) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + fun scheduledDistanceAlongTrip(): Optional = + Optional.ofNullable( + scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") + ) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(): Optional> = + Optional.ofNullable(situationIds.getNullable("situationIds")) + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(): Optional = Optional.ofNullable(vehicleId.getNullable("vehicleId")) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId /** Index of the active trip into the sequence of trips for the active block. */ @JsonProperty("blockTripSequence") @ExcludeMissing - fun _blockTripSequence() = blockTripSequence + fun _blockTripSequence(): JsonField = blockTripSequence /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") + @JsonProperty("closestStop") @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset + fun _closestStop(): JsonField = closestStop /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun _distanceAlongTrip(): JsonField = distanceAlongTrip /** * Last known distance along the trip received in real-time from the transit @@ -1435,102 +1482,129 @@ private constructor( */ @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip /** * Timestamp of the last known real-time location update from the transit vehicle. */ @JsonProperty("lastLocationUpdateTime") @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime /** Timestamp of the last known real-time update from the transit vehicle. */ @JsonProperty("lastUpdateTime") @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset + fun _lastUpdateTime(): JsonField = lastUpdateTime /** Capacity of the transit vehicle in terms of occupancy. */ @JsonProperty("occupancyCapacity") @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity + fun _occupancyCapacity(): JsonField = occupancyCapacity /** Current count of occupants in the transit vehicle. */ @JsonProperty("occupancyCount") @ExcludeMissing - fun _occupancyCount() = occupancyCount + fun _occupancyCount(): JsonField = occupancyCount /** Current occupancy status of the transit vehicle. */ @JsonProperty("occupancyStatus") @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation + fun _occupancyStatus(): JsonField = occupancyStatus /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted /** * Deviation from the schedule in seconds (positive for late, negative for early). */ @JsonProperty("scheduleDeviation") @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation + fun _scheduleDeviation(): JsonField = scheduleDeviation /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. */ - @JsonProperty("scheduledDistanceAlongTrip") + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** Current status modifiers for the trip. */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** Total length of the trip, in meters. */ + @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Last known location of the transit vehicle. */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** Last known orientation value received in real-time from the transit vehicle. */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** Current position of the transit vehicle. */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") + @JsonProperty("situationIds") @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip + fun _situationIds(): JsonField> = situationIds /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId @JsonAnyGetter @ExcludeMissing @@ -1539,36 +1613,38 @@ private constructor( private var validated: Boolean = false fun validate(): TripStatus = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -1578,34 +1654,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() + /** 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 distanceAlongTrip: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() private var lastKnownLocation: JsonField = JsonMissing.of() private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() private var nextStop: JsonField = JsonMissing.of() private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1614,29 +1691,29 @@ private constructor( activeTripId = tripStatus.activeTripId blockTripSequence = tripStatus.blockTripSequence closestStop = tripStatus.closestStop - closestStopTimeOffset = tripStatus.closestStopTimeOffset distanceAlongTrip = tripStatus.distanceAlongTrip - frequency = tripStatus.frequency lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - lastKnownLocation = tripStatus.lastKnownLocation - lastKnownOrientation = tripStatus.lastKnownOrientation lastLocationUpdateTime = tripStatus.lastLocationUpdateTime lastUpdateTime = tripStatus.lastUpdateTime - nextStop = tripStatus.nextStop - nextStopTimeOffset = tripStatus.nextStopTimeOffset occupancyCapacity = tripStatus.occupancyCapacity occupancyCount = tripStatus.occupancyCount occupancyStatus = tripStatus.occupancyStatus - orientation = tripStatus.orientation phase = tripStatus.phase - position = tripStatus.position predicted = tripStatus.predicted scheduleDeviation = tripStatus.scheduleDeviation - scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip serviceDate = tripStatus.serviceDate - situationIds = tripStatus.situationIds 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() } @@ -1667,21 +1744,6 @@ private constructor( this.closestStop = closestStop } - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - /** * Distance, in meters, the transit vehicle has progressed along the active * trip. @@ -1697,14 +1759,6 @@ private constructor( this.distanceAlongTrip = distanceAlongTrip } - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1721,28 +1775,6 @@ private constructor( this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - /** * Timestamp of the last known real-time location update from the transit * vehicle. @@ -1767,27 +1799,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -1815,26 +1826,12 @@ private constructor( this.occupancyStatus = occupancyStatus } - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - /** Current journey phase of the trip. */ fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ fun phase(phase: JsonField) = apply { this.phase = phase } - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - fun position(position: JsonField) = apply { this.position = position } - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) @@ -1858,22 +1855,6 @@ private constructor( this.scheduleDeviation = scheduleDeviation } - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. @@ -1888,15 +1869,6 @@ private constructor( this.serviceDate = serviceDate } - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - /** Current status modifiers for the trip. */ fun status(status: String) = status(JsonField.of(status)) @@ -1912,6 +1884,125 @@ private constructor( 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)) + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + 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)) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: JsonField) = apply { + 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. */ + 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)) + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + 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)) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + 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)) + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + 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)) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** Current position of the transit vehicle. */ + 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)) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + 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)) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** References to situation elements (if any) applicable to this trip. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) @@ -1944,32 +2035,32 @@ private constructor( fun build(): TripStatus = TripStatus( - activeTripId, - blockTripSequence, - closestStop, + 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, - distanceAlongTrip, frequency, - lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, nextStop, nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, orientation, - phase, position, - predicted, - scheduleDeviation, scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, vehicleId, additionalProperties.toImmutable(), ) @@ -1997,10 +2088,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -2009,11 +2100,13 @@ private constructor( private var validated: Boolean = false fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -2023,7 +2116,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -2120,10 +2214,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -2132,11 +2226,13 @@ private constructor( private var validated: Boolean = false fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -2146,7 +2242,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Position]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -2225,17 +2322,17 @@ private constructor( return true } - return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "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 { @@ -2243,17 +2340,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && actualTrack == other.actualTrack && arrivalEnabled == other.arrivalEnabled && blockTripSequence == other.blockTripSequence && departureEnabled == other.departureEnabled && distanceFromStop == other.distanceFromStop && frequency == other.frequency && historicalOccupancy == other.historicalOccupancy && lastUpdateTime == other.lastUpdateTime && numberOfStopsAway == other.numberOfStopsAway && occupancyStatus == other.occupancyStatus && predicted == other.predicted && predictedArrivalInterval == other.predictedArrivalInterval && predictedArrivalTime == other.predictedArrivalTime && predictedDepartureInterval == other.predictedDepartureInterval && predictedDepartureTime == other.predictedDepartureTime && predictedOccupancy == other.predictedOccupancy && routeId == other.routeId && routeLongName == other.routeLongName && routeShortName == other.routeShortName && scheduledArrivalInterval == other.scheduledArrivalInterval && scheduledArrivalTime == other.scheduledArrivalTime && scheduledDepartureInterval == other.scheduledDepartureInterval && scheduledDepartureTime == other.scheduledDepartureTime && scheduledTrack == other.scheduledTrack && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && stopId == other.stopId && stopSequence == other.stopSequence && totalStopsInTrip == other.totalStopsInTrip && tripHeadsign == other.tripHeadsign && tripId == other.tripId && tripStatus == other.tripStatus && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(actualTrack, arrivalEnabled, blockTripSequence, departureEnabled, distanceFromStop, frequency, historicalOccupancy, lastUpdateTime, numberOfStopsAway, occupancyStatus, predicted, predictedArrivalInterval, predictedArrivalTime, predictedDepartureInterval, predictedDepartureTime, predictedOccupancy, routeId, routeLongName, routeShortName, scheduledArrivalInterval, scheduledArrivalTime, scheduledDepartureInterval, scheduledDepartureTime, scheduledTrack, serviceDate, situationIds, status, stopId, stopSequence, totalStopsInTrip, tripHeadsign, tripId, tripStatus, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{actualTrack=$actualTrack, arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, numberOfStopsAway=$numberOfStopsAway, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedArrivalTime=$predictedArrivalTime, predictedDepartureInterval=$predictedDepartureInterval, predictedDepartureTime=$predictedDepartureTime, predictedOccupancy=$predictedOccupancy, routeId=$routeId, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledDepartureTime=$scheduledDepartureTime, scheduledTrack=$scheduledTrack, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, tripStatus=$tripStatus, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "Entry{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}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt index ab76562..3acfe8b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get details of a specific block by ID */ class BlockRetrieveParams -constructor( +private constructor( private val blockId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun blockId(): String = blockId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [BlockRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var blockId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): BlockRetrieveParams = BlockRetrieveParams( - checkNotNull(blockId) { "`blockId` is required but was not set" }, + checkRequired("blockId", blockId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt index cbeff5f..1f04291 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): BlockRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [BlockRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): BlockRetrieveResponse = BlockRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -264,9 +273,11 @@ private constructor( fun configurations(): List = configurations.getRequired("configurations") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("configurations") @ExcludeMissing fun _configurations() = configurations + @JsonProperty("configurations") + @ExcludeMissing + fun _configurations(): JsonField> = configurations @JsonAnyGetter @ExcludeMissing @@ -275,11 +286,13 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - id() - configurations().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + configurations().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -289,16 +302,17 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var configurations: JsonField> = JsonMissing.of() + private var id: JsonField? = null + private var configurations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { id = entry.id - configurations = entry.configurations + configurations = entry.configurations.map { it.toMutableList() } additionalProperties = entry.additionalProperties.toMutableMap() } @@ -310,7 +324,20 @@ private constructor( configurations(JsonField.of(configurations)) fun configurations(configurations: JsonField>) = apply { - this.configurations = configurations + this.configurations = configurations.map { it.toMutableList() } + } + + fun addConfiguration(configuration: Configuration) = apply { + configurations = + (configurations ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(configuration) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -337,8 +364,8 @@ private constructor( fun build(): Entry = Entry( - id, - configurations.map { it.toImmutable() }, + checkRequired("id", id), + checkRequired("configurations", configurations).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -350,12 +377,12 @@ private constructor( @JsonProperty("activeServiceIds") @ExcludeMissing private val activeServiceIds: JsonField> = JsonMissing.of(), - @JsonProperty("inactiveServiceIds") - @ExcludeMissing - private val inactiveServiceIds: JsonField> = JsonMissing.of(), @JsonProperty("trips") @ExcludeMissing private val trips: JsonField> = JsonMissing.of(), + @JsonProperty("inactiveServiceIds") + @ExcludeMissing + private val inactiveServiceIds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -363,20 +390,20 @@ private constructor( fun activeServiceIds(): List = activeServiceIds.getRequired("activeServiceIds") + fun trips(): List = trips.getRequired("trips") + fun inactiveServiceIds(): Optional> = Optional.ofNullable(inactiveServiceIds.getNullable("inactiveServiceIds")) - fun trips(): List = trips.getRequired("trips") - @JsonProperty("activeServiceIds") @ExcludeMissing - fun _activeServiceIds() = activeServiceIds + fun _activeServiceIds(): JsonField> = activeServiceIds + + @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips @JsonProperty("inactiveServiceIds") @ExcludeMissing - fun _inactiveServiceIds() = inactiveServiceIds - - @JsonProperty("trips") @ExcludeMissing fun _trips() = trips + fun _inactiveServiceIds(): JsonField> = inactiveServiceIds @JsonAnyGetter @ExcludeMissing @@ -385,12 +412,14 @@ private constructor( private var validated: Boolean = false fun validate(): Configuration = apply { - if (!validated) { - activeServiceIds() - inactiveServiceIds() - trips().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + activeServiceIds() + trips().forEach { it.validate() } + inactiveServiceIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -400,18 +429,20 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Configuration]. */ + class Builder internal constructor() { - private var activeServiceIds: JsonField> = JsonMissing.of() - private var inactiveServiceIds: JsonField> = JsonMissing.of() - private var trips: JsonField> = JsonMissing.of() + private var activeServiceIds: JsonField>? = null + private var trips: JsonField>? = null + private var inactiveServiceIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(configuration: Configuration) = apply { - activeServiceIds = configuration.activeServiceIds - inactiveServiceIds = configuration.inactiveServiceIds - trips = configuration.trips + activeServiceIds = configuration.activeServiceIds.map { it.toMutableList() } + trips = configuration.trips.map { it.toMutableList() } + inactiveServiceIds = + configuration.inactiveServiceIds.map { it.toMutableList() } additionalProperties = configuration.additionalProperties.toMutableMap() } @@ -419,19 +450,60 @@ private constructor( activeServiceIds(JsonField.of(activeServiceIds)) fun activeServiceIds(activeServiceIds: JsonField>) = apply { - this.activeServiceIds = activeServiceIds + this.activeServiceIds = activeServiceIds.map { it.toMutableList() } + } + + fun addActiveServiceId(activeServiceId: String) = apply { + activeServiceIds = + (activeServiceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(activeServiceId) + } + } + + fun trips(trips: List) = trips(JsonField.of(trips)) + + fun trips(trips: JsonField>) = apply { + this.trips = trips.map { it.toMutableList() } + } + + fun addTrip(trip: Trip) = apply { + trips = + (trips ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(trip) + } } fun inactiveServiceIds(inactiveServiceIds: List) = inactiveServiceIds(JsonField.of(inactiveServiceIds)) fun inactiveServiceIds(inactiveServiceIds: JsonField>) = apply { - this.inactiveServiceIds = inactiveServiceIds + this.inactiveServiceIds = inactiveServiceIds.map { it.toMutableList() } } - fun trips(trips: List) = trips(JsonField.of(trips)) - - fun trips(trips: JsonField>) = apply { this.trips = trips } + fun addInactiveServiceId(inactiveServiceId: String) = apply { + inactiveServiceIds = + (inactiveServiceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(inactiveServiceId) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -457,9 +529,11 @@ private constructor( fun build(): Configuration = Configuration( - activeServiceIds.map { it.toImmutable() }, - inactiveServiceIds.map { it.toImmutable() }, - trips.map { it.toImmutable() }, + checkRequired("activeServiceIds", activeServiceIds).map { + it.toImmutable() + }, + checkRequired("trips", trips).map { it.toImmutable() }, + (inactiveServiceIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -468,46 +542,48 @@ private constructor( class Trip @JsonCreator private constructor( - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - private val distanceAlongBlock: JsonField = JsonMissing.of(), @JsonProperty("accumulatedSlackTime") @ExcludeMissing private val accumulatedSlackTime: JsonField = JsonMissing.of(), @JsonProperty("blockStopTimes") @ExcludeMissing private val blockStopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + private val distanceAlongBlock: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun tripId(): String = tripId.getRequired("tripId") - - fun distanceAlongBlock(): Double = - distanceAlongBlock.getRequired("distanceAlongBlock") - fun accumulatedSlackTime(): Double = accumulatedSlackTime.getRequired("accumulatedSlackTime") fun blockStopTimes(): List = blockStopTimes.getRequired("blockStopTimes") - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + fun distanceAlongBlock(): Double = + distanceAlongBlock.getRequired("distanceAlongBlock") - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - fun _distanceAlongBlock() = distanceAlongBlock + fun tripId(): String = tripId.getRequired("tripId") @JsonProperty("accumulatedSlackTime") @ExcludeMissing - fun _accumulatedSlackTime() = accumulatedSlackTime + fun _accumulatedSlackTime(): JsonField = accumulatedSlackTime @JsonProperty("blockStopTimes") @ExcludeMissing - fun _blockStopTimes() = blockStopTimes + fun _blockStopTimes(): JsonField> = blockStopTimes + + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + fun _distanceAlongBlock(): JsonField = distanceAlongBlock + + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId @JsonAnyGetter @ExcludeMissing @@ -516,13 +592,15 @@ private constructor( private var validated: Boolean = false fun validate(): Trip = apply { - if (!validated) { - tripId() - distanceAlongBlock() - accumulatedSlackTime() - blockStopTimes().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + accumulatedSlackTime() + blockStopTimes().forEach { it.validate() } + distanceAlongBlock() + tripId() + validated = true } fun toBuilder() = Builder().from(this) @@ -532,36 +610,25 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Trip]. */ + class Builder internal constructor() { - private var tripId: JsonField = JsonMissing.of() - private var distanceAlongBlock: JsonField = JsonMissing.of() - private var accumulatedSlackTime: JsonField = JsonMissing.of() - private var blockStopTimes: JsonField> = - JsonMissing.of() + private var accumulatedSlackTime: JsonField? = null + private var blockStopTimes: JsonField>? = null + private var distanceAlongBlock: JsonField? = null + private var tripId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(trip: Trip) = apply { - tripId = trip.tripId - distanceAlongBlock = trip.distanceAlongBlock accumulatedSlackTime = trip.accumulatedSlackTime - blockStopTimes = trip.blockStopTimes + blockStopTimes = trip.blockStopTimes.map { it.toMutableList() } + distanceAlongBlock = trip.distanceAlongBlock + tripId = trip.tripId additionalProperties = trip.additionalProperties.toMutableMap() } - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun distanceAlongBlock(distanceAlongBlock: Double) = - distanceAlongBlock(JsonField.of(distanceAlongBlock)) - - fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { - this.distanceAlongBlock = distanceAlongBlock - } - fun accumulatedSlackTime(accumulatedSlackTime: Double) = accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) @@ -573,9 +640,33 @@ private constructor( blockStopTimes(JsonField.of(blockStopTimes)) fun blockStopTimes(blockStopTimes: JsonField>) = apply { - this.blockStopTimes = blockStopTimes + this.blockStopTimes = blockStopTimes.map { it.toMutableList() } + } + + fun addBlockStopTime(blockStopTime: BlockStopTime) = apply { + blockStopTimes = + (blockStopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(blockStopTime) + } } + fun distanceAlongBlock(distanceAlongBlock: Double) = + distanceAlongBlock(JsonField.of(distanceAlongBlock)) + + fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { + this.distanceAlongBlock = distanceAlongBlock + } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -600,10 +691,12 @@ private constructor( fun build(): Trip = Trip( - tripId, - distanceAlongBlock, - accumulatedSlackTime, - blockStopTimes.map { it.toImmutable() }, + checkRequired("accumulatedSlackTime", accumulatedSlackTime), + checkRequired("blockStopTimes", blockStopTimes).map { + it.toImmutable() + }, + checkRequired("distanceAlongBlock", distanceAlongBlock), + checkRequired("tripId", tripId), additionalProperties.toImmutable(), ) } @@ -612,15 +705,15 @@ private constructor( class BlockStopTime @JsonCreator private constructor( + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + private val accumulatedSlackTime: JsonField = JsonMissing.of(), @JsonProperty("blockSequence") @ExcludeMissing private val blockSequence: JsonField = JsonMissing.of(), @JsonProperty("distanceAlongBlock") @ExcludeMissing private val distanceAlongBlock: JsonField = JsonMissing.of(), - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - private val accumulatedSlackTime: JsonField = JsonMissing.of(), @JsonProperty("stopTime") @ExcludeMissing private val stopTime: JsonField = JsonMissing.of(), @@ -629,29 +722,31 @@ private constructor( immutableEmptyMap(), ) { + fun accumulatedSlackTime(): Double = + accumulatedSlackTime.getRequired("accumulatedSlackTime") + fun blockSequence(): Long = blockSequence.getRequired("blockSequence") fun distanceAlongBlock(): Double = distanceAlongBlock.getRequired("distanceAlongBlock") - fun accumulatedSlackTime(): Double = - accumulatedSlackTime.getRequired("accumulatedSlackTime") - fun stopTime(): StopTime = stopTime.getRequired("stopTime") + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + fun _accumulatedSlackTime(): JsonField = accumulatedSlackTime + @JsonProperty("blockSequence") @ExcludeMissing - fun _blockSequence() = blockSequence + fun _blockSequence(): JsonField = blockSequence @JsonProperty("distanceAlongBlock") @ExcludeMissing - fun _distanceAlongBlock() = distanceAlongBlock + fun _distanceAlongBlock(): JsonField = distanceAlongBlock - @JsonProperty("accumulatedSlackTime") + @JsonProperty("stopTime") @ExcludeMissing - fun _accumulatedSlackTime() = accumulatedSlackTime - - @JsonProperty("stopTime") @ExcludeMissing fun _stopTime() = stopTime + fun _stopTime(): JsonField = stopTime @JsonAnyGetter @ExcludeMissing @@ -660,13 +755,15 @@ private constructor( private var validated: Boolean = false fun validate(): BlockStopTime = apply { - if (!validated) { - blockSequence() - distanceAlongBlock() - accumulatedSlackTime() - stopTime().validate() - validated = true + if (validated) { + return@apply } + + accumulatedSlackTime() + blockSequence() + distanceAlongBlock() + stopTime().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -676,25 +773,34 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [BlockStopTime]. */ + class Builder internal constructor() { - private var blockSequence: JsonField = JsonMissing.of() - private var distanceAlongBlock: JsonField = JsonMissing.of() - private var accumulatedSlackTime: JsonField = JsonMissing.of() - private var stopTime: JsonField = JsonMissing.of() + private var accumulatedSlackTime: JsonField? = null + private var blockSequence: JsonField? = null + private var distanceAlongBlock: JsonField? = null + private var stopTime: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(blockStopTime: BlockStopTime) = apply { + accumulatedSlackTime = blockStopTime.accumulatedSlackTime blockSequence = blockStopTime.blockSequence distanceAlongBlock = blockStopTime.distanceAlongBlock - accumulatedSlackTime = blockStopTime.accumulatedSlackTime stopTime = blockStopTime.stopTime additionalProperties = blockStopTime.additionalProperties.toMutableMap() } + fun accumulatedSlackTime(accumulatedSlackTime: Double) = + accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) + + fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = + apply { + this.accumulatedSlackTime = accumulatedSlackTime + } + fun blockSequence(blockSequence: Long) = blockSequence(JsonField.of(blockSequence)) @@ -709,14 +815,6 @@ private constructor( this.distanceAlongBlock = distanceAlongBlock } - fun accumulatedSlackTime(accumulatedSlackTime: Double) = - accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) - - fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = - apply { - this.accumulatedSlackTime = accumulatedSlackTime - } - fun stopTime(stopTime: StopTime) = stopTime(JsonField.of(stopTime)) fun stopTime(stopTime: JsonField) = apply { @@ -747,10 +845,10 @@ private constructor( fun build(): BlockStopTime = BlockStopTime( - blockSequence, - distanceAlongBlock, - accumulatedSlackTime, - stopTime, + checkRequired("accumulatedSlackTime", accumulatedSlackTime), + checkRequired("blockSequence", blockSequence), + checkRequired("distanceAlongBlock", distanceAlongBlock), + checkRequired("stopTime", stopTime), additionalProperties.toImmutable(), ) } @@ -759,55 +857,57 @@ private constructor( class StopTime @JsonCreator private constructor( - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), @JsonProperty("arrivalTime") @ExcludeMissing private val arrivalTime: JsonField = JsonMissing.of(), @JsonProperty("departureTime") @ExcludeMissing private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("pickupType") + @JsonProperty("stopId") @ExcludeMissing - private val pickupType: JsonField = JsonMissing.of(), + private val stopId: JsonField = JsonMissing.of(), @JsonProperty("dropOffType") @ExcludeMissing private val dropOffType: JsonField = JsonMissing.of(), + @JsonProperty("pickupType") + @ExcludeMissing + private val pickupType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun stopId(): String = stopId.getRequired("stopId") - fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") fun departureTime(): Long = departureTime.getRequired("departureTime") - fun pickupType(): Optional = - Optional.ofNullable(pickupType.getNullable("pickupType")) + fun stopId(): String = stopId.getRequired("stopId") fun dropOffType(): Optional = Optional.ofNullable(dropOffType.getNullable("dropOffType")) - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + fun pickupType(): Optional = + Optional.ofNullable(pickupType.getNullable("pickupType")) @JsonProperty("arrivalTime") @ExcludeMissing - fun _arrivalTime() = arrivalTime + fun _arrivalTime(): JsonField = arrivalTime @JsonProperty("departureTime") @ExcludeMissing - fun _departureTime() = departureTime + fun _departureTime(): JsonField = departureTime - @JsonProperty("pickupType") + @JsonProperty("stopId") @ExcludeMissing - fun _pickupType() = pickupType + fun _stopId(): JsonField = stopId @JsonProperty("dropOffType") @ExcludeMissing - fun _dropOffType() = dropOffType + fun _dropOffType(): JsonField = dropOffType + + @JsonProperty("pickupType") + @ExcludeMissing + fun _pickupType(): JsonField = pickupType @JsonAnyGetter @ExcludeMissing @@ -817,14 +917,16 @@ private constructor( private var validated: Boolean = false fun validate(): StopTime = apply { - if (!validated) { - stopId() - arrivalTime() - departureTime() - pickupType() - dropOffType() - validated = true + if (validated) { + return@apply } + + arrivalTime() + departureTime() + stopId() + dropOffType() + pickupType() + validated = true } fun toBuilder() = Builder().from(this) @@ -834,33 +936,28 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTime]. */ + class Builder internal constructor() { - private var stopId: JsonField = JsonMissing.of() - private var arrivalTime: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var pickupType: JsonField = JsonMissing.of() + private var arrivalTime: JsonField? = null + private var departureTime: JsonField? = null + private var stopId: JsonField? = null private var dropOffType: JsonField = JsonMissing.of() + private var pickupType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(stopTime: StopTime) = apply { - stopId = stopTime.stopId arrivalTime = stopTime.arrivalTime departureTime = stopTime.departureTime - pickupType = stopTime.pickupType + stopId = stopTime.stopId dropOffType = stopTime.dropOffType + pickupType = stopTime.pickupType additionalProperties = stopTime.additionalProperties.toMutableMap() } - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - fun stopId(stopId: JsonField) = apply { - this.stopId = stopId - } - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) @@ -875,11 +972,10 @@ private constructor( this.departureTime = departureTime } - fun pickupType(pickupType: Long) = - pickupType(JsonField.of(pickupType)) + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - fun pickupType(pickupType: JsonField) = apply { - this.pickupType = pickupType + fun stopId(stopId: JsonField) = apply { + this.stopId = stopId } fun dropOffType(dropOffType: Long) = @@ -889,6 +985,13 @@ private constructor( this.dropOffType = dropOffType } + fun pickupType(pickupType: Long) = + pickupType(JsonField.of(pickupType)) + + fun pickupType(pickupType: JsonField) = apply { + this.pickupType = pickupType + } + fun additionalProperties( additionalProperties: Map ) = apply { @@ -914,11 +1017,11 @@ private constructor( fun build(): StopTime = StopTime( - stopId, - arrivalTime, - departureTime, - pickupType, + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureTime", departureTime), + checkRequired("stopId", stopId), dropOffType, + pickupType, additionalProperties.toImmutable(), ) } @@ -928,17 +1031,17 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && stopId == other.stopId && arrivalTime == other.arrivalTime && departureTime == other.departureTime && pickupType == other.pickupType && dropOffType == other.dropOffType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && stopId == other.stopId && dropOffType == other.dropOffType && pickupType == other.pickupType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(stopId, arrivalTime, departureTime, pickupType, dropOffType, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, stopId, dropOffType, pickupType, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "StopTime{stopId=$stopId, arrivalTime=$arrivalTime, departureTime=$departureTime, pickupType=$pickupType, dropOffType=$dropOffType, additionalProperties=$additionalProperties}" + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, stopId=$stopId, dropOffType=$dropOffType, pickupType=$pickupType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -946,17 +1049,17 @@ private constructor( return true } - return /* spotless:off */ other is BlockStopTime && blockSequence == other.blockSequence && distanceAlongBlock == other.distanceAlongBlock && accumulatedSlackTime == other.accumulatedSlackTime && stopTime == other.stopTime && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BlockStopTime && accumulatedSlackTime == other.accumulatedSlackTime && blockSequence == other.blockSequence && distanceAlongBlock == other.distanceAlongBlock && stopTime == other.stopTime && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(blockSequence, distanceAlongBlock, accumulatedSlackTime, stopTime, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(accumulatedSlackTime, blockSequence, distanceAlongBlock, stopTime, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "BlockStopTime{blockSequence=$blockSequence, distanceAlongBlock=$distanceAlongBlock, accumulatedSlackTime=$accumulatedSlackTime, stopTime=$stopTime, additionalProperties=$additionalProperties}" + "BlockStopTime{accumulatedSlackTime=$accumulatedSlackTime, blockSequence=$blockSequence, distanceAlongBlock=$distanceAlongBlock, stopTime=$stopTime, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -964,17 +1067,17 @@ private constructor( return true } - return /* spotless:off */ other is Trip && tripId == other.tripId && distanceAlongBlock == other.distanceAlongBlock && accumulatedSlackTime == other.accumulatedSlackTime && blockStopTimes == other.blockStopTimes && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Trip && accumulatedSlackTime == other.accumulatedSlackTime && blockStopTimes == other.blockStopTimes && distanceAlongBlock == other.distanceAlongBlock && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tripId, distanceAlongBlock, accumulatedSlackTime, blockStopTimes, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(accumulatedSlackTime, blockStopTimes, distanceAlongBlock, tripId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Trip{tripId=$tripId, distanceAlongBlock=$distanceAlongBlock, accumulatedSlackTime=$accumulatedSlackTime, blockStopTimes=$blockStopTimes, additionalProperties=$additionalProperties}" + "Trip{accumulatedSlackTime=$accumulatedSlackTime, blockStopTimes=$blockStopTimes, distanceAlongBlock=$distanceAlongBlock, tripId=$tripId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -982,17 +1085,17 @@ private constructor( return true } - return /* spotless:off */ other is Configuration && activeServiceIds == other.activeServiceIds && inactiveServiceIds == other.inactiveServiceIds && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Configuration && activeServiceIds == other.activeServiceIds && trips == other.trips && inactiveServiceIds == other.inactiveServiceIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeServiceIds, inactiveServiceIds, trips, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(activeServiceIds, trips, inactiveServiceIds, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Configuration{activeServiceIds=$activeServiceIds, inactiveServiceIds=$inactiveServiceIds, trips=$trips, additionalProperties=$additionalProperties}" + "Configuration{activeServiceIds=$activeServiceIds, trips=$trips, inactiveServiceIds=$inactiveServiceIds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt index 7c58fdd..45d12c5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt @@ -4,22 +4,24 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** config */ class ConfigRetrieveParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -28,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ConfigRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt index c103b8d..36c0a69 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): ConfigRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ConfigRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): ConfigRetrieveResponse = ConfigRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -250,12 +259,12 @@ private constructor( class Entry @JsonCreator private constructor( - @JsonProperty("gitProperties") - @ExcludeMissing - private val gitProperties: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("gitProperties") + @ExcludeMissing + private val gitProperties: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -269,11 +278,11 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + fun gitProperties(): Optional = Optional.ofNullable(gitProperties.getNullable("gitProperties")) - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) fun serviceDateFrom(): Optional = @@ -282,17 +291,21 @@ private constructor( fun serviceDateTo(): Optional = Optional.ofNullable(serviceDateTo.getNullable("serviceDateTo")) - @JsonProperty("gitProperties") @ExcludeMissing fun _gitProperties() = gitProperties + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("gitProperties") + @ExcludeMissing + fun _gitProperties(): JsonField = gitProperties - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("serviceDateFrom") @ExcludeMissing - fun _serviceDateFrom() = serviceDateFrom + fun _serviceDateFrom(): JsonField = serviceDateFrom - @JsonProperty("serviceDateTo") @ExcludeMissing fun _serviceDateTo() = serviceDateTo + @JsonProperty("serviceDateTo") + @ExcludeMissing + fun _serviceDateTo(): JsonField = serviceDateTo @JsonAnyGetter @ExcludeMissing @@ -301,14 +314,16 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - gitProperties().map { it.validate() } - id() - name() - serviceDateFrom() - serviceDateTo() - validated = true + if (validated) { + return@apply } + + id() + gitProperties().ifPresent { it.validate() } + name() + serviceDateFrom() + serviceDateTo() + validated = true } fun toBuilder() = Builder().from(this) @@ -318,10 +333,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { - private var gitProperties: JsonField = JsonMissing.of() private var id: JsonField = JsonMissing.of() + private var gitProperties: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var serviceDateFrom: JsonField = JsonMissing.of() private var serviceDateTo: JsonField = JsonMissing.of() @@ -329,14 +345,18 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { - gitProperties = entry.gitProperties id = entry.id + gitProperties = entry.gitProperties name = entry.name serviceDateFrom = entry.serviceDateFrom serviceDateTo = entry.serviceDateTo additionalProperties = entry.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + fun gitProperties(gitProperties: GitProperties) = gitProperties(JsonField.of(gitProperties)) @@ -344,10 +364,6 @@ private constructor( this.gitProperties = gitProperties } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun name(name: String) = name(JsonField.of(name)) fun name(name: JsonField) = apply { this.name = name } @@ -390,8 +406,8 @@ private constructor( fun build(): Entry = Entry( - gitProperties, id, + gitProperties, name, serviceDateFrom, serviceDateTo, @@ -533,73 +549,85 @@ private constructor( fun gitTags(): Optional = Optional.ofNullable(gitTags.getNullable("git.tags")) - @JsonProperty("git.branch") @ExcludeMissing fun _gitBranch() = gitBranch + @JsonProperty("git.branch") + @ExcludeMissing + fun _gitBranch(): JsonField = gitBranch - @JsonProperty("git.build.host") @ExcludeMissing fun _gitBuildHost() = gitBuildHost + @JsonProperty("git.build.host") + @ExcludeMissing + fun _gitBuildHost(): JsonField = gitBuildHost - @JsonProperty("git.build.time") @ExcludeMissing fun _gitBuildTime() = gitBuildTime + @JsonProperty("git.build.time") + @ExcludeMissing + fun _gitBuildTime(): JsonField = gitBuildTime @JsonProperty("git.build.user.email") @ExcludeMissing - fun _gitBuildUserEmail() = gitBuildUserEmail + fun _gitBuildUserEmail(): JsonField = gitBuildUserEmail @JsonProperty("git.build.user.name") @ExcludeMissing - fun _gitBuildUserName() = gitBuildUserName + fun _gitBuildUserName(): JsonField = gitBuildUserName @JsonProperty("git.build.version") @ExcludeMissing - fun _gitBuildVersion() = gitBuildVersion + fun _gitBuildVersion(): JsonField = gitBuildVersion @JsonProperty("git.closest.tag.commit.count") @ExcludeMissing - fun _gitClosestTagCommitCount() = gitClosestTagCommitCount + fun _gitClosestTagCommitCount(): JsonField = gitClosestTagCommitCount @JsonProperty("git.closest.tag.name") @ExcludeMissing - fun _gitClosestTagName() = gitClosestTagName + fun _gitClosestTagName(): JsonField = gitClosestTagName - @JsonProperty("git.commit.id") @ExcludeMissing fun _gitCommitId() = gitCommitId + @JsonProperty("git.commit.id") + @ExcludeMissing + fun _gitCommitId(): JsonField = gitCommitId @JsonProperty("git.commit.id.abbrev") @ExcludeMissing - fun _gitCommitIdAbbrev() = gitCommitIdAbbrev + fun _gitCommitIdAbbrev(): JsonField = gitCommitIdAbbrev @JsonProperty("git.commit.id.describe") @ExcludeMissing - fun _gitCommitIdDescribe() = gitCommitIdDescribe + fun _gitCommitIdDescribe(): JsonField = gitCommitIdDescribe @JsonProperty("git.commit.id.describe-short") @ExcludeMissing - fun _gitCommitIdDescribeShort() = gitCommitIdDescribeShort + fun _gitCommitIdDescribeShort(): JsonField = gitCommitIdDescribeShort @JsonProperty("git.commit.message.full") @ExcludeMissing - fun _gitCommitMessageFull() = gitCommitMessageFull + fun _gitCommitMessageFull(): JsonField = gitCommitMessageFull @JsonProperty("git.commit.message.short") @ExcludeMissing - fun _gitCommitMessageShort() = gitCommitMessageShort + fun _gitCommitMessageShort(): JsonField = gitCommitMessageShort @JsonProperty("git.commit.time") @ExcludeMissing - fun _gitCommitTime() = gitCommitTime + fun _gitCommitTime(): JsonField = gitCommitTime @JsonProperty("git.commit.user.email") @ExcludeMissing - fun _gitCommitUserEmail() = gitCommitUserEmail + fun _gitCommitUserEmail(): JsonField = gitCommitUserEmail @JsonProperty("git.commit.user.name") @ExcludeMissing - fun _gitCommitUserName() = gitCommitUserName + fun _gitCommitUserName(): JsonField = gitCommitUserName - @JsonProperty("git.dirty") @ExcludeMissing fun _gitDirty() = gitDirty + @JsonProperty("git.dirty") + @ExcludeMissing + fun _gitDirty(): JsonField = gitDirty @JsonProperty("git.remote.origin.url") @ExcludeMissing - fun _gitRemoteOriginUrl() = gitRemoteOriginUrl + fun _gitRemoteOriginUrl(): JsonField = gitRemoteOriginUrl - @JsonProperty("git.tags") @ExcludeMissing fun _gitTags() = gitTags + @JsonProperty("git.tags") + @ExcludeMissing + fun _gitTags(): JsonField = gitTags @JsonAnyGetter @ExcludeMissing @@ -608,29 +636,31 @@ private constructor( private var validated: Boolean = false fun validate(): GitProperties = apply { - if (!validated) { - gitBranch() - gitBuildHost() - gitBuildTime() - gitBuildUserEmail() - gitBuildUserName() - gitBuildVersion() - gitClosestTagCommitCount() - gitClosestTagName() - gitCommitId() - gitCommitIdAbbrev() - gitCommitIdDescribe() - gitCommitIdDescribeShort() - gitCommitMessageFull() - gitCommitMessageShort() - gitCommitTime() - gitCommitUserEmail() - gitCommitUserName() - gitDirty() - gitRemoteOriginUrl() - gitTags() - validated = true + if (validated) { + return@apply } + + gitBranch() + gitBuildHost() + gitBuildTime() + gitBuildUserEmail() + gitBuildUserName() + gitBuildVersion() + gitClosestTagCommitCount() + gitClosestTagName() + gitCommitId() + gitCommitIdAbbrev() + gitCommitIdDescribe() + gitCommitIdDescribeShort() + gitCommitMessageFull() + gitCommitMessageShort() + gitCommitTime() + gitCommitUserEmail() + gitCommitUserName() + gitDirty() + gitRemoteOriginUrl() + gitTags() + validated = true } fun toBuilder() = Builder().from(this) @@ -640,7 +670,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [GitProperties]. */ + class Builder internal constructor() { private var gitBranch: JsonField = JsonMissing.of() private var gitBuildHost: JsonField = JsonMissing.of() @@ -894,17 +925,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && gitProperties == other.gitProperties && id == other.id && name == other.name && serviceDateFrom == other.serviceDateFrom && serviceDateTo == other.serviceDateTo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && id == other.id && gitProperties == other.gitProperties && name == other.name && serviceDateFrom == other.serviceDateFrom && serviceDateTo == other.serviceDateTo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(gitProperties, id, name, serviceDateFrom, serviceDateTo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, gitProperties, name, serviceDateFrom, serviceDateTo, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{gitProperties=$gitProperties, id=$id, name=$name, serviceDateFrom=$serviceDateFrom, serviceDateTo=$serviceDateTo, additionalProperties=$additionalProperties}" + "Entry{id=$id, gitProperties=$gitProperties, name=$name, serviceDateFrom=$serviceDateFrom, serviceDateTo=$serviceDateTo, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt index b296308..dfc8416 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt @@ -4,22 +4,24 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** current-time */ class CurrentTimeRetrieveParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -28,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [CurrentTimeRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt index cd1538b..328b9a3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): CurrentTimeRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CurrentTimeRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): CurrentTimeRetrieveResponse = CurrentTimeRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -265,9 +274,11 @@ private constructor( fun time(): Optional = Optional.ofNullable(time.getNullable("time")) - @JsonProperty("readableTime") @ExcludeMissing fun _readableTime() = readableTime + @JsonProperty("readableTime") + @ExcludeMissing + fun _readableTime(): JsonField = readableTime - @JsonProperty("time") @ExcludeMissing fun _time() = time + @JsonProperty("time") @ExcludeMissing fun _time(): JsonField = time @JsonAnyGetter @ExcludeMissing @@ -276,11 +287,13 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - readableTime() - time() - validated = true + if (validated) { + return@apply } + + readableTime() + time() + validated = true } fun toBuilder() = Builder().from(this) @@ -290,7 +303,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { private var readableTime: JsonField = JsonMissing.of() private var time: JsonField = JsonMissing.of() 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 5bd60d2..3f3b947 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 @@ -14,6 +14,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable import org.onebusaway.errors.OnebusawaySdkInvalidDataException @@ -31,12 +32,12 @@ private constructor( @JsonProperty("situations") @ExcludeMissing private val situations: JsonField> = JsonMissing.of(), - @JsonProperty("stopTimes") - @ExcludeMissing - private val stopTimes: JsonField> = JsonMissing.of(), @JsonProperty("stops") @ExcludeMissing private val stops: JsonField> = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + private val stopTimes: JsonField> = JsonMissing.of(), @JsonProperty("trips") @ExcludeMissing private val trips: JsonField> = JsonMissing.of(), @@ -49,23 +50,27 @@ private constructor( fun situations(): List = situations.getRequired("situations") - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - fun stops(): List = stops.getRequired("stops") + fun stopTimes(): List = stopTimes.getRequired("stopTimes") + fun trips(): List = trips.getRequired("trips") - @JsonProperty("agencies") @ExcludeMissing fun _agencies() = agencies + @JsonProperty("agencies") @ExcludeMissing fun _agencies(): JsonField> = agencies - @JsonProperty("routes") @ExcludeMissing fun _routes() = routes + @JsonProperty("routes") @ExcludeMissing fun _routes(): JsonField> = routes - @JsonProperty("situations") @ExcludeMissing fun _situations() = situations + @JsonProperty("situations") + @ExcludeMissing + fun _situations(): JsonField> = situations - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes + @JsonProperty("stops") @ExcludeMissing fun _stops(): JsonField> = stops - @JsonProperty("stops") @ExcludeMissing fun _stops() = stops + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes - @JsonProperty("trips") @ExcludeMissing fun _trips() = trips + @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips @JsonAnyGetter @ExcludeMissing @@ -74,15 +79,17 @@ private constructor( private var validated: Boolean = false fun validate(): References = apply { - if (!validated) { - agencies().forEach { it.validate() } - routes().forEach { it.validate() } - situations().forEach { it.validate() } - stopTimes().forEach { it.validate() } - stops().forEach { it.validate() } - trips().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + agencies().forEach { it.validate() } + routes().forEach { it.validate() } + situations().forEach { it.validate() } + stops().forEach { it.validate() } + stopTimes().forEach { it.validate() } + trips().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -92,52 +99,141 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [References]. */ + class Builder internal constructor() { - private var agencies: JsonField> = JsonMissing.of() - private var routes: JsonField> = JsonMissing.of() - private var situations: JsonField> = JsonMissing.of() - private var stopTimes: JsonField> = JsonMissing.of() - private var stops: JsonField> = JsonMissing.of() - private var trips: JsonField> = JsonMissing.of() + private var agencies: JsonField>? = null + private var routes: JsonField>? = null + private var situations: JsonField>? = null + private var stops: JsonField>? = null + private var stopTimes: JsonField>? = null + private var trips: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(references: References) = apply { - agencies = references.agencies - routes = references.routes - situations = references.situations - stopTimes = references.stopTimes - stops = references.stops - trips = references.trips + agencies = references.agencies.map { it.toMutableList() } + routes = references.routes.map { it.toMutableList() } + situations = references.situations.map { it.toMutableList() } + stops = references.stops.map { it.toMutableList() } + stopTimes = references.stopTimes.map { it.toMutableList() } + trips = references.trips.map { it.toMutableList() } additionalProperties = references.additionalProperties.toMutableMap() } fun agencies(agencies: List) = agencies(JsonField.of(agencies)) - fun agencies(agencies: JsonField>) = apply { this.agencies = agencies } + fun agencies(agencies: JsonField>) = apply { + this.agencies = agencies.map { it.toMutableList() } + } + + fun addAgency(agency: Agency) = apply { + agencies = + (agencies ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(agency) + } + } fun routes(routes: List) = routes(JsonField.of(routes)) - fun routes(routes: JsonField>) = apply { this.routes = routes } + fun routes(routes: JsonField>) = apply { + this.routes = routes.map { it.toMutableList() } + } + + fun addRoute(route: Route) = apply { + routes = + (routes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(route) + } + } fun situations(situations: List) = situations(JsonField.of(situations)) fun situations(situations: JsonField>) = apply { - this.situations = situations + this.situations = situations.map { it.toMutableList() } } - fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - - fun stopTimes(stopTimes: JsonField>) = apply { this.stopTimes = stopTimes } + fun addSituation(situation: Situation) = apply { + situations = + (situations ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situation) + } + } fun stops(stops: List) = stops(JsonField.of(stops)) - fun stops(stops: JsonField>) = apply { this.stops = stops } + fun stops(stops: JsonField>) = apply { + this.stops = stops.map { it.toMutableList() } + } + + fun addStop(stop: Stop) = apply { + stops = + (stops ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stop) + } + } + + fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) + + fun stopTimes(stopTimes: JsonField>) = apply { + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopTime) + } + } fun trips(trips: List) = trips(JsonField.of(trips)) - fun trips(trips: JsonField>) = apply { this.trips = trips } + fun trips(trips: JsonField>) = apply { + this.trips = trips.map { it.toMutableList() } + } + + fun addTrip(trip: Trip) = apply { + trips = + (trips ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(trip) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -160,12 +256,12 @@ private constructor( fun build(): References = References( - agencies.map { it.toImmutable() }, - routes.map { it.toImmutable() }, - situations.map { it.toImmutable() }, - stopTimes.map { it.toImmutable() }, - stops.map { it.toImmutable() }, - trips.map { it.toImmutable() }, + checkRequired("agencies", agencies).map { it.toImmutable() }, + checkRequired("routes", routes).map { it.toImmutable() }, + checkRequired("situations", situations).map { it.toImmutable() }, + checkRequired("stops", stops).map { it.toImmutable() }, + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("trips", trips).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -174,6 +270,14 @@ private constructor( class Agency @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + private val timezone: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @JsonProperty("disclaimer") @ExcludeMissing private val disclaimer: JsonField = JsonMissing.of(), @@ -183,27 +287,27 @@ private constructor( @JsonProperty("fareUrl") @ExcludeMissing private val fareUrl: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lang") @ExcludeMissing private val lang: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), @JsonProperty("phone") @ExcludeMissing private val phone: JsonField = JsonMissing.of(), @JsonProperty("privateService") @ExcludeMissing private val privateService: JsonField = JsonMissing.of(), - @JsonProperty("timezone") - @ExcludeMissing - private val timezone: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + + fun name(): String = name.getRequired("name") + + fun timezone(): String = timezone.getRequired("timezone") + + fun url(): String = url.getRequired("url") + fun disclaimer(): Optional = Optional.ofNullable(disclaimer.getNullable("disclaimer")) @@ -211,40 +315,36 @@ private constructor( fun fareUrl(): Optional = Optional.ofNullable(fareUrl.getNullable("fareUrl")) - fun id(): String = id.getRequired("id") - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - fun name(): String = name.getRequired("name") - fun phone(): Optional = Optional.ofNullable(phone.getNullable("phone")) fun privateService(): Optional = Optional.ofNullable(privateService.getNullable("privateService")) - fun timezone(): String = timezone.getRequired("timezone") - - fun url(): String = url.getRequired("url") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("disclaimer") @ExcludeMissing fun _disclaimer() = disclaimer + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone - @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl() = fareUrl + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang + @JsonProperty("disclaimer") + @ExcludeMissing + fun _disclaimer(): JsonField = disclaimer - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - @JsonProperty("phone") @ExcludeMissing fun _phone() = phone + @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl(): JsonField = fareUrl - @JsonProperty("privateService") @ExcludeMissing fun _privateService() = privateService + @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang - @JsonProperty("timezone") @ExcludeMissing fun _timezone() = timezone + @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("privateService") + @ExcludeMissing + fun _privateService(): JsonField = privateService @JsonAnyGetter @ExcludeMissing @@ -253,19 +353,21 @@ private constructor( private var validated: Boolean = false fun validate(): Agency = apply { - if (!validated) { - disclaimer() - email() - fareUrl() - id() - lang() - name() - phone() - privateService() - timezone() - url() - validated = true - } + if (validated) { + return@apply + } + + id() + name() + timezone() + url() + disclaimer() + email() + fareUrl() + lang() + phone() + privateService() + validated = true } fun toBuilder() = Builder().from(this) @@ -275,35 +377,52 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Agency]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var name: JsonField? = null + private var timezone: JsonField? = null + private var url: JsonField? = null private var disclaimer: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() private var fareUrl: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var lang: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() private var phone: JsonField = JsonMissing.of() private var privateService: JsonField = JsonMissing.of() - private var timezone: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(agency: Agency) = apply { + id = agency.id + name = agency.name + timezone = agency.timezone + url = agency.url disclaimer = agency.disclaimer email = agency.email fareUrl = agency.fareUrl - id = agency.id lang = agency.lang - name = agency.name phone = agency.phone privateService = agency.privateService - timezone = agency.timezone - url = agency.url additionalProperties = agency.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + + fun url(url: String) = url(JsonField.of(url)) + + fun url(url: JsonField) = apply { this.url = url } + fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) fun disclaimer(disclaimer: JsonField) = apply { this.disclaimer = disclaimer } @@ -316,18 +435,10 @@ private constructor( fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun lang(lang: String) = lang(JsonField.of(lang)) fun lang(lang: JsonField) = apply { this.lang = lang } - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - fun phone(phone: String) = phone(JsonField.of(phone)) fun phone(phone: JsonField) = apply { this.phone = phone } @@ -339,14 +450,6 @@ private constructor( this.privateService = privateService } - fun timezone(timezone: String) = timezone(JsonField.of(timezone)) - - fun timezone(timezone: JsonField) = apply { this.timezone = timezone } - - fun url(url: String) = url(JsonField.of(url)) - - fun url(url: JsonField) = apply { this.url = url } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -368,16 +471,16 @@ private constructor( fun build(): Agency = Agency( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("timezone", timezone), + checkRequired("url", url), disclaimer, email, fareUrl, - id, lang, - name, phone, privateService, - timezone, - url, additionalProperties.toImmutable(), ) } @@ -387,33 +490,34 @@ private constructor( return true } - return /* spotless:off */ other is Agency && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && id == other.id && lang == other.lang && name == other.name && phone == other.phone && privateService == other.privateService && timezone == other.timezone && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Agency && id == other.id && name == other.name && timezone == other.timezone && url == other.url && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && lang == other.lang && phone == other.phone && privateService == other.privateService && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(disclaimer, email, fareUrl, id, lang, name, phone, privateService, timezone, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, timezone, url, disclaimer, email, fareUrl, lang, phone, privateService, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Agency{disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, id=$id, lang=$lang, name=$name, phone=$phone, privateService=$privateService, timezone=$timezone, url=$url, additionalProperties=$additionalProperties}" + "Agency{id=$id, name=$name, timezone=$timezone, url=$url, disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, lang=$lang, phone=$phone, privateService=$privateService, additionalProperties=$additionalProperties}" } @NoAutoDetect class Route @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("agencyId") @ExcludeMissing private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("longName") @ExcludeMissing private val longName: JsonField = JsonMissing.of(), @@ -426,21 +530,22 @@ private constructor( @JsonProperty("textColor") @ExcludeMissing private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + fun agencyId(): String = agencyId.getRequired("agencyId") + fun type(): Long = type.getRequired("type") + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun id(): String = id.getRequired("id") - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) fun nullSafeShortName(): Optional = @@ -450,31 +555,31 @@ private constructor( fun textColor(): Optional = Optional.ofNullable(textColor.getNullable("textColor")) - fun type(): Long = type.getRequired("type") - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("color") @ExcludeMissing fun _color() = color + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName @JsonProperty("nullSafeShortName") @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName + fun _nullSafeShortName(): JsonField = nullSafeShortName - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor + @JsonProperty("shortName") @ExcludeMissing fun _shortName(): JsonField = shortName - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("textColor") @ExcludeMissing fun _textColor(): JsonField = textColor - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -483,19 +588,21 @@ private constructor( private var validated: Boolean = false fun validate(): Route = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true - } + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true } fun toBuilder() = Builder().from(this) @@ -505,39 +612,48 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Route]. */ + class Builder internal constructor() { - private var agencyId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null private var color: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var longName: JsonField = JsonMissing.of() private var nullSafeShortName: JsonField = JsonMissing.of() private var shortName: JsonField = JsonMissing.of() private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(route: Route) = apply { + id = route.id agencyId = route.agencyId + type = route.type color = route.color description = route.description - id = route.id longName = route.longName nullSafeShortName = route.nullSafeShortName shortName = route.shortName textColor = route.textColor - type = route.type url = route.url additionalProperties = route.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + fun type(type: Long) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun color(color: String) = color(JsonField.of(color)) fun color(color: JsonField) = apply { this.color = color } @@ -548,10 +664,6 @@ private constructor( this.description = description } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun longName(longName: String) = longName(JsonField.of(longName)) fun longName(longName: JsonField) = apply { this.longName = longName } @@ -571,10 +683,6 @@ private constructor( fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - fun url(url: String) = url(JsonField.of(url)) fun url(url: JsonField) = apply { this.url = url } @@ -600,15 +708,15 @@ private constructor( fun build(): Route = Route( - agencyId, + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), color, description, - id, longName, nullSafeShortName, shortName, textColor, - type, url, additionalProperties.toImmutable(), ) @@ -619,17 +727,17 @@ private constructor( return true } - return /* spotless:off */ other is Route && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Route && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Route{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" + "Route{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" } @NoAutoDetect @@ -640,34 +748,34 @@ private constructor( @JsonProperty("creationTime") @ExcludeMissing private val creationTime: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("summary") - @ExcludeMissing - private val summary: JsonField

= JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @JsonProperty("activeWindows") @ExcludeMissing private val activeWindows: JsonField> = JsonMissing.of(), @JsonProperty("allAffects") @ExcludeMissing private val allAffects: JsonField> = JsonMissing.of(), + @JsonProperty("consequenceMessage") + @ExcludeMissing + private val consequenceMessage: JsonField = JsonMissing.of(), @JsonProperty("consequences") @ExcludeMissing private val consequences: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), @JsonProperty("publicationWindows") @ExcludeMissing private val publicationWindows: JsonField> = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), @JsonProperty("severity") @ExcludeMissing private val severity: JsonField = JsonMissing.of(), - @JsonProperty("consequenceMessage") + @JsonProperty("summary") @ExcludeMissing - private val consequenceMessage: JsonField = JsonMissing.of(), + private val summary: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -678,67 +786,77 @@ private constructor( /** Unix timestamp of when this situation was created. */ fun creationTime(): Long = creationTime.getRequired("creationTime") - /** Reason for the service alert, taken from TPEG codes. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - fun summary(): Optional = Optional.ofNullable(summary.getNullable("summary")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - fun activeWindows(): Optional> = Optional.ofNullable(activeWindows.getNullable("activeWindows")) fun allAffects(): Optional> = Optional.ofNullable(allAffects.getNullable("allAffects")) + /** Message regarding the consequence of the situation. */ + fun consequenceMessage(): Optional = + Optional.ofNullable(consequenceMessage.getNullable("consequenceMessage")) + fun consequences(): Optional> = Optional.ofNullable(consequences.getNullable("consequences")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + fun publicationWindows(): Optional> = Optional.ofNullable(publicationWindows.getNullable("publicationWindows")) + /** Reason for the service alert, taken from TPEG codes. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + /** Severity of the situation. */ fun severity(): Optional = Optional.ofNullable(severity.getNullable("severity")) - /** Message regarding the consequence of the situation. */ - fun consequenceMessage(): Optional = - Optional.ofNullable(consequenceMessage.getNullable("consequenceMessage")) + fun summary(): Optional = Optional.ofNullable(summary.getNullable("summary")) + + fun url(): Optional = Optional.ofNullable(url.getNullable("url")) /** Unique identifier for the situation. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Unix timestamp of when this situation was created. */ - @JsonProperty("creationTime") @ExcludeMissing fun _creationTime() = creationTime - - /** Reason for the service alert, taken from TPEG codes. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason - - @JsonProperty("summary") @ExcludeMissing fun _summary() = summary + @JsonProperty("creationTime") + @ExcludeMissing + fun _creationTime(): JsonField = creationTime - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("activeWindows") + @ExcludeMissing + fun _activeWindows(): JsonField> = activeWindows - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("allAffects") + @ExcludeMissing + fun _allAffects(): JsonField> = allAffects - @JsonProperty("activeWindows") @ExcludeMissing fun _activeWindows() = activeWindows + /** Message regarding the consequence of the situation. */ + @JsonProperty("consequenceMessage") + @ExcludeMissing + fun _consequenceMessage(): JsonField = consequenceMessage - @JsonProperty("allAffects") @ExcludeMissing fun _allAffects() = allAffects + @JsonProperty("consequences") + @ExcludeMissing + fun _consequences(): JsonField> = consequences - @JsonProperty("consequences") @ExcludeMissing fun _consequences() = consequences + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonProperty("publicationWindows") @ExcludeMissing - fun _publicationWindows() = publicationWindows + fun _publicationWindows(): JsonField> = publicationWindows + + /** Reason for the service alert, taken from TPEG codes. */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** Severity of the situation. */ - @JsonProperty("severity") @ExcludeMissing fun _severity() = severity + @JsonProperty("severity") @ExcludeMissing fun _severity(): JsonField = severity - /** Message regarding the consequence of the situation. */ - @JsonProperty("consequenceMessage") - @ExcludeMissing - fun _consequenceMessage() = consequenceMessage + @JsonProperty("summary") @ExcludeMissing fun _summary(): JsonField = summary + + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -747,21 +865,23 @@ private constructor( private var validated: Boolean = false fun validate(): Situation = apply { - if (!validated) { - id() - creationTime() - reason() - summary().map { it.validate() } - description().map { it.validate() } - url().map { it.validate() } - activeWindows().map { it.forEach { it.validate() } } - allAffects().map { it.forEach { it.validate() } } - consequences().map { it.forEach { it.validate() } } - publicationWindows().map { it.forEach { it.validate() } } - severity() - consequenceMessage() - validated = true - } + if (validated) { + return@apply + } + + id() + creationTime() + activeWindows().ifPresent { it.forEach { it.validate() } } + allAffects().ifPresent { it.forEach { it.validate() } } + consequenceMessage() + consequences().ifPresent { it.forEach { it.validate() } } + description().ifPresent { it.validate() } + publicationWindows().ifPresent { it.forEach { it.validate() } } + reason() + severity() + summary().ifPresent { it.validate() } + url().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -771,36 +891,37 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Situation]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var creationTime: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var creationTime: JsonField? = null + private var activeWindows: JsonField>? = null + private var allAffects: JsonField>? = null + private var consequenceMessage: JsonField = JsonMissing.of() + private var consequences: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var publicationWindows: JsonField>? = null private var reason: JsonField = JsonMissing.of() + private var severity: JsonField = JsonMissing.of() private var summary: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() - private var activeWindows: JsonField> = JsonMissing.of() - private var allAffects: JsonField> = JsonMissing.of() - private var consequences: JsonField> = JsonMissing.of() - private var publicationWindows: JsonField> = JsonMissing.of() - private var severity: JsonField = JsonMissing.of() - private var consequenceMessage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(situation: Situation) = apply { id = situation.id creationTime = situation.creationTime + activeWindows = situation.activeWindows.map { it.toMutableList() } + allAffects = situation.allAffects.map { it.toMutableList() } + consequenceMessage = situation.consequenceMessage + consequences = situation.consequences.map { it.toMutableList() } + description = situation.description + publicationWindows = situation.publicationWindows.map { it.toMutableList() } reason = situation.reason + severity = situation.severity summary = situation.summary - description = situation.description url = situation.url - activeWindows = situation.activeWindows - allAffects = situation.allAffects - consequences = situation.consequences - publicationWindows = situation.publicationWindows - severity = situation.severity - consequenceMessage = situation.consequenceMessage additionalProperties = situation.additionalProperties.toMutableMap() } @@ -818,67 +939,119 @@ private constructor( this.creationTime = creationTime } - /** Reason for the service alert, taken from TPEG codes. */ - fun reason(reason: Reason) = reason(JsonField.of(reason)) + fun activeWindows(activeWindows: List) = + activeWindows(JsonField.of(activeWindows)) - /** Reason for the service alert, taken from TPEG codes. */ - fun reason(reason: JsonField) = apply { this.reason = reason } + fun activeWindows(activeWindows: JsonField>) = apply { + this.activeWindows = activeWindows.map { it.toMutableList() } + } - fun summary(summary: Summary) = summary(JsonField.of(summary)) + fun addActiveWindow(activeWindow: ActiveWindow) = apply { + activeWindows = + (activeWindows ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(activeWindow) + } + } - fun summary(summary: JsonField) = apply { this.summary = summary } + fun allAffects(allAffects: List) = allAffects(JsonField.of(allAffects)) - fun description(description: Description) = description(JsonField.of(description)) + fun allAffects(allAffects: JsonField>) = apply { + this.allAffects = allAffects.map { it.toMutableList() } + } - fun description(description: JsonField) = apply { - this.description = description + fun addAllAffect(allAffect: AllAffect) = apply { + allAffects = + (allAffects ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(allAffect) + } } - fun url(url: Url) = url(JsonField.of(url)) + /** Message regarding the consequence of the situation. */ + fun consequenceMessage(consequenceMessage: String) = + consequenceMessage(JsonField.of(consequenceMessage)) - fun url(url: JsonField) = apply { this.url = url } + /** Message regarding the consequence of the situation. */ + fun consequenceMessage(consequenceMessage: JsonField) = apply { + this.consequenceMessage = consequenceMessage + } - fun activeWindows(activeWindows: List) = - activeWindows(JsonField.of(activeWindows)) + fun consequences(consequences: List) = + consequences(JsonField.of(consequences)) - fun activeWindows(activeWindows: JsonField>) = apply { - this.activeWindows = activeWindows + fun consequences(consequences: JsonField>) = apply { + this.consequences = consequences.map { it.toMutableList() } } - fun allAffects(allAffects: List) = allAffects(JsonField.of(allAffects)) - - fun allAffects(allAffects: JsonField>) = apply { - this.allAffects = allAffects + fun addConsequence(consequence: Consequence) = apply { + consequences = + (consequences ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(consequence) + } } - fun consequences(consequences: List) = - consequences(JsonField.of(consequences)) + fun description(description: Description) = description(JsonField.of(description)) - fun consequences(consequences: JsonField>) = apply { - this.consequences = consequences + fun description(description: JsonField) = apply { + this.description = description } fun publicationWindows(publicationWindows: List) = publicationWindows(JsonField.of(publicationWindows)) fun publicationWindows(publicationWindows: JsonField>) = apply { - this.publicationWindows = publicationWindows + this.publicationWindows = publicationWindows.map { it.toMutableList() } + } + + fun addPublicationWindow(publicationWindow: PublicationWindow) = apply { + publicationWindows = + (publicationWindows ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(publicationWindow) + } } + /** Reason for the service alert, taken from TPEG codes. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** Reason for the service alert, taken from TPEG codes. */ + fun reason(reason: JsonField) = apply { this.reason = reason } + /** Severity of the situation. */ fun severity(severity: String) = severity(JsonField.of(severity)) /** Severity of the situation. */ fun severity(severity: JsonField) = apply { this.severity = severity } - /** Message regarding the consequence of the situation. */ - fun consequenceMessage(consequenceMessage: String) = - consequenceMessage(JsonField.of(consequenceMessage)) + fun summary(summary: Summary) = summary(JsonField.of(summary)) - /** Message regarding the consequence of the situation. */ - fun consequenceMessage(consequenceMessage: JsonField) = apply { - this.consequenceMessage = consequenceMessage - } + fun summary(summary: JsonField) = apply { this.summary = summary } + + fun url(url: Url) = url(JsonField.of(url)) + + fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -901,18 +1074,18 @@ private constructor( fun build(): Situation = Situation( - id, - creationTime, + checkRequired("id", id), + checkRequired("creationTime", creationTime), + (activeWindows ?: JsonMissing.of()).map { it.toImmutable() }, + (allAffects ?: JsonMissing.of()).map { it.toImmutable() }, + consequenceMessage, + (consequences ?: JsonMissing.of()).map { it.toImmutable() }, + description, + (publicationWindows ?: JsonMissing.of()).map { it.toImmutable() }, reason, + severity, summary, - description, url, - activeWindows.map { it.toImmutable() }, - allAffects.map { it.toImmutable() }, - consequences.map { it.toImmutable() }, - publicationWindows.map { it.toImmutable() }, - severity, - consequenceMessage, additionalProperties.toImmutable(), ) } @@ -936,10 +1109,10 @@ private constructor( fun to(): Optional = Optional.ofNullable(to.getNullable("to")) /** Start time of the active window as a Unix timestamp. */ - @JsonProperty("from") @ExcludeMissing fun _from() = from + @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from /** End time of the active window as a Unix timestamp. */ - @JsonProperty("to") @ExcludeMissing fun _to() = to + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to @JsonAnyGetter @ExcludeMissing @@ -948,11 +1121,13 @@ private constructor( private var validated: Boolean = false fun validate(): ActiveWindow = apply { - if (!validated) { - from() - to() - validated = true + if (validated) { + return@apply } + + from() + to() + validated = true } fun toBuilder() = Builder().from(this) @@ -962,7 +1137,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ActiveWindow]. */ + class Builder internal constructor() { private var from: JsonField = JsonMissing.of() private var to: JsonField = JsonMissing.of() @@ -1082,22 +1258,26 @@ private constructor( fun tripId(): Optional = Optional.ofNullable(tripId.getNullable("tripId")) /** Identifier for the agency. */ - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId /** Identifier for the application. */ - @JsonProperty("applicationId") @ExcludeMissing fun _applicationId() = applicationId + @JsonProperty("applicationId") + @ExcludeMissing + fun _applicationId(): JsonField = applicationId /** Identifier for the direction. */ - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId + @JsonProperty("directionId") + @ExcludeMissing + fun _directionId(): JsonField = directionId /** Identifier for the route. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId /** Identifier for the stop. */ - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId /** Identifier for the trip. */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId @JsonAnyGetter @ExcludeMissing @@ -1106,15 +1286,17 @@ private constructor( private var validated: Boolean = false fun validate(): AllAffect = apply { - if (!validated) { - agencyId() - applicationId() - directionId() - routeId() - stopId() - tripId() - validated = true + if (validated) { + return@apply } + + agencyId() + applicationId() + directionId() + routeId() + stopId() + tripId() + validated = true } fun toBuilder() = Builder().from(this) @@ -1124,7 +1306,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AllAffect]. */ + class Builder internal constructor() { private var agencyId: JsonField = JsonMissing.of() private var applicationId: JsonField = JsonMissing.of() @@ -1260,11 +1443,13 @@ private constructor( Optional.ofNullable(conditionDetails.getNullable("conditionDetails")) /** Condition of the consequence. */ - @JsonProperty("condition") @ExcludeMissing fun _condition() = condition + @JsonProperty("condition") + @ExcludeMissing + fun _condition(): JsonField = condition @JsonProperty("conditionDetails") @ExcludeMissing - fun _conditionDetails() = conditionDetails + fun _conditionDetails(): JsonField = conditionDetails @JsonAnyGetter @ExcludeMissing @@ -1273,11 +1458,13 @@ private constructor( private var validated: Boolean = false fun validate(): Consequence = apply { - if (!validated) { - condition() - conditionDetails().map { it.validate() } - validated = true + if (validated) { + return@apply } + + condition() + conditionDetails().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -1287,7 +1474,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Consequence]. */ + class Builder internal constructor() { private var condition: JsonField = JsonMissing.of() private var conditionDetails: JsonField = JsonMissing.of() @@ -1363,11 +1551,13 @@ private constructor( fun diversionStopIds(): Optional> = Optional.ofNullable(diversionStopIds.getNullable("diversionStopIds")) - @JsonProperty("diversionPath") @ExcludeMissing fun _diversionPath() = diversionPath + @JsonProperty("diversionPath") + @ExcludeMissing + fun _diversionPath(): JsonField = diversionPath @JsonProperty("diversionStopIds") @ExcludeMissing - fun _diversionStopIds() = diversionStopIds + fun _diversionStopIds(): JsonField> = diversionStopIds @JsonAnyGetter @ExcludeMissing @@ -1376,11 +1566,13 @@ private constructor( private var validated: Boolean = false fun validate(): ConditionDetails = apply { - if (!validated) { - diversionPath().map { it.validate() } - diversionStopIds() - validated = true + if (validated) { + return@apply } + + diversionPath().ifPresent { it.validate() } + diversionStopIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -1390,16 +1582,18 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ConditionDetails]. */ + class Builder internal constructor() { private var diversionPath: JsonField = JsonMissing.of() - private var diversionStopIds: JsonField> = JsonMissing.of() + private var diversionStopIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(conditionDetails: ConditionDetails) = apply { diversionPath = conditionDetails.diversionPath - diversionStopIds = conditionDetails.diversionStopIds + diversionStopIds = + conditionDetails.diversionStopIds.map { it.toMutableList() } additionalProperties = conditionDetails.additionalProperties.toMutableMap() } @@ -1414,7 +1608,20 @@ private constructor( diversionStopIds(JsonField.of(diversionStopIds)) fun diversionStopIds(diversionStopIds: JsonField>) = apply { - this.diversionStopIds = diversionStopIds + this.diversionStopIds = diversionStopIds.map { it.toMutableList() } + } + + fun addDiversionStopId(diversionStopId: String) = apply { + diversionStopIds = + (diversionStopIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(diversionStopId) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1442,7 +1649,7 @@ private constructor( fun build(): ConditionDetails = ConditionDetails( diversionPath, - diversionStopIds.map { it.toImmutable() }, + (diversionStopIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -1476,13 +1683,17 @@ private constructor( Optional.ofNullable(points.getNullable("points")) /** Length of the diversion path. */ - @JsonProperty("length") @ExcludeMissing fun _length() = length + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length /** Levels of the diversion path. */ - @JsonProperty("levels") @ExcludeMissing fun _levels() = levels + @JsonProperty("levels") + @ExcludeMissing + fun _levels(): JsonField = levels /** Points of the diversion path. */ - @JsonProperty("points") @ExcludeMissing fun _points() = points + @JsonProperty("points") + @ExcludeMissing + fun _points(): JsonField = points @JsonAnyGetter @ExcludeMissing @@ -1491,12 +1702,14 @@ private constructor( private var validated: Boolean = false fun validate(): DiversionPath = apply { - if (!validated) { - length() - levels() - points() - validated = true + if (validated) { + return@apply } + + length() + levels() + points() + validated = true } fun toBuilder() = Builder().from(this) @@ -1506,7 +1719,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DiversionPath]. */ + class Builder internal constructor() { private var length: JsonField = JsonMissing.of() private var levels: JsonField = JsonMissing.of() @@ -1646,10 +1860,10 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** Language of the description. */ - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang + @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang /** Longer description of the situation. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1658,11 +1872,13 @@ private constructor( private var validated: Boolean = false fun validate(): Description = apply { - if (!validated) { - lang() - value() - validated = true + if (validated) { + return@apply } + + lang() + value() + validated = true } fun toBuilder() = Builder().from(this) @@ -1672,7 +1888,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Description]. */ + class Builder internal constructor() { private var lang: JsonField = JsonMissing.of() private var value: JsonField = JsonMissing.of() @@ -1764,10 +1981,10 @@ private constructor( fun to(): Long = to.getRequired("to") /** Start time of the time window as a Unix timestamp. */ - @JsonProperty("from") @ExcludeMissing fun _from() = from + @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from /** End time of the time window as a Unix timestamp. */ - @JsonProperty("to") @ExcludeMissing fun _to() = to + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to @JsonAnyGetter @ExcludeMissing @@ -1776,11 +1993,13 @@ private constructor( private var validated: Boolean = false fun validate(): PublicationWindow = apply { - if (!validated) { - from() - to() - validated = true + if (validated) { + return@apply } + + from() + to() + validated = true } fun toBuilder() = Builder().from(this) @@ -1790,10 +2009,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PublicationWindow]. */ + class Builder internal constructor() { - private var from: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() + private var from: JsonField? = null + private var to: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1839,8 +2059,8 @@ private constructor( fun build(): PublicationWindow = PublicationWindow( - from, - to, + checkRequired("from", from), + checkRequired("to", to), additionalProperties.toImmutable(), ) } @@ -1863,12 +2083,21 @@ 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 { @@ -1886,6 +2115,7 @@ private constructor( @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) } + /** An enum containing [Reason]'s known values. */ enum class Known { EQUIPMENT_REASON, ENVIRONMENT_REASON, @@ -1894,15 +2124,34 @@ private constructor( 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 @@ -1913,6 +2162,15 @@ private constructor( 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 @@ -1959,10 +2217,10 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** Language of the summary. */ - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang + @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang /** Short summary of the situation. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1971,11 +2229,13 @@ private constructor( private var validated: Boolean = false fun validate(): Summary = apply { - if (!validated) { - lang() - value() - validated = true + if (validated) { + return@apply } + + lang() + value() + validated = true } fun toBuilder() = Builder().from(this) @@ -1985,7 +2245,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Summary]. */ + class Builder internal constructor() { private var lang: JsonField = JsonMissing.of() private var value: JsonField = JsonMissing.of() @@ -2079,10 +2340,10 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** Language of the URL. */ - @JsonProperty("lang") @ExcludeMissing fun _lang() = lang + @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang /** URL for more information about the situation. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -2091,11 +2352,13 @@ private constructor( private var validated: Boolean = false fun validate(): Url = apply { - if (!validated) { - lang() - value() - validated = true + if (validated) { + return@apply } + + lang() + value() + validated = true } fun toBuilder() = Builder().from(this) @@ -2105,7 +2368,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Url]. */ + class Builder internal constructor() { private var lang: JsonField = JsonMissing.of() private var value: JsonField = JsonMissing.of() @@ -2183,34 +2447,25 @@ private constructor( return true } - return /* spotless:off */ other is Situation && id == other.id && creationTime == other.creationTime && reason == other.reason && summary == other.summary && description == other.description && url == other.url && activeWindows == other.activeWindows && allAffects == other.allAffects && consequences == other.consequences && publicationWindows == other.publicationWindows && severity == other.severity && consequenceMessage == other.consequenceMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Situation && id == other.id && creationTime == other.creationTime && activeWindows == other.activeWindows && allAffects == other.allAffects && consequenceMessage == other.consequenceMessage && consequences == other.consequences && description == other.description && publicationWindows == other.publicationWindows && reason == other.reason && severity == other.severity && summary == other.summary && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, creationTime, reason, summary, description, url, activeWindows, allAffects, consequences, publicationWindows, severity, consequenceMessage, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, creationTime, activeWindows, allAffects, consequenceMessage, consequences, description, publicationWindows, reason, severity, summary, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Situation{id=$id, creationTime=$creationTime, reason=$reason, summary=$summary, description=$description, url=$url, activeWindows=$activeWindows, allAffects=$allAffects, consequences=$consequences, publicationWindows=$publicationWindows, severity=$severity, consequenceMessage=$consequenceMessage, additionalProperties=$additionalProperties}" + "Situation{id=$id, creationTime=$creationTime, activeWindows=$activeWindows, allAffects=$allAffects, consequenceMessage=$consequenceMessage, consequences=$consequences, description=$description, publicationWindows=$publicationWindows, reason=$reason, severity=$severity, summary=$summary, url=$url, additionalProperties=$additionalProperties}" } @NoAutoDetect class Stop @JsonCreator private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing @@ -2224,6 +2479,15 @@ private constructor( @JsonProperty("staticRouteIds") @ExcludeMissing private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -2231,17 +2495,10 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - fun id(): String = id.getRequired("id") fun lat(): Double = lat.getRequired("lat") - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -2252,32 +2509,45 @@ private constructor( fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") + fun code(): Optional = Optional.ofNullable(code.getNullable("code")) + + fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) + + fun locationType(): Optional = + Optional.ofNullable(locationType.getNullable("locationType")) + fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds + @JsonProperty("direction") @ExcludeMissing fun _direction(): JsonField = direction - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType @JsonProperty("wheelchairBoarding") @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding + fun _wheelchairBoarding(): JsonField = wheelchairBoarding @JsonAnyGetter @ExcludeMissing @@ -2286,20 +2556,22 @@ private constructor( private var validated: Boolean = false fun validate(): Stop = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true - } + if (validated) { + return@apply + } + + id() + lat() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + locationType() + wheelchairBoarding() + validated = true } fun toBuilder() = Builder().from(this) @@ -2309,45 +2581,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Stop]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var lat: 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 id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(stop: Stop) = apply { - code = stop.code - direction = stop.direction id = stop.id lat = stop.lat - locationType = stop.locationType lon = stop.lon name = stop.name parent = stop.parent - routeIds = stop.routeIds - staticRouteIds = stop.staticRouteIds + routeIds = stop.routeIds.map { it.toMutableList() } + staticRouteIds = stop.staticRouteIds.map { it.toMutableList() } + code = stop.code + direction = stop.direction + locationType = stop.locationType wheelchairBoarding = stop.wheelchairBoarding additionalProperties = stop.additionalProperties.toMutableMap() } - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } @@ -2356,12 +2621,6 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -2376,13 +2635,55 @@ private constructor( fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } + fun routeIds(routeIds: JsonField>) = apply { + this.routeIds = routeIds.map { it.toMutableList() } + } + + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(routeId) + } + } fun staticRouteIds(staticRouteIds: List) = staticRouteIds(JsonField.of(staticRouteIds)) fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType } fun wheelchairBoarding(wheelchairBoarding: String) = @@ -2413,16 +2714,16 @@ private constructor( fun build(): Stop = Stop( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - id, - lat, locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -2433,17 +2734,17 @@ private constructor( return true } - return /* spotless:off */ other is Stop && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Stop && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Stop{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "Stop{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" } @NoAutoDetect @@ -2489,21 +2790,27 @@ private constructor( fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime - @JsonProperty("departureTime") @ExcludeMissing fun _departureTime() = departureTime + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip + fun _distanceAlongTrip(): JsonField = distanceAlongTrip @JsonProperty("historicalOccupancy") @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy + fun _historicalOccupancy(): JsonField = historicalOccupancy - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId @JsonAnyGetter @ExcludeMissing @@ -2512,15 +2819,17 @@ private constructor( private var validated: Boolean = false fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true + if (validated) { + return@apply } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true } fun toBuilder() = Builder().from(this) @@ -2530,7 +2839,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTime]. */ + class Builder internal constructor() { private var arrivalTime: JsonField = JsonMissing.of() private var departureTime: JsonField = JsonMissing.of() @@ -2638,25 +2948,25 @@ private constructor( class Trip @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), @JsonProperty("blockId") @ExcludeMissing private val blockId: JsonField = JsonMissing.of(), @JsonProperty("directionId") @ExcludeMissing private val directionId: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("peakOffpeak") @ExcludeMissing private val peakOffpeak: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), @JsonProperty("routeShortName") @ExcludeMissing private val routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), @JsonProperty("shapeId") @ExcludeMissing private val shapeId: JsonField = JsonMissing.of(), @@ -2673,23 +2983,23 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + + fun routeId(): String = routeId.getRequired("routeId") + + fun serviceId(): String = serviceId.getRequired("serviceId") + fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) fun directionId(): Optional = Optional.ofNullable(directionId.getNullable("directionId")) - fun id(): String = id.getRequired("id") - fun peakOffpeak(): Optional = Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - fun routeId(): String = routeId.getRequired("routeId") - fun routeShortName(): Optional = Optional.ofNullable(routeShortName.getNullable("routeShortName")) - fun serviceId(): String = serviceId.getRequired("serviceId") - fun shapeId(): Optional = Optional.ofNullable(shapeId.getNullable("shapeId")) fun timeZone(): Optional = Optional.ofNullable(timeZone.getNullable("timeZone")) @@ -2700,27 +3010,37 @@ private constructor( fun tripShortName(): Optional = Optional.ofNullable(tripShortName.getNullable("tripShortName")) - @JsonProperty("blockId") @ExcludeMissing fun _blockId() = blockId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("serviceId") @ExcludeMissing fun _serviceId(): JsonField = serviceId - @JsonProperty("peakOffpeak") @ExcludeMissing fun _peakOffpeak() = peakOffpeak + @JsonProperty("blockId") @ExcludeMissing fun _blockId(): JsonField = blockId - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId + @JsonProperty("directionId") + @ExcludeMissing + fun _directionId(): JsonField = directionId - @JsonProperty("routeShortName") @ExcludeMissing fun _routeShortName() = routeShortName + @JsonProperty("peakOffpeak") + @ExcludeMissing + fun _peakOffpeak(): JsonField = peakOffpeak - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId() = shapeId + @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone + @JsonProperty("timeZone") @ExcludeMissing fun _timeZone(): JsonField = timeZone - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign - @JsonProperty("tripShortName") @ExcludeMissing fun _tripShortName() = tripShortName + @JsonProperty("tripShortName") + @ExcludeMissing + fun _tripShortName(): JsonField = tripShortName @JsonAnyGetter @ExcludeMissing @@ -2729,20 +3049,22 @@ private constructor( private var validated: Boolean = false fun validate(): Trip = apply { - if (!validated) { - blockId() - directionId() - id() - peakOffpeak() - routeId() - routeShortName() - serviceId() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true - } + if (validated) { + return@apply + } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + validated = true } fun toBuilder() = Builder().from(this) @@ -2752,15 +3074,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Trip]. */ + class Builder internal constructor() { + 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 id: JsonField = JsonMissing.of() private var peakOffpeak: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() private var routeShortName: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() private var shapeId: JsonField = JsonMissing.of() private var timeZone: JsonField = JsonMissing.of() private var tripHeadsign: JsonField = JsonMissing.of() @@ -2769,13 +3092,13 @@ private constructor( @JvmSynthetic internal fun from(trip: Trip) = apply { + id = trip.id + routeId = trip.routeId + serviceId = trip.serviceId blockId = trip.blockId directionId = trip.directionId - id = trip.id peakOffpeak = trip.peakOffpeak - routeId = trip.routeId routeShortName = trip.routeShortName - serviceId = trip.serviceId shapeId = trip.shapeId timeZone = trip.timeZone tripHeadsign = trip.tripHeadsign @@ -2783,6 +3106,18 @@ private constructor( additionalProperties = trip.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) fun blockId(blockId: JsonField) = apply { this.blockId = blockId } @@ -2793,18 +3128,10 @@ private constructor( this.directionId = directionId } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) fun peakOffpeak(peakOffpeak: JsonField) = apply { this.peakOffpeak = peakOffpeak } - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - fun routeShortName(routeShortName: String) = routeShortName(JsonField.of(routeShortName)) @@ -2812,10 +3139,6 @@ private constructor( this.routeShortName = routeShortName } - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } @@ -2857,13 +3180,13 @@ private constructor( fun build(): Trip = Trip( + checkRequired("id", id), + checkRequired("routeId", routeId), + checkRequired("serviceId", serviceId), blockId, directionId, - id, peakOffpeak, - routeId, routeShortName, - serviceId, shapeId, timeZone, tripHeadsign, @@ -2877,17 +3200,17 @@ private constructor( return true } - return /* spotless:off */ other is Trip && blockId == other.blockId && directionId == other.directionId && id == other.id && peakOffpeak == other.peakOffpeak && routeId == other.routeId && routeShortName == other.routeShortName && serviceId == other.serviceId && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Trip && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Trip{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" + "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}" } override fun equals(other: Any?): Boolean { @@ -2895,15 +3218,15 @@ private constructor( return true } - return /* spotless:off */ other is References && agencies == other.agencies && routes == other.routes && situations == other.situations && stopTimes == other.stopTimes && stops == other.stops && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is References && agencies == other.agencies && routes == other.routes && situations == other.situations && stops == other.stops && stopTimes == other.stopTimes && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(agencies, routes, situations, stopTimes, stops, trips, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(agencies, routes, situations, stops, stopTimes, trips, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "References{agencies=$agencies, routes=$routes, situations=$situations, stopTimes=$stopTimes, stops=$stops, trips=$trips, additionalProperties=$additionalProperties}" + "References{agencies=$agencies, routes=$routes, situations=$situations, stops=$stops, stopTimes=$stopTimes, trips=$trips, additionalProperties=$additionalProperties}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt index 07dbe77..9e9afca 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt @@ -8,12 +8,15 @@ import java.util.Optional import org.onebusaway.core.Enum import org.onebusaway.core.JsonField import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams import org.onebusaway.errors.OnebusawaySdkInvalidDataException +/** Submit a user-generated problem report for a stop */ class ReportProblemWithStopRetrieveParams -constructor( +private constructor( private val stopId: String, private val code: Code?, private val userComment: String?, @@ -22,7 +25,7 @@ constructor( private val userLon: Double?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun stopId(): String = stopId @@ -45,10 +48,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.code?.let { queryParams.put("code", listOf(it.toString())) } this.userComment?.let { queryParams.put("userComment", listOf(it.toString())) } @@ -75,8 +77,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ReportProblemWithStopRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var stopId: String? = null private var code: Code? = null @@ -105,21 +108,50 @@ constructor( fun stopId(stopId: String) = apply { this.stopId = stopId } /** A string code identifying the nature of the problem */ - fun code(code: Code) = apply { this.code = code } + fun code(code: Code?) = apply { this.code = code } + + /** A string code identifying the nature of the problem */ + fun code(code: Optional) = code(code.orElse(null)) /** Additional comment text supplied by the user describing the problem */ - fun userComment(userComment: String) = apply { this.userComment = userComment } + fun userComment(userComment: String?) = apply { this.userComment = userComment } + + /** Additional comment text supplied by the user describing the problem */ + fun userComment(userComment: Optional) = userComment(userComment.orElse(null)) /** The reporting user’s current latitude */ - fun userLat(userLat: Double) = apply { this.userLat = userLat } + fun userLat(userLat: Double?) = apply { this.userLat = userLat } + + /** The reporting user’s current latitude */ + fun userLat(userLat: Double) = userLat(userLat as Double?) + + /** The reporting user’s current latitude */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun userLat(userLat: Optional) = userLat(userLat.orElse(null) as Double?) /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(userLocationAccuracy: Double) = apply { + fun userLocationAccuracy(userLocationAccuracy: Double?) = apply { this.userLocationAccuracy = userLocationAccuracy } + /** The reporting user’s location accuracy, in meters */ + fun userLocationAccuracy(userLocationAccuracy: Double) = + userLocationAccuracy(userLocationAccuracy as Double?) + + /** The reporting user’s location accuracy, in meters */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun userLocationAccuracy(userLocationAccuracy: Optional) = + userLocationAccuracy(userLocationAccuracy.orElse(null) as Double?) + + /** The reporting user’s current longitude */ + fun userLon(userLon: Double?) = apply { this.userLon = userLon } + + /** The reporting user’s current longitude */ + fun userLon(userLon: Double) = userLon(userLon as Double?) + /** The reporting user’s current longitude */ - fun userLon(userLon: Double) = apply { this.userLon = userLon } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun userLon(userLon: Optional) = userLon(userLon.orElse(null) as Double?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -221,7 +253,7 @@ constructor( fun build(): ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, + checkRequired("stopId", stopId), code, userComment, userLat, @@ -232,12 +264,21 @@ constructor( ) } + /** A string code identifying the nature of the problem */ class Code @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 { @@ -255,6 +296,7 @@ constructor( @JvmStatic fun of(value: String) = Code(JsonField.of(value)) } + /** An enum containing [Code]'s known values. */ enum class Known { STOP_NAME_WRONG, STOP_NUMBER_WRONG, @@ -263,15 +305,32 @@ constructor( OTHER, } + /** + * An enum containing [Code]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Code] 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 { STOP_NAME_WRONG, STOP_NUMBER_WRONG, STOP_LOCATION_WRONG, ROUTE_OR_TRIP_MISSING, OTHER, + /** An enum member indicating that [Code] 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) { STOP_NAME_WRONG -> Value.STOP_NAME_WRONG @@ -282,6 +341,15 @@ constructor( 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) { STOP_NAME_WRONG -> Known.STOP_NAME_WRONG diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt index 6d0e87a..213acd1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt @@ -8,12 +8,15 @@ import java.util.Optional import org.onebusaway.core.Enum import org.onebusaway.core.JsonField import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams import org.onebusaway.errors.OnebusawaySdkInvalidDataException +/** Submit a user-generated problem report for a particular trip. */ class ReportProblemWithTripRetrieveParams -constructor( +private constructor( private val tripId: String, private val code: Code?, private val serviceDate: Long?, @@ -27,7 +30,7 @@ constructor( private val vehicleId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun tripId(): String = tripId @@ -65,10 +68,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.code?.let { queryParams.put("code", listOf(it.toString())) } this.serviceDate?.let { queryParams.put("serviceDate", listOf(it.toString())) } @@ -100,8 +102,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ReportProblemWithTripRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var tripId: String? = null private var code: Code? = null @@ -140,38 +143,93 @@ constructor( fun tripId(tripId: String) = apply { this.tripId = tripId } /** A string code identifying the nature of the problem */ - fun code(code: Code) = apply { this.code = code } + fun code(code: Code?) = apply { this.code = code } + + /** A string code identifying the nature of the problem */ + fun code(code: Optional) = code(code.orElse(null)) + + /** The service date of the trip */ + fun serviceDate(serviceDate: Long?) = apply { this.serviceDate = serviceDate } /** The service date of the trip */ - fun serviceDate(serviceDate: Long) = apply { this.serviceDate = serviceDate } + fun serviceDate(serviceDate: Long) = serviceDate(serviceDate as Long?) + + /** The service date of the trip */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun serviceDate(serviceDate: Optional) = + serviceDate(serviceDate.orElse(null) as Long?) + + /** A stop ID indicating where the user is experiencing the problem */ + fun stopId(stopId: String?) = apply { this.stopId = stopId } /** A stop ID indicating where the user is experiencing the problem */ - fun stopId(stopId: String) = apply { this.stopId = stopId } + fun stopId(stopId: Optional) = stopId(stopId.orElse(null)) /** Additional comment text supplied by the user describing the problem */ - fun userComment(userComment: String) = apply { this.userComment = userComment } + fun userComment(userComment: String?) = apply { this.userComment = userComment } + + /** Additional comment text supplied by the user describing the problem */ + fun userComment(userComment: Optional) = userComment(userComment.orElse(null)) + + /** The reporting user’s current latitude */ + fun userLat(userLat: Double?) = apply { this.userLat = userLat } /** The reporting user’s current latitude */ - fun userLat(userLat: Double) = apply { this.userLat = userLat } + fun userLat(userLat: Double) = userLat(userLat as Double?) + + /** The reporting user’s current latitude */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun userLat(userLat: Optional) = userLat(userLat.orElse(null) as Double?) /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(userLocationAccuracy: Double) = apply { + fun userLocationAccuracy(userLocationAccuracy: Double?) = apply { this.userLocationAccuracy = userLocationAccuracy } + /** The reporting user’s location accuracy, in meters */ + fun userLocationAccuracy(userLocationAccuracy: Double) = + userLocationAccuracy(userLocationAccuracy as Double?) + + /** The reporting user’s location accuracy, in meters */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun userLocationAccuracy(userLocationAccuracy: Optional) = + userLocationAccuracy(userLocationAccuracy.orElse(null) as Double?) + + /** The reporting user’s current longitude */ + fun userLon(userLon: Double?) = apply { this.userLon = userLon } + /** The reporting user’s current longitude */ - fun userLon(userLon: Double) = apply { this.userLon = userLon } + fun userLon(userLon: Double) = userLon(userLon as Double?) + + /** The reporting user’s current longitude */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun userLon(userLon: Optional) = userLon(userLon.orElse(null) as Double?) + + /** Indicator if the user is on the transit vehicle experiencing the problem */ + fun userOnVehicle(userOnVehicle: Boolean?) = apply { this.userOnVehicle = userOnVehicle } /** Indicator if the user is on the transit vehicle experiencing the problem */ - fun userOnVehicle(userOnVehicle: Boolean) = apply { this.userOnVehicle = userOnVehicle } + fun userOnVehicle(userOnVehicle: Boolean) = userOnVehicle(userOnVehicle as Boolean?) + + /** Indicator if the user is on the transit vehicle experiencing the problem */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun userOnVehicle(userOnVehicle: Optional) = + userOnVehicle(userOnVehicle.orElse(null) as Boolean?) /** The vehicle number, as reported by the user */ - fun userVehicleNumber(userVehicleNumber: String) = apply { + fun userVehicleNumber(userVehicleNumber: String?) = apply { this.userVehicleNumber = userVehicleNumber } + /** The vehicle number, as reported by the user */ + fun userVehicleNumber(userVehicleNumber: Optional) = + userVehicleNumber(userVehicleNumber.orElse(null)) + /** The vehicle actively serving the trip */ - fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } + fun vehicleId(vehicleId: String?) = apply { this.vehicleId = vehicleId } + + /** The vehicle actively serving the trip */ + fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -273,7 +331,7 @@ constructor( fun build(): ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams( - checkNotNull(tripId) { "`tripId` is required but was not set" }, + checkRequired("tripId", tripId), code, serviceDate, stopId, @@ -289,12 +347,21 @@ constructor( ) } + /** A string code identifying the nature of the problem */ class Code @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 { @@ -314,6 +381,7 @@ constructor( @JvmStatic fun of(value: String) = Code(JsonField.of(value)) } + /** An enum containing [Code]'s known values. */ enum class Known { VEHICLE_NEVER_CAME, VEHICLE_CAME_EARLY, @@ -323,6 +391,15 @@ constructor( OTHER, } + /** + * An enum containing [Code]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Code] 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 { VEHICLE_NEVER_CAME, VEHICLE_CAME_EARLY, @@ -330,9 +407,17 @@ constructor( WRONG_HEADSIGN, VEHICLE_DOES_NOT_STOP_HERE, OTHER, + /** An enum member indicating that [Code] 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) { VEHICLE_NEVER_CAME -> Value.VEHICLE_NEVER_CAME @@ -344,6 +429,15 @@ constructor( 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) { VEHICLE_NEVER_CAME -> Known.VEHICLE_NEVER_CAME 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 eb9ea9a..2ca005b 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 @@ -12,6 +12,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -38,13 +39,13 @@ private constructor( fun version(): Long = version.getRequired("version") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -53,13 +54,15 @@ private constructor( private var validated: Boolean = false fun validate(): ResponseWrapper = apply { - if (!validated) { - code() - currentTime() - text() - version() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -69,12 +72,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ResponseWrapper]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -123,10 +127,10 @@ private constructor( fun build(): ResponseWrapper = ResponseWrapper( - code, - currentTime, - text, - version, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), additionalProperties.toImmutable(), ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt index cdbc57c..df3aead 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get route IDs for a specific agency */ class RouteIdsForAgencyListParams -constructor( +private constructor( private val agencyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun agencyId(): String = agencyId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RouteIdsForAgencyListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var agencyId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): RouteIdsForAgencyListParams = RouteIdsForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, + checkRequired("agencyId", agencyId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt index d7aa39a..dd63e25 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt @@ -12,6 +12,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -41,15 +42,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -66,14 +67,16 @@ private constructor( private var validated: Boolean = false fun validate(): RouteIdsForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -83,13 +86,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RouteIdsForAgencyListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -143,11 +147,11 @@ private constructor( fun build(): RouteIdsForAgencyListResponse = RouteIdsForAgencyListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -175,11 +179,15 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -188,12 +196,14 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list() - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -203,17 +213,18 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list + list = data.list.map { it.toMutableList() } references = data.references additionalProperties = data.additionalProperties.toMutableMap() } @@ -226,7 +237,22 @@ private constructor( fun list(list: List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: String) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun references(references: References) = references(JsonField.of(references)) @@ -255,9 +281,9 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, - references, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), additionalProperties.toImmutable(), ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt index 54c0374..3f67683 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Retrieve information for a specific route identified by its unique ID. */ class RouteRetrieveParams -constructor( +private constructor( private val routeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun routeId(): String = routeId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RouteRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var routeId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): RouteRetrieveParams = RouteRetrieveParams( - checkNotNull(routeId) { "`routeId` is required but was not set" }, + checkRequired("routeId", routeId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt index 5d65b29..0f81450 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): RouteRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RouteRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): RouteRetrieveResponse = RouteRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -250,18 +259,21 @@ private constructor( class Entry @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), @JsonProperty("agencyId") @ExcludeMissing private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), @JsonProperty("longName") @ExcludeMissing private val longName: JsonField = JsonMissing.of(), @@ -274,9 +286,6 @@ private constructor( @JsonProperty("textColor") @ExcludeMissing private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @@ -284,15 +293,17 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + fun agencyId(): String = agencyId.getRequired("agencyId") + fun type(): Long = type.getRequired("type") + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun id(): String = id.getRequired("id") - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) fun nullSafeShortName(): Optional = @@ -304,31 +315,35 @@ private constructor( fun textColor(): Optional = Optional.ofNullable(textColor.getNullable("textColor")) - fun type(): Long = type.getRequired("type") - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("color") @ExcludeMissing fun _color() = color + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName @JsonProperty("nullSafeShortName") @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName + fun _nullSafeShortName(): JsonField = nullSafeShortName - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -337,19 +352,21 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true + if (validated) { + return@apply } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true } fun toBuilder() = Builder().from(this) @@ -359,39 +376,48 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { - private var agencyId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null private var color: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var longName: JsonField = JsonMissing.of() private var nullSafeShortName: JsonField = JsonMissing.of() private var shortName: JsonField = JsonMissing.of() private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { + id = entry.id agencyId = entry.agencyId + type = entry.type color = entry.color description = entry.description - id = entry.id longName = entry.longName nullSafeShortName = entry.nullSafeShortName shortName = entry.shortName textColor = entry.textColor - type = entry.type url = entry.url additionalProperties = entry.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + fun type(type: Long) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun color(color: String) = color(JsonField.of(color)) fun color(color: JsonField) = apply { this.color = color } @@ -402,10 +428,6 @@ private constructor( this.description = description } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun longName(longName: String) = longName(JsonField.of(longName)) fun longName(longName: JsonField) = apply { this.longName = longName } @@ -425,10 +447,6 @@ private constructor( fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - fun url(url: String) = url(JsonField.of(url)) fun url(url: JsonField) = apply { this.url = url } @@ -457,15 +475,15 @@ private constructor( fun build(): Entry = Entry( - agencyId, + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), color, description, - id, longName, nullSafeShortName, shortName, textColor, - type, url, additionalProperties.toImmutable(), ) @@ -476,17 +494,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" + "Entry{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt index 288f3ee..1f6cb50 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Retrieve the list of all routes for a particular agency by id */ class RoutesForAgencyListParams -constructor( +private constructor( private val agencyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun agencyId(): String = agencyId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RoutesForAgencyListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var agencyId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): RoutesForAgencyListParams = RoutesForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, + checkRequired("agencyId", agencyId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt index c647b28..cf24f91 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): RoutesForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RoutesForAgencyListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): RoutesForAgencyListResponse = RoutesForAgencyListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -176,11 +180,17 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -189,12 +199,14 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -204,17 +216,18 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list + list = data.list.map { it.toMutableList() } references = data.references additionalProperties = data.additionalProperties.toMutableMap() } @@ -227,7 +240,22 @@ private constructor( fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun references(references: References) = references(JsonField.of(references)) @@ -256,9 +284,9 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, - references, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -267,18 +295,21 @@ private constructor( class List @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), @JsonProperty("agencyId") @ExcludeMissing private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), @JsonProperty("longName") @ExcludeMissing private val longName: JsonField = JsonMissing.of(), @@ -291,9 +322,6 @@ private constructor( @JsonProperty("textColor") @ExcludeMissing private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @@ -301,15 +329,17 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + fun agencyId(): String = agencyId.getRequired("agencyId") + fun type(): Long = type.getRequired("type") + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun id(): String = id.getRequired("id") - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) fun nullSafeShortName(): Optional = @@ -321,31 +351,35 @@ private constructor( fun textColor(): Optional = Optional.ofNullable(textColor.getNullable("textColor")) - fun type(): Long = type.getRequired("type") - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("color") @ExcludeMissing fun _color() = color + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName @JsonProperty("nullSafeShortName") @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName + fun _nullSafeShortName(): JsonField = nullSafeShortName - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -354,19 +388,21 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true + if (validated) { + return@apply } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true } fun toBuilder() = Builder().from(this) @@ -376,39 +412,48 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { - private var agencyId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null private var color: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var longName: JsonField = JsonMissing.of() private var nullSafeShortName: JsonField = JsonMissing.of() private var shortName: JsonField = JsonMissing.of() private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { + id = list.id agencyId = list.agencyId + type = list.type color = list.color description = list.description - id = list.id longName = list.longName nullSafeShortName = list.nullSafeShortName shortName = list.shortName textColor = list.textColor - type = list.type url = list.url additionalProperties = list.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + fun type(type: Long) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun color(color: String) = color(JsonField.of(color)) fun color(color: JsonField) = apply { this.color = color } @@ -419,10 +464,6 @@ private constructor( this.description = description } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun longName(longName: String) = longName(JsonField.of(longName)) fun longName(longName: JsonField) = apply { this.longName = longName } @@ -442,10 +483,6 @@ private constructor( fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - fun url(url: String) = url(JsonField.of(url)) fun url(url: JsonField) = apply { this.url = url } @@ -474,15 +511,15 @@ private constructor( fun build(): List = List( - agencyId, + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), color, description, - id, longName, nullSafeShortName, shortName, textColor, - type, url, additionalProperties.toImmutable(), ) @@ -493,17 +530,17 @@ private constructor( return true } - return /* spotless:off */ other is List && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt index f934535..69461ad 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt @@ -5,11 +5,14 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** routes-for-location */ class RoutesForLocationListParams -constructor( +private constructor( private val lat: Double, private val lon: Double, private val latSpan: Double?, @@ -18,7 +21,7 @@ constructor( private val radius: Double?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun lat(): Double = lat @@ -36,10 +39,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.lat.let { queryParams.put("lat", listOf(it.toString())) } this.lon.let { queryParams.put("lon", listOf(it.toString())) } @@ -58,8 +60,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RoutesForLocationListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var lat: Double? = null private var lon: Double? = null @@ -86,13 +89,30 @@ constructor( fun lon(lon: Double) = apply { this.lon = lon } - fun latSpan(latSpan: Double) = apply { this.latSpan = latSpan } + fun latSpan(latSpan: Double?) = apply { this.latSpan = latSpan } - fun lonSpan(lonSpan: Double) = apply { this.lonSpan = lonSpan } + fun latSpan(latSpan: Double) = latSpan(latSpan as Double?) - fun query(query: String) = apply { this.query = query } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun latSpan(latSpan: Optional) = latSpan(latSpan.orElse(null) as Double?) - fun radius(radius: Double) = apply { this.radius = radius } + fun lonSpan(lonSpan: Double?) = apply { this.lonSpan = lonSpan } + + fun lonSpan(lonSpan: Double) = lonSpan(lonSpan as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.orElse(null) as Double?) + + fun query(query: String?) = apply { this.query = query } + + fun query(query: Optional) = query(query.orElse(null)) + + fun radius(radius: Double?) = apply { this.radius = radius } + + fun radius(radius: Double) = radius(radius as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun radius(radius: Optional) = radius(radius.orElse(null) as Double?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -194,8 +214,8 @@ constructor( fun build(): RoutesForLocationListParams = RoutesForLocationListParams( - checkNotNull(lat) { "`lat` is required but was not set" }, - checkNotNull(lon) { "`lon` is required but was not set" }, + checkRequired("lat", lat), + checkRequired("lon", lon), latSpan, lonSpan, query, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt index 3ecf897..80b0395 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): RoutesForLocationListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RoutesForLocationListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): RoutesForLocationListResponse = RoutesForLocationListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -181,13 +185,21 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -196,13 +208,15 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -212,18 +226,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var outOfRange: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list + list = data.list.map { it.toMutableList() } outOfRange = data.outOfRange references = data.references additionalProperties = data.additionalProperties.toMutableMap() @@ -237,7 +252,22 @@ private constructor( fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) @@ -270,10 +300,10 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, - outOfRange, - references, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -282,18 +312,21 @@ private constructor( class List @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), @JsonProperty("agencyId") @ExcludeMissing private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), @JsonProperty("longName") @ExcludeMissing private val longName: JsonField = JsonMissing.of(), @@ -306,9 +339,6 @@ private constructor( @JsonProperty("textColor") @ExcludeMissing private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @@ -316,15 +346,17 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + fun agencyId(): String = agencyId.getRequired("agencyId") + fun type(): Long = type.getRequired("type") + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun id(): String = id.getRequired("id") - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) fun nullSafeShortName(): Optional = @@ -336,31 +368,35 @@ private constructor( fun textColor(): Optional = Optional.ofNullable(textColor.getNullable("textColor")) - fun type(): Long = type.getRequired("type") - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("color") @ExcludeMissing fun _color() = color + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName @JsonProperty("nullSafeShortName") @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName + fun _nullSafeShortName(): JsonField = nullSafeShortName - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -369,19 +405,21 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true + if (validated) { + return@apply } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true } fun toBuilder() = Builder().from(this) @@ -391,39 +429,48 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { - private var agencyId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null private var color: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var longName: JsonField = JsonMissing.of() private var nullSafeShortName: JsonField = JsonMissing.of() private var shortName: JsonField = JsonMissing.of() private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { + id = list.id agencyId = list.agencyId + type = list.type color = list.color description = list.description - id = list.id longName = list.longName nullSafeShortName = list.nullSafeShortName shortName = list.shortName textColor = list.textColor - type = list.type url = list.url additionalProperties = list.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + fun type(type: Long) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun color(color: String) = color(JsonField.of(color)) fun color(color: JsonField) = apply { this.color = color } @@ -434,10 +481,6 @@ private constructor( this.description = description } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun longName(longName: String) = longName(JsonField.of(longName)) fun longName(longName: JsonField) = apply { this.longName = longName } @@ -457,10 +500,6 @@ private constructor( fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - fun url(url: String) = url(JsonField.of(url)) fun url(url: JsonField) = apply { this.url = url } @@ -489,15 +528,15 @@ private constructor( fun build(): List = List( - agencyId, + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), color, description, - id, longName, nullSafeShortName, shortName, textColor, - type, url, additionalProperties.toImmutable(), ) @@ -508,17 +547,17 @@ private constructor( return true } - return /* spotless:off */ other is List && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt index daacc53..288fae3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt @@ -6,16 +6,19 @@ import java.time.LocalDate import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Retrieve the full schedule for a route on a particular day */ class ScheduleForRouteRetrieveParams -constructor( +private constructor( private val routeId: String, private val date: LocalDate?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun routeId(): String = routeId @@ -29,10 +32,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.date?.let { queryParams.put("date", listOf(it.toString())) } queryParams.putAll(additionalQueryParams) @@ -53,8 +55,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ScheduleForRouteRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var routeId: String? = null private var date: LocalDate? = null @@ -75,7 +78,13 @@ constructor( * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, * defaults to current date) */ - fun date(date: LocalDate) = apply { this.date = date } + fun date(date: LocalDate?) = apply { this.date = date } + + /** + * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, + * defaults to current date) + */ + fun date(date: Optional) = date(date.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -177,7 +186,7 @@ constructor( fun build(): ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams( - checkNotNull(routeId) { "`routeId` is required but was not set" }, + checkRequired("routeId", routeId), date, additionalHeaders.build(), additionalQueryParams.build(), diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt index 90e5f08..be77b8a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): ScheduleForRouteRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ScheduleForRouteRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -146,11 +150,11 @@ private constructor( fun build(): ScheduleForRouteRetrieveResponse = ScheduleForRouteRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -168,7 +172,7 @@ private constructor( fun entry(): Entry = entry.getRequired("entry") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry @JsonAnyGetter @ExcludeMissing @@ -177,10 +181,12 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -190,9 +196,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() + private var entry: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -224,7 +231,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Data = Data(entry, additionalProperties.toImmutable()) + fun build(): Data = + Data(checkRequired("entry", entry), additionalProperties.toImmutable()) } @NoAutoDetect @@ -240,12 +248,12 @@ private constructor( @JsonProperty("serviceIds") @ExcludeMissing private val serviceIds: JsonField> = JsonMissing.of(), - @JsonProperty("stopTripGroupings") - @ExcludeMissing - private val stopTripGroupings: JsonField> = JsonMissing.of(), @JsonProperty("stops") @ExcludeMissing private val stops: JsonField> = JsonMissing.of(), + @JsonProperty("stopTripGroupings") + @ExcludeMissing + private val stopTripGroupings: JsonField> = JsonMissing.of(), @JsonProperty("trips") @ExcludeMissing private val trips: JsonField> = JsonMissing.of(), @@ -259,26 +267,30 @@ private constructor( fun serviceIds(): List = serviceIds.getRequired("serviceIds") + fun stops(): List = stops.getRequired("stops") + fun stopTripGroupings(): List = stopTripGroupings.getRequired("stopTripGroupings") - fun stops(): List = stops.getRequired("stops") - fun trips(): List = trips.getRequired("trips") - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + @JsonProperty("scheduleDate") + @ExcludeMissing + fun _scheduleDate(): JsonField = scheduleDate - @JsonProperty("scheduleDate") @ExcludeMissing fun _scheduleDate() = scheduleDate + @JsonProperty("serviceIds") + @ExcludeMissing + fun _serviceIds(): JsonField> = serviceIds - @JsonProperty("serviceIds") @ExcludeMissing fun _serviceIds() = serviceIds + @JsonProperty("stops") @ExcludeMissing fun _stops(): JsonField> = stops @JsonProperty("stopTripGroupings") @ExcludeMissing - fun _stopTripGroupings() = stopTripGroupings - - @JsonProperty("stops") @ExcludeMissing fun _stops() = stops + fun _stopTripGroupings(): JsonField> = stopTripGroupings - @JsonProperty("trips") @ExcludeMissing fun _trips() = trips + @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips @JsonAnyGetter @ExcludeMissing @@ -287,15 +299,17 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - routeId() - scheduleDate() - serviceIds() - stopTripGroupings().forEach { it.validate() } - stops().forEach { it.validate() } - trips().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + routeId() + scheduleDate() + serviceIds() + stops().forEach { it.validate() } + stopTripGroupings().forEach { it.validate() } + trips().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -305,24 +319,25 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { - private var routeId: JsonField = JsonMissing.of() - private var scheduleDate: JsonField = JsonMissing.of() - private var serviceIds: JsonField> = JsonMissing.of() - private var stopTripGroupings: JsonField> = JsonMissing.of() - private var stops: JsonField> = JsonMissing.of() - private var trips: JsonField> = JsonMissing.of() + 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 internal fun from(entry: Entry) = apply { routeId = entry.routeId scheduleDate = entry.scheduleDate - serviceIds = entry.serviceIds - stopTripGroupings = entry.stopTripGroupings - stops = entry.stops - trips = entry.trips + 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() } @@ -339,7 +354,39 @@ private constructor( fun serviceIds(serviceIds: List) = serviceIds(JsonField.of(serviceIds)) fun serviceIds(serviceIds: JsonField>) = apply { - this.serviceIds = serviceIds + this.serviceIds = serviceIds.map { it.toMutableList() } + } + + fun addServiceId(serviceId: String) = apply { + serviceIds = + (serviceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(serviceId) + } + } + + fun stops(stops: List) = stops(JsonField.of(stops)) + + fun stops(stops: JsonField>) = apply { + this.stops = stops.map { it.toMutableList() } + } + + fun addStop(stop: Stop) = apply { + stops = + (stops ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stop) + } } fun stopTripGroupings(stopTripGroupings: List) = @@ -347,16 +394,40 @@ private constructor( fun stopTripGroupings(stopTripGroupings: JsonField>) = apply { - this.stopTripGroupings = stopTripGroupings + this.stopTripGroupings = stopTripGroupings.map { it.toMutableList() } } - fun stops(stops: List) = stops(JsonField.of(stops)) - - fun stops(stops: JsonField>) = apply { this.stops = stops } + fun addStopTripGrouping(stopTripGrouping: StopTripGrouping) = apply { + stopTripGroupings = + (stopTripGroupings ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopTripGrouping) + } + } fun trips(trips: List) = trips(JsonField.of(trips)) - fun trips(trips: JsonField>) = apply { this.trips = trips } + fun trips(trips: JsonField>) = apply { + this.trips = trips.map { it.toMutableList() } + } + + fun addTrip(trip: Trip) = apply { + trips = + (trips ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(trip) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -382,12 +453,14 @@ private constructor( fun build(): Entry = Entry( - routeId, - scheduleDate, - serviceIds.map { it.toImmutable() }, - stopTripGroupings.map { it.toImmutable() }, - stops.map { it.toImmutable() }, - trips.map { it.toImmutable() }, + 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.toImmutable(), ) } @@ -396,21 +469,12 @@ private constructor( class Stop @JsonCreator private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @@ -426,6 +490,15 @@ private constructor( @JsonProperty("staticRouteIds") @ExcludeMissing private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -433,18 +506,10 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - fun id(): String = id.getRequired("id") fun lat(): Double = lat.getRequired("lat") - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -455,34 +520,48 @@ private constructor( fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") + fun code(): Optional = Optional.ofNullable(code.getNullable("code")) + + fun direction(): Optional = + Optional.ofNullable(direction.getNullable("direction")) + + fun locationType(): Optional = + Optional.ofNullable(locationType.getNullable("locationType")) + fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction - @JsonProperty("staticRouteIds") + @JsonProperty("locationType") @ExcludeMissing - fun _staticRouteIds() = staticRouteIds + fun _locationType(): JsonField = locationType @JsonProperty("wheelchairBoarding") @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding + fun _wheelchairBoarding(): JsonField = wheelchairBoarding @JsonAnyGetter @ExcludeMissing @@ -491,20 +570,22 @@ private constructor( private var validated: Boolean = false fun validate(): Stop = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true + if (validated) { + return@apply } + + id() + lat() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + locationType() + wheelchairBoarding() + validated = true } fun toBuilder() = Builder().from(this) @@ -514,47 +595,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Stop]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var lat: 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 id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(stop: Stop) = apply { - code = stop.code - direction = stop.direction id = stop.id lat = stop.lat - locationType = stop.locationType lon = stop.lon name = stop.name parent = stop.parent - routeIds = stop.routeIds - staticRouteIds = stop.staticRouteIds + routeIds = stop.routeIds.map { it.toMutableList() } + staticRouteIds = stop.staticRouteIds.map { it.toMutableList() } + code = stop.code + direction = stop.direction + locationType = stop.locationType wheelchairBoarding = stop.wheelchairBoarding additionalProperties = stop.additionalProperties.toMutableMap() } - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { - this.direction = direction - } - fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } @@ -563,12 +635,6 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -584,14 +650,56 @@ private constructor( fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds + this.routeIds = routeIds.map { it.toMutableList() } + } + + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(routeId) + } } fun staticRouteIds(staticRouteIds: List) = staticRouteIds(JsonField.of(staticRouteIds)) fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + fun direction(direction: JsonField) = apply { + this.direction = direction + } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType } fun wheelchairBoarding(wheelchairBoarding: String) = @@ -625,16 +733,18 @@ private constructor( fun build(): Stop = Stop( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { + it.toImmutable() + }, code, direction, - id, - lat, locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -645,17 +755,17 @@ private constructor( return true } - return /* spotless:off */ other is Stop && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Stop && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Stop{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "Stop{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" } @NoAutoDetect @@ -693,17 +803,25 @@ private constructor( fun tripsWithStopTimes(): Optional> = Optional.ofNullable(tripsWithStopTimes.getNullable("tripsWithStopTimes")) - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId + @JsonProperty("directionId") + @ExcludeMissing + fun _directionId(): JsonField = directionId - @JsonProperty("stopIds") @ExcludeMissing fun _stopIds() = stopIds + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds - @JsonProperty("tripHeadsigns") @ExcludeMissing fun _tripHeadsigns() = tripHeadsigns + @JsonProperty("tripHeadsigns") + @ExcludeMissing + fun _tripHeadsigns(): JsonField> = tripHeadsigns - @JsonProperty("tripIds") @ExcludeMissing fun _tripIds() = tripIds + @JsonProperty("tripIds") + @ExcludeMissing + fun _tripIds(): JsonField> = tripIds @JsonProperty("tripsWithStopTimes") @ExcludeMissing - fun _tripsWithStopTimes() = tripsWithStopTimes + fun _tripsWithStopTimes(): JsonField> = tripsWithStopTimes @JsonAnyGetter @ExcludeMissing @@ -712,14 +830,16 @@ private constructor( private var validated: Boolean = false fun validate(): StopTripGrouping = apply { - if (!validated) { - directionId() - stopIds() - tripHeadsigns() - tripIds() - tripsWithStopTimes().map { it.forEach { it.validate() } } - validated = true + if (validated) { + return@apply } + + directionId() + stopIds() + tripHeadsigns() + tripIds() + tripsWithStopTimes().ifPresent { it.forEach { it.validate() } } + validated = true } fun toBuilder() = Builder().from(this) @@ -729,23 +849,25 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTripGrouping]. */ + class Builder internal constructor() { - private var directionId: JsonField = JsonMissing.of() - private var stopIds: JsonField> = JsonMissing.of() - private var tripHeadsigns: JsonField> = JsonMissing.of() - private var tripIds: JsonField> = JsonMissing.of() - private var tripsWithStopTimes: 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(stopTripGrouping: StopTripGrouping) = apply { directionId = stopTripGrouping.directionId - stopIds = stopTripGrouping.stopIds - tripHeadsigns = stopTripGrouping.tripHeadsigns - tripIds = stopTripGrouping.tripIds - tripsWithStopTimes = stopTripGrouping.tripsWithStopTimes + 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() } @@ -757,27 +879,83 @@ private constructor( fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopId) + } + } fun tripHeadsigns(tripHeadsigns: List) = tripHeadsigns(JsonField.of(tripHeadsigns)) fun tripHeadsigns(tripHeadsigns: JsonField>) = apply { - this.tripHeadsigns = tripHeadsigns + this.tripHeadsigns = tripHeadsigns.map { it.toMutableList() } + } + + fun addTripHeadsign(tripHeadsign: String) = apply { + tripHeadsigns = + (tripHeadsigns ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tripHeadsign) + } } fun tripIds(tripIds: List) = tripIds(JsonField.of(tripIds)) - fun tripIds(tripIds: JsonField>) = apply { this.tripIds = tripIds } + fun tripIds(tripIds: JsonField>) = apply { + this.tripIds = tripIds.map { it.toMutableList() } + } + + fun addTripId(tripId: String) = apply { + tripIds = + (tripIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tripId) + } + } fun tripsWithStopTimes(tripsWithStopTimes: List) = tripsWithStopTimes(JsonField.of(tripsWithStopTimes)) fun tripsWithStopTimes(tripsWithStopTimes: JsonField>) = apply { - this.tripsWithStopTimes = tripsWithStopTimes + this.tripsWithStopTimes = tripsWithStopTimes.map { it.toMutableList() } } + fun addTripsWithStopTime(tripsWithStopTime: TripsWithStopTime) = apply { + tripsWithStopTimes = + (tripsWithStopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tripsWithStopTime) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -802,11 +980,11 @@ private constructor( fun build(): StopTripGrouping = StopTripGrouping( - directionId, - stopIds.map { it.toImmutable() }, - tripHeadsigns.map { it.toImmutable() }, - tripIds.map { it.toImmutable() }, - tripsWithStopTimes.map { it.toImmutable() }, + 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.toImmutable(), ) } @@ -815,23 +993,27 @@ private constructor( class TripsWithStopTime @JsonCreator private constructor( - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), @JsonProperty("stopTimes") @ExcludeMissing private val stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun tripId(): String = tripId.getRequired("tripId") - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + fun tripId(): String = tripId.getRequired("tripId") - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes + + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId @JsonAnyGetter @ExcludeMissing @@ -840,11 +1022,13 @@ private constructor( private var validated: Boolean = false fun validate(): TripsWithStopTime = apply { - if (!validated) { - tripId() - stopTimes().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + stopTimes().forEach { it.validate() } + tripId() + validated = true } fun toBuilder() = Builder().from(this) @@ -854,32 +1038,46 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [TripsWithStopTime]. */ + class Builder internal constructor() { - private var tripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = JsonMissing.of() + private var stopTimes: JsonField>? = null + private var tripId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tripsWithStopTime: TripsWithStopTime) = apply { + stopTimes = tripsWithStopTime.stopTimes.map { it.toMutableList() } tripId = tripsWithStopTime.tripId - stopTimes = tripsWithStopTime.stopTimes additionalProperties = tripsWithStopTime.additionalProperties.toMutableMap() } - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes + this.stopTimes = stopTimes.map { it.toMutableList() } } + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopTime) + } + } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -904,8 +1102,8 @@ private constructor( fun build(): TripsWithStopTime = TripsWithStopTime( - tripId, - stopTimes.map { it.toImmutable() }, + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("tripId", tripId), additionalProperties.toImmutable(), ) } @@ -926,18 +1124,18 @@ private constructor( @JsonProperty("departureTime") @ExcludeMissing private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), @JsonProperty("stopId") @ExcludeMissing private val stopId: JsonField = JsonMissing.of(), @JsonProperty("tripId") @ExcludeMissing private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -952,41 +1150,47 @@ private constructor( fun departureTime(): Long = departureTime.getRequired("departureTime") + fun stopId(): String = stopId.getRequired("stopId") + + fun tripId(): String = tripId.getRequired("tripId") + fun serviceId(): Optional = Optional.ofNullable(serviceId.getNullable("serviceId")) fun stopHeadsign(): Optional = Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - fun stopId(): String = stopId.getRequired("stopId") - - fun tripId(): String = tripId.getRequired("tripId") - @JsonProperty("arrivalEnabled") @ExcludeMissing - fun _arrivalEnabled() = arrivalEnabled + fun _arrivalEnabled(): JsonField = arrivalEnabled @JsonProperty("arrivalTime") @ExcludeMissing - fun _arrivalTime() = arrivalTime + fun _arrivalTime(): JsonField = arrivalTime @JsonProperty("departureEnabled") @ExcludeMissing - fun _departureEnabled() = departureEnabled + fun _departureEnabled(): JsonField = departureEnabled @JsonProperty("departureTime") @ExcludeMissing - fun _departureTime() = departureTime + fun _departureTime(): JsonField = departureTime - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId - @JsonProperty("stopHeadsign") + @JsonProperty("tripId") @ExcludeMissing - fun _stopHeadsign() = stopHeadsign + fun _tripId(): JsonField = tripId - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign @JsonAnyGetter @ExcludeMissing @@ -995,17 +1199,19 @@ private constructor( private var validated: Boolean = false fun validate(): StopTime = apply { - if (!validated) { - arrivalEnabled() - arrivalTime() - departureEnabled() - departureTime() - serviceId() - stopHeadsign() - stopId() - tripId() - validated = true + if (validated) { + return@apply } + + arrivalEnabled() + arrivalTime() + departureEnabled() + departureTime() + stopId() + tripId() + serviceId() + stopHeadsign() + validated = true } fun toBuilder() = Builder().from(this) @@ -1015,16 +1221,17 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTime]. */ + class Builder internal constructor() { - private var arrivalEnabled: JsonField = JsonMissing.of() - private var arrivalTime: JsonField = JsonMissing.of() - private var departureEnabled: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() + 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 stopId: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1034,10 +1241,10 @@ private constructor( arrivalTime = stopTime.arrivalTime departureEnabled = stopTime.departureEnabled departureTime = stopTime.departureTime - serviceId = stopTime.serviceId - stopHeadsign = stopTime.stopHeadsign stopId = stopTime.stopId tripId = stopTime.tripId + serviceId = stopTime.serviceId + stopHeadsign = stopTime.stopHeadsign additionalProperties = stopTime.additionalProperties.toMutableMap() } @@ -1069,6 +1276,14 @@ private constructor( this.departureTime = departureTime } + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) fun serviceId(serviceId: JsonField) = apply { @@ -1082,14 +1297,6 @@ private constructor( this.stopHeadsign = stopHeadsign } - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1114,14 +1321,14 @@ private constructor( fun build(): StopTime = StopTime( - arrivalEnabled, - arrivalTime, - departureEnabled, - departureTime, + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureEnabled", departureEnabled), + checkRequired("departureTime", departureTime), + checkRequired("stopId", stopId), + checkRequired("tripId", tripId), serviceId, stopHeadsign, - stopId, - tripId, additionalProperties.toImmutable(), ) } @@ -1131,17 +1338,17 @@ private constructor( return true } - return /* spotless:off */ other is StopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && serviceId == other.serviceId && stopHeadsign == other.stopHeadsign && stopId == other.stopId && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, stopHeadsign, stopId, tripId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, stopId, tripId, serviceId, stopHeadsign, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "StopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, stopHeadsign=$stopHeadsign, stopId=$stopId, tripId=$tripId, additionalProperties=$additionalProperties}" + "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 { @@ -1149,17 +1356,17 @@ private constructor( return true } - return /* spotless:off */ other is TripsWithStopTime && tripId == other.tripId && stopTimes == other.stopTimes && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TripsWithStopTime && stopTimes == other.stopTimes && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tripId, stopTimes, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(stopTimes, tripId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "TripsWithStopTime{tripId=$tripId, stopTimes=$stopTimes, additionalProperties=$additionalProperties}" + "TripsWithStopTime{stopTimes=$stopTimes, tripId=$tripId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1184,27 +1391,27 @@ private constructor( class Trip @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), @JsonProperty("blockId") @ExcludeMissing private val blockId: JsonField = JsonMissing.of(), @JsonProperty("directionId") @ExcludeMissing private val directionId: JsonField = JsonMissing.of(), - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), @JsonProperty("peakOffpeak") @ExcludeMissing private val peakOffpeak: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), @JsonProperty("routeShortName") @ExcludeMissing private val routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), @JsonProperty("shapeId") @ExcludeMissing private val shapeId: JsonField = JsonMissing.of(), @@ -1221,24 +1428,24 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + + fun routeId(): String = routeId.getRequired("routeId") + + fun serviceId(): String = serviceId.getRequired("serviceId") + fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) fun directionId(): Optional = Optional.ofNullable(directionId.getNullable("directionId")) - fun id(): String = id.getRequired("id") - fun peakOffpeak(): Optional = Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - fun routeId(): String = routeId.getRequired("routeId") - fun routeShortName(): Optional = Optional.ofNullable(routeShortName.getNullable("routeShortName")) - fun serviceId(): String = serviceId.getRequired("serviceId") - fun shapeId(): Optional = Optional.ofNullable(shapeId.getNullable("shapeId")) @@ -1251,29 +1458,41 @@ private constructor( fun tripShortName(): Optional = Optional.ofNullable(tripShortName.getNullable("tripShortName")) - @JsonProperty("blockId") @ExcludeMissing fun _blockId() = blockId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("blockId") @ExcludeMissing fun _blockId(): JsonField = blockId - @JsonProperty("peakOffpeak") @ExcludeMissing fun _peakOffpeak() = peakOffpeak + @JsonProperty("directionId") + @ExcludeMissing + fun _directionId(): JsonField = directionId - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId + @JsonProperty("peakOffpeak") + @ExcludeMissing + fun _peakOffpeak(): JsonField = peakOffpeak @JsonProperty("routeShortName") @ExcludeMissing - fun _routeShortName() = routeShortName + fun _routeShortName(): JsonField = routeShortName - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId + @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId() = shapeId - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign - @JsonProperty("tripShortName") @ExcludeMissing fun _tripShortName() = tripShortName + @JsonProperty("tripShortName") + @ExcludeMissing + fun _tripShortName(): JsonField = tripShortName @JsonAnyGetter @ExcludeMissing @@ -1282,20 +1501,22 @@ private constructor( private var validated: Boolean = false fun validate(): Trip = apply { - if (!validated) { - blockId() - directionId() - id() - peakOffpeak() - routeId() - routeShortName() - serviceId() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true + if (validated) { + return@apply } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + validated = true } fun toBuilder() = Builder().from(this) @@ -1305,15 +1526,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Trip]. */ + class Builder internal constructor() { + 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 id: JsonField = JsonMissing.of() private var peakOffpeak: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() private var routeShortName: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() private var shapeId: JsonField = JsonMissing.of() private var timeZone: JsonField = JsonMissing.of() private var tripHeadsign: JsonField = JsonMissing.of() @@ -1322,13 +1544,13 @@ private constructor( @JvmSynthetic internal fun from(trip: Trip) = apply { + id = trip.id + routeId = trip.routeId + serviceId = trip.serviceId blockId = trip.blockId directionId = trip.directionId - id = trip.id peakOffpeak = trip.peakOffpeak - routeId = trip.routeId routeShortName = trip.routeShortName - serviceId = trip.serviceId shapeId = trip.shapeId timeZone = trip.timeZone tripHeadsign = trip.tripHeadsign @@ -1336,6 +1558,20 @@ private constructor( additionalProperties = trip.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + fun serviceId(serviceId: JsonField) = apply { + this.serviceId = serviceId + } + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) fun blockId(blockId: JsonField) = apply { this.blockId = blockId } @@ -1346,20 +1582,12 @@ private constructor( this.directionId = directionId } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) fun peakOffpeak(peakOffpeak: JsonField) = apply { this.peakOffpeak = peakOffpeak } - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - fun routeShortName(routeShortName: String) = routeShortName(JsonField.of(routeShortName)) @@ -1367,12 +1595,6 @@ private constructor( this.routeShortName = routeShortName } - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } @@ -1419,13 +1641,13 @@ private constructor( fun build(): Trip = Trip( + checkRequired("id", id), + checkRequired("routeId", routeId), + checkRequired("serviceId", serviceId), blockId, directionId, - id, peakOffpeak, - routeId, routeShortName, - serviceId, shapeId, timeZone, tripHeadsign, @@ -1439,17 +1661,17 @@ private constructor( return true } - return /* spotless:off */ other is Trip && blockId == other.blockId && directionId == other.directionId && id == other.id && peakOffpeak == other.peakOffpeak && routeId == other.routeId && routeShortName == other.routeShortName && serviceId == other.serviceId && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Trip && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Trip{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" + "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}" } override fun equals(other: Any?): Boolean { @@ -1457,17 +1679,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && routeId == other.routeId && scheduleDate == other.scheduleDate && serviceIds == other.serviceIds && stopTripGroupings == other.stopTripGroupings && stops == other.stops && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && routeId == other.routeId && scheduleDate == other.scheduleDate && serviceIds == other.serviceIds && stops == other.stops && stopTripGroupings == other.stopTripGroupings && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(routeId, scheduleDate, serviceIds, stopTripGroupings, stops, trips, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(routeId, scheduleDate, serviceIds, stops, stopTripGroupings, trips, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stopTripGroupings=$stopTripGroupings, stops=$stops, trips=$trips, additionalProperties=$additionalProperties}" + "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stops=$stops, stopTripGroupings=$stopTripGroupings, trips=$trips, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt index f33d2c8..5ec1ae9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt @@ -6,16 +6,19 @@ import java.time.LocalDate import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get schedule for a specific stop */ class ScheduleForStopRetrieveParams -constructor( +private constructor( private val stopId: String, private val date: LocalDate?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun stopId(): String = stopId @@ -29,10 +32,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.date?.let { queryParams.put("date", listOf(it.toString())) } queryParams.putAll(additionalQueryParams) @@ -53,8 +55,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ScheduleForStopRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var stopId: String? = null private var date: LocalDate? = null @@ -75,7 +78,13 @@ constructor( * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, * defaults to the current date) */ - fun date(date: LocalDate) = apply { this.date = date } + fun date(date: LocalDate?) = apply { this.date = date } + + /** + * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, + * defaults to the current date) + */ + fun date(date: Optional) = date(date.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -177,7 +186,7 @@ constructor( fun build(): ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, + checkRequired("stopId", stopId), date, additionalHeaders.build(), additionalQueryParams.build(), diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt index 307813a..386941c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): ScheduleForStopRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ScheduleForStopRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -146,11 +150,11 @@ private constructor( fun build(): ScheduleForStopRetrieveResponse = ScheduleForStopRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -173,9 +177,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -184,11 +190,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -198,10 +206,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -242,8 +251,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -272,13 +281,13 @@ private constructor( fun stopRouteSchedules(): List = stopRouteSchedules.getRequired("stopRouteSchedules") - @JsonProperty("date") @ExcludeMissing fun _date() = date + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId @JsonProperty("stopRouteSchedules") @ExcludeMissing - fun _stopRouteSchedules() = stopRouteSchedules + fun _stopRouteSchedules(): JsonField> = stopRouteSchedules @JsonAnyGetter @ExcludeMissing @@ -287,12 +296,14 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - date() - stopId() - stopRouteSchedules().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + date() + stopId() + stopRouteSchedules().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -302,19 +313,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { - private var date: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var stopRouteSchedules: JsonField> = - JsonMissing.of() + private var date: JsonField? = null + private var stopId: JsonField? = null + private var stopRouteSchedules: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { date = entry.date stopId = entry.stopId - stopRouteSchedules = entry.stopRouteSchedules + stopRouteSchedules = entry.stopRouteSchedules.map { it.toMutableList() } additionalProperties = entry.additionalProperties.toMutableMap() } @@ -331,9 +342,22 @@ private constructor( fun stopRouteSchedules(stopRouteSchedules: JsonField>) = apply { - this.stopRouteSchedules = stopRouteSchedules + this.stopRouteSchedules = stopRouteSchedules.map { it.toMutableList() } } + fun addStopRouteSchedule(stopRouteSchedule: StopRouteSchedule) = apply { + stopRouteSchedules = + (stopRouteSchedules ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopRouteSchedule) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -358,9 +382,11 @@ private constructor( fun build(): Entry = Entry( - date, - stopId, - stopRouteSchedules.map { it.toImmutable() }, + checkRequired("date", date), + checkRequired("stopId", stopId), + checkRequired("stopRouteSchedules", stopRouteSchedules).map { + it.toImmutable() + }, additionalProperties.toImmutable(), ) } @@ -386,11 +412,12 @@ private constructor( fun stopRouteDirectionSchedules(): List = stopRouteDirectionSchedules.getRequired("stopRouteDirectionSchedules") - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId @JsonProperty("stopRouteDirectionSchedules") @ExcludeMissing - fun _stopRouteDirectionSchedules() = stopRouteDirectionSchedules + fun _stopRouteDirectionSchedules(): JsonField> = + stopRouteDirectionSchedules @JsonAnyGetter @ExcludeMissing @@ -399,11 +426,13 @@ private constructor( private var validated: Boolean = false fun validate(): StopRouteSchedule = apply { - if (!validated) { - routeId() - stopRouteDirectionSchedules().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + routeId() + stopRouteDirectionSchedules().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -413,18 +442,20 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopRouteSchedule]. */ + class Builder internal constructor() { - private var routeId: JsonField = JsonMissing.of() + private var routeId: JsonField? = null private var stopRouteDirectionSchedules: - JsonField> = - JsonMissing.of() + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(stopRouteSchedule: StopRouteSchedule) = apply { routeId = stopRouteSchedule.routeId - stopRouteDirectionSchedules = stopRouteSchedule.stopRouteDirectionSchedules + stopRouteDirectionSchedules = + stopRouteSchedule.stopRouteDirectionSchedules.map { it.toMutableList() } additionalProperties = stopRouteSchedule.additionalProperties.toMutableMap() } @@ -438,7 +469,25 @@ private constructor( fun stopRouteDirectionSchedules( stopRouteDirectionSchedules: JsonField> - ) = apply { this.stopRouteDirectionSchedules = stopRouteDirectionSchedules } + ) = apply { + this.stopRouteDirectionSchedules = + stopRouteDirectionSchedules.map { it.toMutableList() } + } + + fun addStopRouteDirectionSchedule( + stopRouteDirectionSchedule: StopRouteDirectionSchedule + ) = apply { + stopRouteDirectionSchedules = + (stopRouteDirectionSchedules ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopRouteDirectionSchedule) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -464,8 +513,12 @@ private constructor( fun build(): StopRouteSchedule = StopRouteSchedule( - routeId, - stopRouteDirectionSchedules.map { it.toImmutable() }, + checkRequired("routeId", routeId), + checkRequired( + "stopRouteDirectionSchedules", + stopRouteDirectionSchedules + ) + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -474,10 +527,6 @@ private constructor( class StopRouteDirectionSchedule @JsonCreator private constructor( - @JsonProperty("scheduleFrequencies") - @ExcludeMissing - private val scheduleFrequencies: JsonField> = - JsonMissing.of(), @JsonProperty("scheduleStopTimes") @ExcludeMissing private val scheduleStopTimes: JsonField> = @@ -485,27 +534,34 @@ private constructor( @JsonProperty("tripHeadsign") @ExcludeMissing private val tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("scheduleFrequencies") + @ExcludeMissing + private val scheduleFrequencies: JsonField> = + JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun scheduleFrequencies(): Optional> = - Optional.ofNullable(scheduleFrequencies.getNullable("scheduleFrequencies")) - fun scheduleStopTimes(): List = scheduleStopTimes.getRequired("scheduleStopTimes") fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - @JsonProperty("scheduleFrequencies") - @ExcludeMissing - fun _scheduleFrequencies() = scheduleFrequencies + fun scheduleFrequencies(): Optional> = + Optional.ofNullable(scheduleFrequencies.getNullable("scheduleFrequencies")) @JsonProperty("scheduleStopTimes") @ExcludeMissing - fun _scheduleStopTimes() = scheduleStopTimes + fun _scheduleStopTimes(): JsonField> = scheduleStopTimes - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign + + @JsonProperty("scheduleFrequencies") + @ExcludeMissing + fun _scheduleFrequencies(): JsonField> = + scheduleFrequencies @JsonAnyGetter @ExcludeMissing @@ -514,12 +570,14 @@ private constructor( private var validated: Boolean = false fun validate(): StopRouteDirectionSchedule = apply { - if (!validated) { - scheduleFrequencies().map { it.forEach { it.validate() } } - scheduleStopTimes().forEach { it.validate() } - tripHeadsign() - validated = true + if (validated) { + return@apply } + + scheduleStopTimes().forEach { it.validate() } + tripHeadsign() + scheduleFrequencies().ifPresent { it.forEach { it.validate() } } + validated = true } fun toBuilder() = Builder().from(this) @@ -529,39 +587,55 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopRouteDirectionSchedule]. */ + class Builder internal constructor() { - private var scheduleFrequencies: JsonField> = - JsonMissing.of() - private var scheduleStopTimes: JsonField> = - JsonMissing.of() - private var tripHeadsign: JsonField = JsonMissing.of() + private var scheduleStopTimes: JsonField>? = + null + private var tripHeadsign: JsonField? = null + private var scheduleFrequencies: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(stopRouteDirectionSchedule: StopRouteDirectionSchedule) = apply { - scheduleFrequencies = stopRouteDirectionSchedule.scheduleFrequencies - scheduleStopTimes = stopRouteDirectionSchedule.scheduleStopTimes + scheduleStopTimes = + stopRouteDirectionSchedule.scheduleStopTimes.map { + it.toMutableList() + } tripHeadsign = stopRouteDirectionSchedule.tripHeadsign + scheduleFrequencies = + stopRouteDirectionSchedule.scheduleFrequencies.map { + it.toMutableList() + } additionalProperties = stopRouteDirectionSchedule.additionalProperties.toMutableMap() } - fun scheduleFrequencies(scheduleFrequencies: List) = - scheduleFrequencies(JsonField.of(scheduleFrequencies)) - - fun scheduleFrequencies( - scheduleFrequencies: JsonField> - ) = apply { this.scheduleFrequencies = scheduleFrequencies } - fun scheduleStopTimes(scheduleStopTimes: List) = scheduleStopTimes(JsonField.of(scheduleStopTimes)) fun scheduleStopTimes( scheduleStopTimes: JsonField> - ) = apply { this.scheduleStopTimes = scheduleStopTimes } + ) = apply { + this.scheduleStopTimes = scheduleStopTimes.map { it.toMutableList() } + } + + fun addScheduleStopTime(scheduleStopTime: ScheduleStopTime) = apply { + scheduleStopTimes = + (scheduleStopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(scheduleStopTime) + } + } fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) @@ -570,6 +644,29 @@ private constructor( this.tripHeadsign = tripHeadsign } + fun scheduleFrequencies(scheduleFrequencies: List) = + scheduleFrequencies(JsonField.of(scheduleFrequencies)) + + fun scheduleFrequencies( + scheduleFrequencies: JsonField> + ) = apply { + this.scheduleFrequencies = + scheduleFrequencies.map { it.toMutableList() } + } + + fun addScheduleFrequency(scheduleFrequency: ScheduleFrequency) = apply { + scheduleFrequencies = + (scheduleFrequencies ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(scheduleFrequency) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -594,9 +691,11 @@ private constructor( fun build(): StopRouteDirectionSchedule = StopRouteDirectionSchedule( - scheduleFrequencies.map { it.toImmutable() }, - scheduleStopTimes.map { it.toImmutable() }, - tripHeadsign, + checkRequired("scheduleStopTimes", scheduleStopTimes).map { + it.toImmutable() + }, + checkRequired("tripHeadsign", tripHeadsign), + (scheduleFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -620,12 +719,12 @@ private constructor( @JsonProperty("serviceId") @ExcludeMissing private val serviceId: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), @JsonProperty("tripId") @ExcludeMissing private val tripId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + private val stopHeadsign: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -642,34 +741,38 @@ private constructor( fun serviceId(): String = serviceId.getRequired("serviceId") + fun tripId(): String = tripId.getRequired("tripId") + fun stopHeadsign(): Optional = Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - fun tripId(): String = tripId.getRequired("tripId") - @JsonProperty("arrivalEnabled") @ExcludeMissing - fun _arrivalEnabled() = arrivalEnabled + fun _arrivalEnabled(): JsonField = arrivalEnabled @JsonProperty("arrivalTime") @ExcludeMissing - fun _arrivalTime() = arrivalTime + fun _arrivalTime(): JsonField = arrivalTime @JsonProperty("departureEnabled") @ExcludeMissing - fun _departureEnabled() = departureEnabled + fun _departureEnabled(): JsonField = departureEnabled @JsonProperty("departureTime") @ExcludeMissing - fun _departureTime() = departureTime + fun _departureTime(): JsonField = departureTime - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId - @JsonProperty("stopHeadsign") + @JsonProperty("tripId") @ExcludeMissing - fun _stopHeadsign() = stopHeadsign + fun _tripId(): JsonField = tripId - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign @JsonAnyGetter @ExcludeMissing @@ -678,16 +781,18 @@ private constructor( private var validated: Boolean = false fun validate(): ScheduleStopTime = apply { - if (!validated) { - arrivalEnabled() - arrivalTime() - departureEnabled() - departureTime() - serviceId() - stopHeadsign() - tripId() - validated = true + if (validated) { + return@apply } + + arrivalEnabled() + arrivalTime() + departureEnabled() + departureTime() + serviceId() + tripId() + stopHeadsign() + validated = true } fun toBuilder() = Builder().from(this) @@ -697,15 +802,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ScheduleStopTime]. */ + class Builder internal constructor() { - private var arrivalEnabled: JsonField = JsonMissing.of() - private var arrivalTime: JsonField = JsonMissing.of() - private var departureEnabled: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() + private var arrivalEnabled: JsonField? = null + private var arrivalTime: JsonField? = null + private var departureEnabled: JsonField? = null + private var departureTime: JsonField? = null + private var serviceId: JsonField? = null + private var tripId: JsonField? = null private var stopHeadsign: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -716,8 +822,8 @@ private constructor( departureEnabled = scheduleStopTime.departureEnabled departureTime = scheduleStopTime.departureTime serviceId = scheduleStopTime.serviceId - stopHeadsign = scheduleStopTime.stopHeadsign tripId = scheduleStopTime.tripId + stopHeadsign = scheduleStopTime.stopHeadsign additionalProperties = scheduleStopTime.additionalProperties.toMutableMap() } @@ -756,6 +862,10 @@ private constructor( this.serviceId = serviceId } + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + fun stopHeadsign(stopHeadsign: String) = stopHeadsign(JsonField.of(stopHeadsign)) @@ -763,10 +873,6 @@ private constructor( this.stopHeadsign = stopHeadsign } - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -791,13 +897,13 @@ private constructor( fun build(): ScheduleStopTime = ScheduleStopTime( - arrivalEnabled, - arrivalTime, - departureEnabled, - departureTime, - serviceId, + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureEnabled", departureEnabled), + checkRequired("departureTime", departureTime), + checkRequired("serviceId", serviceId), + checkRequired("tripId", tripId), stopHeadsign, - tripId, additionalProperties.toImmutable(), ) } @@ -807,38 +913,38 @@ private constructor( return true } - return /* spotless:off */ other is ScheduleStopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && serviceId == other.serviceId && stopHeadsign == other.stopHeadsign && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScheduleStopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && serviceId == other.serviceId && tripId == other.tripId && stopHeadsign == other.stopHeadsign && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, stopHeadsign, tripId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, tripId, stopHeadsign, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ScheduleStopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, stopHeadsign=$stopHeadsign, tripId=$tripId, additionalProperties=$additionalProperties}" + "ScheduleStopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, tripId=$tripId, stopHeadsign=$stopHeadsign, additionalProperties=$additionalProperties}" } @NoAutoDetect class ScheduleFrequency @JsonCreator private constructor( - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("startTime") - @ExcludeMissing - private val startTime: JsonField = JsonMissing.of(), @JsonProperty("endTime") @ExcludeMissing private val endTime: JsonField = JsonMissing.of(), @JsonProperty("headway") @ExcludeMissing private val headway: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + private val serviceDate: JsonField = JsonMissing.of(), @JsonProperty("serviceId") @ExcludeMissing private val serviceId: JsonField = JsonMissing.of(), + @JsonProperty("startTime") + @ExcludeMissing + private val startTime: JsonField = JsonMissing.of(), @JsonProperty("tripId") @ExcludeMissing private val tripId: JsonField = JsonMissing.of(), @@ -847,31 +953,41 @@ private constructor( immutableEmptyMap(), ) { - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - fun startTime(): Long = startTime.getRequired("startTime") - fun endTime(): Long = endTime.getRequired("endTime") fun headway(): Long = headway.getRequired("headway") + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + fun serviceId(): String = serviceId.getRequired("serviceId") + fun startTime(): Long = startTime.getRequired("startTime") + fun tripId(): String = tripId.getRequired("tripId") - @JsonProperty("serviceDate") + @JsonProperty("endTime") @ExcludeMissing - fun _serviceDate() = serviceDate + fun _endTime(): JsonField = endTime - @JsonProperty("startTime") @ExcludeMissing fun _startTime() = startTime + @JsonProperty("headway") + @ExcludeMissing + fun _headway(): JsonField = headway - @JsonProperty("endTime") @ExcludeMissing fun _endTime() = endTime + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate - @JsonProperty("headway") @ExcludeMissing fun _headway() = headway + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId + @JsonProperty("startTime") + @ExcludeMissing + fun _startTime(): JsonField = startTime - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId @JsonAnyGetter @ExcludeMissing @@ -880,15 +996,17 @@ private constructor( private var validated: Boolean = false fun validate(): ScheduleFrequency = apply { - if (!validated) { - serviceDate() - startTime() - endTime() - headway() - serviceId() - tripId() - validated = true + if (validated) { + return@apply } + + endTime() + headway() + serviceDate() + serviceId() + startTime() + tripId() + validated = true } fun toBuilder() = Builder().from(this) @@ -898,42 +1016,30 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ScheduleFrequency]. */ + class Builder internal constructor() { - private var serviceDate: JsonField = JsonMissing.of() - private var startTime: JsonField = JsonMissing.of() - private var endTime: JsonField = JsonMissing.of() - private var headway: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() + private var endTime: JsonField? = null + private var headway: JsonField? = null + private var serviceDate: JsonField? = null + private var serviceId: JsonField? = null + private var startTime: JsonField? = null + private var tripId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scheduleFrequency: ScheduleFrequency) = apply { - serviceDate = scheduleFrequency.serviceDate - startTime = scheduleFrequency.startTime endTime = scheduleFrequency.endTime headway = scheduleFrequency.headway + serviceDate = scheduleFrequency.serviceDate serviceId = scheduleFrequency.serviceId + startTime = scheduleFrequency.startTime tripId = scheduleFrequency.tripId additionalProperties = scheduleFrequency.additionalProperties.toMutableMap() } - fun serviceDate(serviceDate: Long) = - serviceDate(JsonField.of(serviceDate)) - - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun startTime(startTime: Long) = startTime(JsonField.of(startTime)) - - fun startTime(startTime: JsonField) = apply { - this.startTime = startTime - } - fun endTime(endTime: Long) = endTime(JsonField.of(endTime)) fun endTime(endTime: JsonField) = apply { this.endTime = endTime } @@ -942,12 +1048,25 @@ private constructor( fun headway(headway: JsonField) = apply { this.headway = headway } + fun serviceDate(serviceDate: Long) = + serviceDate(JsonField.of(serviceDate)) + + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } + fun startTime(startTime: Long) = startTime(JsonField.of(startTime)) + + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) fun tripId(tripId: JsonField) = apply { this.tripId = tripId } @@ -976,12 +1095,12 @@ private constructor( fun build(): ScheduleFrequency = ScheduleFrequency( - serviceDate, - startTime, - endTime, - headway, - serviceId, - tripId, + checkRequired("endTime", endTime), + checkRequired("headway", headway), + checkRequired("serviceDate", serviceDate), + checkRequired("serviceId", serviceId), + checkRequired("startTime", startTime), + checkRequired("tripId", tripId), additionalProperties.toImmutable(), ) } @@ -991,17 +1110,17 @@ private constructor( return true } - return /* spotless:off */ other is ScheduleFrequency && serviceDate == other.serviceDate && startTime == other.startTime && endTime == other.endTime && headway == other.headway && serviceId == other.serviceId && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScheduleFrequency && endTime == other.endTime && headway == other.headway && serviceDate == other.serviceDate && serviceId == other.serviceId && startTime == other.startTime && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(serviceDate, startTime, endTime, headway, serviceId, tripId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(endTime, headway, serviceDate, serviceId, startTime, tripId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ScheduleFrequency{serviceDate=$serviceDate, startTime=$startTime, endTime=$endTime, headway=$headway, serviceId=$serviceId, tripId=$tripId, additionalProperties=$additionalProperties}" + "ScheduleFrequency{endTime=$endTime, headway=$headway, serviceDate=$serviceDate, serviceId=$serviceId, startTime=$startTime, tripId=$tripId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1009,17 +1128,17 @@ private constructor( return true } - return /* spotless:off */ other is StopRouteDirectionSchedule && scheduleFrequencies == other.scheduleFrequencies && scheduleStopTimes == other.scheduleStopTimes && tripHeadsign == other.tripHeadsign && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopRouteDirectionSchedule && scheduleStopTimes == other.scheduleStopTimes && tripHeadsign == other.tripHeadsign && scheduleFrequencies == other.scheduleFrequencies && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(scheduleFrequencies, scheduleStopTimes, tripHeadsign, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(scheduleStopTimes, tripHeadsign, scheduleFrequencies, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "StopRouteDirectionSchedule{scheduleFrequencies=$scheduleFrequencies, scheduleStopTimes=$scheduleStopTimes, tripHeadsign=$tripHeadsign, additionalProperties=$additionalProperties}" + "StopRouteDirectionSchedule{scheduleStopTimes=$scheduleStopTimes, tripHeadsign=$tripHeadsign, scheduleFrequencies=$scheduleFrequencies, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt index e7084d4..2d08c20 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt @@ -5,16 +5,19 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Search for a route based on its name. */ class SearchForRouteListParams -constructor( +private constructor( private val input: String, private val maxCount: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The string to search for. */ fun input(): String = input @@ -26,10 +29,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.input.let { queryParams.put("input", listOf(it.toString())) } this.maxCount?.let { queryParams.put("maxCount", listOf(it.toString())) } @@ -44,8 +46,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SearchForRouteListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var input: String? = null private var maxCount: Long? = null @@ -64,7 +67,14 @@ constructor( fun input(input: String) = apply { this.input = input } /** The max number of results to return. Defaults to 20. */ - fun maxCount(maxCount: Long) = apply { this.maxCount = maxCount } + fun maxCount(maxCount: Long?) = apply { this.maxCount = maxCount } + + /** The max number of results to return. Defaults to 20. */ + fun maxCount(maxCount: Long) = maxCount(maxCount as Long?) + + /** The max number of results to return. Defaults to 20. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maxCount(maxCount: Optional) = maxCount(maxCount.orElse(null) as Long?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -166,7 +176,7 @@ constructor( fun build(): SearchForRouteListParams = SearchForRouteListParams( - checkNotNull(input) { "`input` is required but was not set" }, + checkRequired("input", input), maxCount, additionalHeaders.build(), additionalQueryParams.build(), diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt index c845a37..0db7b57 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): SearchForRouteListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().map { it.validate() } - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -84,12 +87,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SearchForRouteListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null private var data: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -144,10 +148,10 @@ private constructor( fun build(): SearchForRouteListResponse = SearchForRouteListResponse( - code, - currentTime, - text, - version, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), data, additionalProperties.toImmutable(), ) @@ -181,13 +185,21 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -196,13 +208,15 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -212,18 +226,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var outOfRange: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list + list = data.list.map { it.toMutableList() } outOfRange = data.outOfRange references = data.references additionalProperties = data.additionalProperties.toMutableMap() @@ -237,7 +252,22 @@ private constructor( fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) @@ -270,10 +300,10 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, - outOfRange, - references, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -282,18 +312,21 @@ private constructor( class List @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), @JsonProperty("agencyId") @ExcludeMissing private val agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), @JsonProperty("longName") @ExcludeMissing private val longName: JsonField = JsonMissing.of(), @@ -306,9 +339,6 @@ private constructor( @JsonProperty("textColor") @ExcludeMissing private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @@ -316,15 +346,17 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + fun agencyId(): String = agencyId.getRequired("agencyId") + fun type(): Long = type.getRequired("type") + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun id(): String = id.getRequired("id") - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) fun nullSafeShortName(): Optional = @@ -336,31 +368,35 @@ private constructor( fun textColor(): Optional = Optional.ofNullable(textColor.getNullable("textColor")) - fun type(): Long = type.getRequired("type") - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId() = agencyId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("color") @ExcludeMissing fun _color() = color + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - @JsonProperty("longName") @ExcludeMissing fun _longName() = longName + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName @JsonProperty("nullSafeShortName") @ExcludeMissing - fun _nullSafeShortName() = nullSafeShortName - - @JsonProperty("shortName") @ExcludeMissing fun _shortName() = shortName + fun _nullSafeShortName(): JsonField = nullSafeShortName - @JsonProperty("textColor") @ExcludeMissing fun _textColor() = textColor + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -369,19 +405,21 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - agencyId() - color() - description() - id() - longName() - nullSafeShortName() - shortName() - textColor() - type() - url() - validated = true + if (validated) { + return@apply } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + validated = true } fun toBuilder() = Builder().from(this) @@ -391,39 +429,48 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { - private var agencyId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null private var color: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() private var longName: JsonField = JsonMissing.of() private var nullSafeShortName: JsonField = JsonMissing.of() private var shortName: JsonField = JsonMissing.of() private var textColor: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { + id = list.id agencyId = list.agencyId + type = list.type color = list.color description = list.description - id = list.id longName = list.longName nullSafeShortName = list.nullSafeShortName shortName = list.shortName textColor = list.textColor - type = list.type url = list.url additionalProperties = list.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + fun type(type: Long) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun color(color: String) = color(JsonField.of(color)) fun color(color: JsonField) = apply { this.color = color } @@ -434,10 +481,6 @@ private constructor( this.description = description } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun longName(longName: String) = longName(JsonField.of(longName)) fun longName(longName: JsonField) = apply { this.longName = longName } @@ -457,10 +500,6 @@ private constructor( fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - fun url(url: String) = url(JsonField.of(url)) fun url(url: JsonField) = apply { this.url = url } @@ -489,15 +528,15 @@ private constructor( fun build(): List = List( - agencyId, + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), color, description, - id, longName, nullSafeShortName, shortName, textColor, - type, url, additionalProperties.toImmutable(), ) @@ -508,17 +547,17 @@ private constructor( return true } - return /* spotless:off */ other is List && agencyId == other.agencyId && color == other.color && description == other.description && id == other.id && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(agencyId, color, description, id, longName, nullSafeShortName, shortName, textColor, type, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{agencyId=$agencyId, color=$color, description=$description, id=$id, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, type=$type, url=$url, additionalProperties=$additionalProperties}" + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt index 5de1fb8..0c20584 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt @@ -5,16 +5,19 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Search for a stop based on its name. */ class SearchForStopListParams -constructor( +private constructor( private val input: String, private val maxCount: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The string to search for. */ fun input(): String = input @@ -26,10 +29,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.input.let { queryParams.put("input", listOf(it.toString())) } this.maxCount?.let { queryParams.put("maxCount", listOf(it.toString())) } @@ -44,8 +46,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SearchForStopListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var input: String? = null private var maxCount: Long? = null @@ -64,7 +67,14 @@ constructor( fun input(input: String) = apply { this.input = input } /** The max number of results to return. Defaults to 20. */ - fun maxCount(maxCount: Long) = apply { this.maxCount = maxCount } + fun maxCount(maxCount: Long?) = apply { this.maxCount = maxCount } + + /** The max number of results to return. Defaults to 20. */ + fun maxCount(maxCount: Long) = maxCount(maxCount as Long?) + + /** The max number of results to return. Defaults to 20. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maxCount(maxCount: Optional) = maxCount(maxCount.orElse(null) as Long?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -166,7 +176,7 @@ constructor( fun build(): SearchForStopListParams = SearchForStopListParams( - checkNotNull(input) { "`input` is required but was not set" }, + checkRequired("input", input), maxCount, additionalHeaders.build(), additionalQueryParams.build(), diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt index eb341ad..ef89eff 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): SearchForStopListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().map { it.validate() } - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -84,12 +87,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SearchForStopListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var currentTime: JsonField? = null + private var text: JsonField? = null + private var version: JsonField? = null private var data: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -144,10 +148,10 @@ private constructor( fun build(): SearchForStopListResponse = SearchForStopListResponse( - code, - currentTime, - text, - version, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), data, additionalProperties.toImmutable(), ) @@ -181,13 +185,21 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -196,13 +208,15 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -212,18 +226,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var outOfRange: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var outOfRange: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list + list = data.list.map { it.toMutableList() } outOfRange = data.outOfRange references = data.references additionalProperties = data.additionalProperties.toMutableMap() @@ -237,7 +252,22 @@ private constructor( fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) @@ -270,10 +300,10 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, - outOfRange, - references, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -282,21 +312,12 @@ private constructor( class List @JsonCreator private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @@ -313,6 +334,15 @@ private constructor( @ExcludeMissing private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -320,18 +350,10 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - fun id(): String = id.getRequired("id") fun lat(): Double = lat.getRequired("lat") - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -343,32 +365,48 @@ private constructor( fun staticRouteIds(): kotlin.collections.List = staticRouteIds.getRequired("staticRouteIds") + fun code(): Optional = Optional.ofNullable(code.getNullable("code")) + + fun direction(): Optional = + Optional.ofNullable(direction.getNullable("direction")) + + fun locationType(): Optional = + Optional.ofNullable(locationType.getNullable("locationType")) + fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType @JsonProperty("wheelchairBoarding") @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding + fun _wheelchairBoarding(): JsonField = wheelchairBoarding @JsonAnyGetter @ExcludeMissing @@ -377,20 +415,22 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true + if (validated) { + return@apply } + + id() + lat() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + locationType() + wheelchairBoarding() + validated = true } fun toBuilder() = Builder().from(this) @@ -400,46 +440,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var lat: 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 id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = - JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { - code = list.code - direction = list.direction id = list.id lat = list.lat - locationType = list.locationType lon = list.lon name = list.name parent = list.parent - routeIds = list.routeIds - staticRouteIds = list.staticRouteIds + routeIds = list.routeIds.map { it.toMutableList() } + staticRouteIds = list.staticRouteIds.map { it.toMutableList() } + code = list.code + direction = list.direction + locationType = list.locationType wheelchairBoarding = list.wheelchairBoarding additionalProperties = list.additionalProperties.toMutableMap() } - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } @@ -448,12 +480,6 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -470,7 +496,20 @@ private constructor( routeIds(JsonField.of(routeIds)) fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds + this.routeIds = routeIds.map { it.toMutableList() } + } + + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(routeId) + } } fun staticRouteIds(staticRouteIds: kotlin.collections.List) = @@ -478,9 +517,36 @@ private constructor( fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } } + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) @@ -512,16 +578,16 @@ private constructor( fun build(): List = List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - id, - lat, locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -532,17 +598,17 @@ private constructor( return true } - return /* spotless:off */ other is List && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "List{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt index d484d52..83b1125 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ class ShapeRetrieveParams -constructor( +private constructor( private val shapeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun shapeId(): String = shapeId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ShapeRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var shapeId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): ShapeRetrieveParams = ShapeRetrieveParams( - checkNotNull(shapeId) { "`shapeId` is required but was not set" }, + checkRequired("shapeId", shapeId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt index cb95187..3ab1dd0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): ShapeRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ShapeRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): ShapeRetrieveResponse = ShapeRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -253,29 +262,29 @@ private constructor( @JsonProperty("length") @ExcludeMissing private val length: JsonField = JsonMissing.of(), - @JsonProperty("levels") - @ExcludeMissing - private val levels: JsonField = JsonMissing.of(), @JsonProperty("points") @ExcludeMissing private val points: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + private val levels: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { fun length(): Long = length.getRequired("length") - fun levels(): Optional = Optional.ofNullable(levels.getNullable("levels")) - /** Encoded polyline format representing the shape of the path */ fun points(): String = points.getRequired("points") - @JsonProperty("length") @ExcludeMissing fun _length() = length + fun levels(): Optional = Optional.ofNullable(levels.getNullable("levels")) - @JsonProperty("levels") @ExcludeMissing fun _levels() = levels + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length /** Encoded polyline format representing the shape of the path */ - @JsonProperty("points") @ExcludeMissing fun _points() = points + @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points + + @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels @JsonAnyGetter @ExcludeMissing @@ -284,12 +293,14 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - length() - levels() - points() - validated = true + if (validated) { + return@apply } + + length() + points() + levels() + validated = true } fun toBuilder() = Builder().from(this) @@ -299,18 +310,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { - private var length: JsonField = JsonMissing.of() + private var length: JsonField? = null + private var points: JsonField? = null private var levels: JsonField = JsonMissing.of() - private var points: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { length = entry.length - levels = entry.levels points = entry.points + levels = entry.levels additionalProperties = entry.additionalProperties.toMutableMap() } @@ -318,16 +330,16 @@ private constructor( fun length(length: JsonField) = apply { this.length = length } - fun levels(levels: String) = levels(JsonField.of(levels)) - - fun levels(levels: JsonField) = apply { this.levels = levels } - /** Encoded polyline format representing the shape of the path */ fun points(points: String) = points(JsonField.of(points)) /** Encoded polyline format representing the shape of the path */ fun points(points: JsonField) = apply { this.points = points } + fun levels(levels: String) = levels(JsonField.of(levels)) + + fun levels(levels: JsonField) = apply { this.levels = levels } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -352,9 +364,9 @@ private constructor( fun build(): Entry = Entry( - length, + checkRequired("length", length), + checkRequired("points", points), levels, - points, additionalProperties.toImmutable(), ) } @@ -364,17 +376,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && length == other.length && points == other.points && levels == other.levels && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(length, points, levels, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + "Entry{length=$length, points=$points, levels=$levels, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt index 5ed4d90..62ecdf9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get stop IDs for a specific agency */ class StopIdsForAgencyListParams -constructor( +private constructor( private val agencyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun agencyId(): String = agencyId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [StopIdsForAgencyListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var agencyId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): StopIdsForAgencyListParams = StopIdsForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, + checkRequired("agencyId", agencyId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt index 47ff328..f73bb4a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt @@ -12,6 +12,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -41,15 +42,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -66,14 +67,16 @@ private constructor( private var validated: Boolean = false fun validate(): StopIdsForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -83,13 +86,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopIdsForAgencyListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -143,11 +147,11 @@ private constructor( fun build(): StopIdsForAgencyListResponse = StopIdsForAgencyListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -175,11 +179,15 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -188,12 +196,14 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list() - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -203,17 +213,18 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list + list = data.list.map { it.toMutableList() } references = data.references additionalProperties = data.additionalProperties.toMutableMap() } @@ -226,7 +237,22 @@ private constructor( fun list(list: List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: String) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun references(references: References) = references(JsonField.of(references)) @@ -255,9 +281,9 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, - references, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), additionalProperties.toImmutable(), ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt index 1b46e7b..2f25115 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get details of a specific stop */ class StopRetrieveParams -constructor( +private constructor( private val stopId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun stopId(): String = stopId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [StopRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var stopId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): StopRetrieveParams = StopRetrieveParams( - checkNotNull(stopId) { "`stopId` is required but was not set" }, + checkRequired("stopId", stopId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt index 0888b1b..1650ec1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): StopRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): StopRetrieveResponse = StopRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -250,21 +259,12 @@ private constructor( class Entry @JsonCreator private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @@ -280,6 +280,15 @@ private constructor( @JsonProperty("staticRouteIds") @ExcludeMissing private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -287,18 +296,10 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - fun id(): String = id.getRequired("id") fun lat(): Double = lat.getRequired("lat") - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -309,32 +310,48 @@ private constructor( fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") + fun code(): Optional = Optional.ofNullable(code.getNullable("code")) + + fun direction(): Optional = + Optional.ofNullable(direction.getNullable("direction")) + + fun locationType(): Optional = + Optional.ofNullable(locationType.getNullable("locationType")) + fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType @JsonProperty("wheelchairBoarding") @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding + fun _wheelchairBoarding(): JsonField = wheelchairBoarding @JsonAnyGetter @ExcludeMissing @@ -343,20 +360,22 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true + if (validated) { + return@apply } + + id() + lat() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + locationType() + wheelchairBoarding() + validated = true } fun toBuilder() = Builder().from(this) @@ -366,45 +385,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var lat: 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 id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { - code = entry.code - direction = entry.direction id = entry.id lat = entry.lat - locationType = entry.locationType lon = entry.lon name = entry.name parent = entry.parent - routeIds = entry.routeIds - staticRouteIds = entry.staticRouteIds + routeIds = entry.routeIds.map { it.toMutableList() } + staticRouteIds = entry.staticRouteIds.map { it.toMutableList() } + code = entry.code + direction = entry.direction + locationType = entry.locationType wheelchairBoarding = entry.wheelchairBoarding additionalProperties = entry.additionalProperties.toMutableMap() } - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } @@ -413,12 +425,6 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -433,13 +439,55 @@ private constructor( fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - fun routeIds(routeIds: JsonField>) = apply { this.routeIds = routeIds } + fun routeIds(routeIds: JsonField>) = apply { + this.routeIds = routeIds.map { it.toMutableList() } + } + + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(routeId) + } + } fun staticRouteIds(staticRouteIds: List) = staticRouteIds(JsonField.of(staticRouteIds)) fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType } fun wheelchairBoarding(wheelchairBoarding: String) = @@ -473,16 +521,16 @@ private constructor( fun build(): Entry = Entry( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - id, - lat, locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -493,17 +541,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "Entry{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt index aa654da..e58a7ed 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get stops for a specific agency */ class StopsForAgencyListParams -constructor( +private constructor( private val agencyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun agencyId(): String = agencyId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [StopsForAgencyListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var agencyId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): StopsForAgencyListParams = StopsForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, + checkRequired("agencyId", agencyId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt index b3e2c4e..0e16b9a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -31,15 +32,15 @@ private constructor( @JsonProperty("limitExceeded") @ExcludeMissing private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing private val list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing private val references: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -53,27 +54,33 @@ private constructor( fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - fun outOfRange(): Optional = Optional.ofNullable(outOfRange.getNullable("outOfRange")) - fun list(): kotlin.collections.List = list.getRequired("list") fun references(): References = references.getRequired("references") - @JsonProperty("code") @ExcludeMissing fun _code() = code + fun outOfRange(): Optional = Optional.ofNullable(outOfRange.getNullable("outOfRange")) - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange(): JsonField = outOfRange @JsonAnyGetter @ExcludeMissing @@ -90,17 +97,19 @@ private constructor( private var validated: Boolean = false fun validate(): StopsForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - limitExceeded() - outOfRange() - list().forEach { it.validate() } - references().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,16 +119,17 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopsForAgencyListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var limitExceeded: JsonField = JsonMissing.of() + private var code: JsonField? = null + 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 list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -129,9 +139,9 @@ private constructor( text = stopsForAgencyListResponse.text version = stopsForAgencyListResponse.version limitExceeded = stopsForAgencyListResponse.limitExceeded - outOfRange = stopsForAgencyListResponse.outOfRange - list = stopsForAgencyListResponse.list + list = stopsForAgencyListResponse.list.map { it.toMutableList() } references = stopsForAgencyListResponse.references + outOfRange = stopsForAgencyListResponse.outOfRange additionalProperties = stopsForAgencyListResponse.additionalProperties.toMutableMap() } @@ -157,18 +167,33 @@ private constructor( this.limitExceeded = limitExceeded } - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun references(references: References) = references(JsonField.of(references)) fun references(references: JsonField) = apply { this.references = references } + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -190,14 +215,14 @@ private constructor( fun build(): StopsForAgencyListResponse = StopsForAgencyListResponse( - code, - currentTime, - text, - version, - limitExceeded, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), outOfRange, - list.map { it.toImmutable() }, - references, additionalProperties.toImmutable(), ) } @@ -206,17 +231,8 @@ private constructor( class List @JsonCreator private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing @@ -230,6 +246,15 @@ private constructor( @JsonProperty("staticRouteIds") @ExcludeMissing private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -237,17 +262,10 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - fun id(): String = id.getRequired("id") fun lat(): Double = lat.getRequired("lat") - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -259,32 +277,45 @@ private constructor( fun staticRouteIds(): kotlin.collections.List = staticRouteIds.getRequired("staticRouteIds") + fun code(): Optional = Optional.ofNullable(code.getNullable("code")) + + fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) + + fun locationType(): Optional = + Optional.ofNullable(locationType.getNullable("locationType")) + fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds + @JsonProperty("direction") @ExcludeMissing fun _direction(): JsonField = direction - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType @JsonProperty("wheelchairBoarding") @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding + fun _wheelchairBoarding(): JsonField = wheelchairBoarding @JsonAnyGetter @ExcludeMissing @@ -293,20 +324,22 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true + if (validated) { + return@apply } + + id() + lat() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + locationType() + wheelchairBoarding() + validated = true } fun toBuilder() = Builder().from(this) @@ -316,46 +349,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var lat: 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 id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = - JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { - code = list.code - direction = list.direction id = list.id lat = list.lat - locationType = list.locationType lon = list.lon name = list.name parent = list.parent - routeIds = list.routeIds - staticRouteIds = list.staticRouteIds + routeIds = list.routeIds.map { it.toMutableList() } + staticRouteIds = list.staticRouteIds.map { it.toMutableList() } + code = list.code + direction = list.direction + locationType = list.locationType wheelchairBoarding = list.wheelchairBoarding additionalProperties = list.additionalProperties.toMutableMap() } - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } @@ -364,12 +389,6 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -386,14 +405,54 @@ private constructor( routeIds(JsonField.of(routeIds)) fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds + this.routeIds = routeIds.map { it.toMutableList() } + } + + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(routeId) + } } fun staticRouteIds(staticRouteIds: kotlin.collections.List) = staticRouteIds(JsonField.of(staticRouteIds)) fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } + } + + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType } fun wheelchairBoarding(wheelchairBoarding: String) = @@ -424,16 +483,16 @@ private constructor( fun build(): List = List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - id, - lat, locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -444,17 +503,17 @@ private constructor( return true } - return /* spotless:off */ other is List && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "List{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -462,15 +521,15 @@ private constructor( return true } - return /* spotless:off */ other is StopsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && limitExceeded == other.limitExceeded && outOfRange == other.outOfRange && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is StopsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, limitExceeded, outOfRange, list, references, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, limitExceeded, list, references, outOfRange, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "StopsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, limitExceeded=$limitExceeded, outOfRange=$outOfRange, list=$list, references=$references, additionalProperties=$additionalProperties}" + "StopsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt index 1da3e8f..679c6c6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt @@ -5,11 +5,14 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** stops-for-location */ class StopsForLocationListParams -constructor( +private constructor( private val lat: Double, private val lon: Double, private val latSpan: Double?, @@ -18,7 +21,7 @@ constructor( private val radius: Double?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun lat(): Double = lat @@ -40,10 +43,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.lat.let { queryParams.put("lat", listOf(it.toString())) } this.lon.let { queryParams.put("lon", listOf(it.toString())) } @@ -62,8 +64,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [StopsForLocationListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var lat: Double? = null private var lon: Double? = null @@ -91,16 +94,40 @@ constructor( fun lon(lon: Double) = apply { this.lon = lon } /** An alternative to radius to set the search bounding box (optional) */ - fun latSpan(latSpan: Double) = apply { this.latSpan = latSpan } + fun latSpan(latSpan: Double?) = apply { this.latSpan = latSpan } /** An alternative to radius to set the search bounding box (optional) */ - fun lonSpan(lonSpan: Double) = apply { this.lonSpan = lonSpan } + fun latSpan(latSpan: Double) = latSpan(latSpan as Double?) + + /** An alternative to radius to set the search bounding box (optional) */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun latSpan(latSpan: Optional) = latSpan(latSpan.orElse(null) as Double?) + + /** An alternative to radius to set the search bounding box (optional) */ + fun lonSpan(lonSpan: Double?) = apply { this.lonSpan = lonSpan } + + /** An alternative to radius to set the search bounding box (optional) */ + fun lonSpan(lonSpan: Double) = lonSpan(lonSpan as Double?) + + /** An alternative to radius to set the search bounding box (optional) */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.orElse(null) as Double?) + + /** A search query string to filter the results */ + fun query(query: String?) = apply { this.query = query } /** A search query string to filter the results */ - fun query(query: String) = apply { this.query = query } + fun query(query: Optional) = query(query.orElse(null)) + + /** The radius in meters to search within */ + fun radius(radius: Double?) = apply { this.radius = radius } + + /** The radius in meters to search within */ + fun radius(radius: Double) = radius(radius as Double?) /** The radius in meters to search within */ - fun radius(radius: Double) = apply { this.radius = radius } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun radius(radius: Optional) = radius(radius.orElse(null) as Double?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -202,8 +229,8 @@ constructor( fun build(): StopsForLocationListParams = StopsForLocationListParams( - checkNotNull(lat) { "`lat` is required but was not set" }, - checkNotNull(lon) { "`lon` is required but was not set" }, + checkRequired("lat", lat), + checkRequired("lon", lon), latSpan, lonSpan, query, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt index e1efeed..6a8b14c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): StopsForLocationListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopsForLocationListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): StopsForLocationListResponse = StopsForLocationListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -160,35 +164,43 @@ private constructor( @JsonProperty("limitExceeded") @ExcludeMissing private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), @JsonProperty("list") @ExcludeMissing private val list: JsonField> = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing private val references: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - fun outOfRange(): Optional = - Optional.ofNullable(outOfRange.getNullable("outOfRange")) - fun list(): kotlin.collections.List = list.getRequired("list") fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + fun outOfRange(): Optional = + Optional.ofNullable(outOfRange.getNullable("outOfRange")) - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list + + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange @JsonAnyGetter @ExcludeMissing @@ -197,13 +209,15 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - outOfRange() - list().forEach { it.validate() } - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + validated = true } fun toBuilder() = Builder().from(this) @@ -213,20 +227,21 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: 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 list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - outOfRange = data.outOfRange - list = data.list + list = data.list.map { it.toMutableList() } references = data.references + outOfRange = data.outOfRange additionalProperties = data.additionalProperties.toMutableMap() } @@ -236,13 +251,24 @@ private constructor( this.limitExceeded = limitExceeded } - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun references(references: References) = references(JsonField.of(references)) @@ -250,6 +276,10 @@ private constructor( this.references = references } + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -271,10 +301,10 @@ private constructor( fun build(): Data = Data( - limitExceeded, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), outOfRange, - list.map { it.toImmutable() }, - references, additionalProperties.toImmutable(), ) } @@ -283,21 +313,12 @@ private constructor( class List @JsonCreator private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @@ -314,6 +335,15 @@ private constructor( @ExcludeMissing private val staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -321,18 +351,10 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - fun id(): String = id.getRequired("id") fun lat(): Double = lat.getRequired("lat") - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -344,32 +366,48 @@ private constructor( fun staticRouteIds(): kotlin.collections.List = staticRouteIds.getRequired("staticRouteIds") + fun code(): Optional = Optional.ofNullable(code.getNullable("code")) + + fun direction(): Optional = + Optional.ofNullable(direction.getNullable("direction")) + + fun locationType(): Optional = + Optional.ofNullable(locationType.getNullable("locationType")) + fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("locationType") @ExcludeMissing fun _locationType() = locationType + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("routeIds") + @ExcludeMissing + fun _routeIds(): JsonField> = routeIds - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("staticRouteIds") + @ExcludeMissing + fun _staticRouteIds(): JsonField> = staticRouteIds - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("routeIds") @ExcludeMissing fun _routeIds() = routeIds + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction - @JsonProperty("staticRouteIds") @ExcludeMissing fun _staticRouteIds() = staticRouteIds + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType @JsonProperty("wheelchairBoarding") @ExcludeMissing - fun _wheelchairBoarding() = wheelchairBoarding + fun _wheelchairBoarding(): JsonField = wheelchairBoarding @JsonAnyGetter @ExcludeMissing @@ -378,20 +416,22 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - code() - direction() - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - wheelchairBoarding() - validated = true + if (validated) { + return@apply } + + id() + lat() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + locationType() + wheelchairBoarding() + validated = true } fun toBuilder() = Builder().from(this) @@ -401,46 +441,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { + private var id: JsonField? = null + private var lat: 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 id: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() private var locationType: JsonField = JsonMissing.of() - private var lon: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var routeIds: JsonField> = JsonMissing.of() - private var staticRouteIds: JsonField> = - JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { - code = list.code - direction = list.direction id = list.id lat = list.lat - locationType = list.locationType lon = list.lon name = list.name parent = list.parent - routeIds = list.routeIds - staticRouteIds = list.staticRouteIds + routeIds = list.routeIds.map { it.toMutableList() } + staticRouteIds = list.staticRouteIds.map { it.toMutableList() } + code = list.code + direction = list.direction + locationType = list.locationType wheelchairBoarding = list.wheelchairBoarding additionalProperties = list.additionalProperties.toMutableMap() } - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } @@ -449,12 +481,6 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -471,7 +497,20 @@ private constructor( routeIds(JsonField.of(routeIds)) fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds + this.routeIds = routeIds.map { it.toMutableList() } + } + + fun addRouteId(routeId: String) = apply { + routeIds = + (routeIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(routeId) + } } fun staticRouteIds(staticRouteIds: kotlin.collections.List) = @@ -479,9 +518,36 @@ private constructor( fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds + this.staticRouteIds = staticRouteIds.map { it.toMutableList() } } + fun addStaticRouteId(staticRouteId: String) = apply { + staticRouteIds = + (staticRouteIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(staticRouteId) + } + } + + fun code(code: String) = code(JsonField.of(code)) + + fun code(code: JsonField) = apply { this.code = code } + + fun direction(direction: String) = direction(JsonField.of(direction)) + + fun direction(direction: JsonField) = apply { this.direction = direction } + + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) @@ -513,16 +579,16 @@ private constructor( fun build(): List = List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - id, - lat, locationType, - lon, - name, - parent, - routeIds.map { it.toImmutable() }, - staticRouteIds.map { it.toImmutable() }, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -533,17 +599,17 @@ private constructor( return true } - return /* spotless:off */ other is List && code == other.code && direction == other.direction && id == other.id && lat == other.lat && locationType == other.locationType && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, direction, id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{code=$code, direction=$direction, id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "List{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -551,17 +617,17 @@ private constructor( return true } - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && outOfRange == other.outOfRange && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, outOfRange, list, references, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, outOfRange=$outOfRange, list=$list, references=$references, additionalProperties=$additionalProperties}" + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt index 7dcf9a4..3345bb5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt @@ -5,17 +5,20 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get stops for a specific route */ class StopsForRouteListParams -constructor( +private constructor( private val routeId: String, private val includePolylines: Boolean?, private val time: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun routeId(): String = routeId @@ -29,10 +32,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.includePolylines?.let { queryParams.put("includePolylines", listOf(it.toString())) } this.time?.let { queryParams.put("time", listOf(it.toString())) } @@ -54,8 +56,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [StopsForRouteListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var routeId: String? = null private var includePolylines: Boolean? = null @@ -75,12 +78,24 @@ constructor( fun routeId(routeId: String) = apply { this.routeId = routeId } /** Include polyline elements in the response (default true) */ - fun includePolylines(includePolylines: Boolean) = apply { + fun includePolylines(includePolylines: Boolean?) = apply { this.includePolylines = includePolylines } + /** Include polyline elements in the response (default true) */ + fun includePolylines(includePolylines: Boolean) = + includePolylines(includePolylines as Boolean?) + + /** Include polyline elements in the response (default true) */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includePolylines(includePolylines: Optional) = + includePolylines(includePolylines.orElse(null) as Boolean?) + + /** Specify service date (YYYY-MM-DD or epoch) (default today) */ + fun time(time: String?) = apply { this.time = time } + /** Specify service date (YYYY-MM-DD or epoch) (default today) */ - fun time(time: String) = apply { this.time = time } + fun time(time: Optional) = time(time.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -182,7 +197,7 @@ constructor( fun build(): StopsForRouteListParams = StopsForRouteListParams( - checkNotNull(routeId) { "`routeId` is required but was not set" }, + checkRequired("routeId", routeId), includePolylines, time, additionalHeaders.build(), diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt index e42c0f0..2676f66 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): StopsForRouteListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopsForRouteListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): StopsForRouteListResponse = StopsForRouteListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -277,13 +286,19 @@ private constructor( fun stopIds(): Optional> = Optional.ofNullable(stopIds.getNullable("stopIds")) - @JsonProperty("polylines") @ExcludeMissing fun _polylines() = polylines + @JsonProperty("polylines") + @ExcludeMissing + fun _polylines(): JsonField> = polylines - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - @JsonProperty("stopGroupings") @ExcludeMissing fun _stopGroupings() = stopGroupings + @JsonProperty("stopGroupings") + @ExcludeMissing + fun _stopGroupings(): JsonField> = stopGroupings - @JsonProperty("stopIds") @ExcludeMissing fun _stopIds() = stopIds + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds @JsonAnyGetter @ExcludeMissing @@ -292,13 +307,15 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - polylines().map { it.forEach { it.validate() } } - routeId() - stopGroupings().map { it.forEach { it.validate() } } - stopIds() - validated = true + if (validated) { + return@apply } + + polylines().ifPresent { it.forEach { it.validate() } } + routeId() + stopGroupings().ifPresent { it.forEach { it.validate() } } + stopIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -308,27 +325,41 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { - private var polylines: JsonField> = JsonMissing.of() + private var polylines: JsonField>? = null private var routeId: JsonField = JsonMissing.of() - private var stopGroupings: JsonField> = JsonMissing.of() - private var stopIds: JsonField> = JsonMissing.of() + private var stopGroupings: JsonField>? = null + private var stopIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { - polylines = entry.polylines + polylines = entry.polylines.map { it.toMutableList() } routeId = entry.routeId - stopGroupings = entry.stopGroupings - stopIds = entry.stopIds + stopGroupings = entry.stopGroupings.map { it.toMutableList() } + stopIds = entry.stopIds.map { it.toMutableList() } additionalProperties = entry.additionalProperties.toMutableMap() } fun polylines(polylines: List) = polylines(JsonField.of(polylines)) fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines + this.polylines = polylines.map { it.toMutableList() } + } + + fun addPolyline(polyline: Polyline) = apply { + polylines = + (polylines ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(polyline) + } } fun routeId(routeId: String) = routeId(JsonField.of(routeId)) @@ -339,12 +370,40 @@ private constructor( stopGroupings(JsonField.of(stopGroupings)) fun stopGroupings(stopGroupings: JsonField>) = apply { - this.stopGroupings = stopGroupings + this.stopGroupings = stopGroupings.map { it.toMutableList() } + } + + fun addStopGrouping(stopGrouping: StopGrouping) = apply { + stopGroupings = + (stopGroupings ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopGrouping) + } } fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopId) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -370,10 +429,10 @@ private constructor( fun build(): Entry = Entry( - polylines.map { it.toImmutable() }, + (polylines ?: JsonMissing.of()).map { it.toImmutable() }, routeId, - stopGroupings.map { it.toImmutable() }, - stopIds.map { it.toImmutable() }, + (stopGroupings ?: JsonMissing.of()).map { it.toImmutable() }, + (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -401,11 +460,11 @@ private constructor( fun points(): Optional = Optional.ofNullable(points.getNullable("points")) - @JsonProperty("length") @ExcludeMissing fun _length() = length + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length - @JsonProperty("levels") @ExcludeMissing fun _levels() = levels + @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels - @JsonProperty("points") @ExcludeMissing fun _points() = points + @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points @JsonAnyGetter @ExcludeMissing @@ -414,12 +473,14 @@ private constructor( private var validated: Boolean = false fun validate(): Polyline = apply { - if (!validated) { - length() - levels() - points() - validated = true + if (validated) { + return@apply } + + length() + levels() + points() + validated = true } fun toBuilder() = Builder().from(this) @@ -429,7 +490,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Polyline]. */ + class Builder internal constructor() { private var length: JsonField = JsonMissing.of() private var levels: JsonField = JsonMissing.of() @@ -535,13 +597,17 @@ private constructor( fun stopIds(): Optional> = Optional.ofNullable(stopIds.getNullable("stopIds")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("polylines") @ExcludeMissing fun _polylines() = polylines + @JsonProperty("polylines") + @ExcludeMissing + fun _polylines(): JsonField> = polylines - @JsonProperty("stopIds") @ExcludeMissing fun _stopIds() = stopIds + @JsonProperty("stopIds") + @ExcludeMissing + fun _stopIds(): JsonField> = stopIds @JsonAnyGetter @ExcludeMissing @@ -550,13 +616,15 @@ private constructor( private var validated: Boolean = false fun validate(): StopGrouping = apply { - if (!validated) { - id() - name().map { it.validate() } - polylines().map { it.forEach { it.validate() } } - stopIds() - validated = true + if (validated) { + return@apply } + + id() + name().ifPresent { it.validate() } + polylines().ifPresent { it.forEach { it.validate() } } + stopIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -566,20 +634,21 @@ private constructor( @JvmStatic fun builder() = Builder() } - class 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> = JsonMissing.of() - private var stopIds: 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 - stopIds = stopGrouping.stopIds + polylines = stopGrouping.polylines.map { it.toMutableList() } + stopIds = stopGrouping.stopIds.map { it.toMutableList() } additionalProperties = stopGrouping.additionalProperties.toMutableMap() } @@ -594,12 +663,40 @@ private constructor( fun polylines(polylines: List) = polylines(JsonField.of(polylines)) fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines + this.polylines = polylines.map { it.toMutableList() } + } + + fun addPolyline(polyline: Polyline) = apply { + polylines = + (polylines ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(polyline) + } } fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - fun stopIds(stopIds: JsonField>) = apply { this.stopIds = stopIds } + fun stopIds(stopIds: JsonField>) = apply { + this.stopIds = stopIds.map { it.toMutableList() } + } + + fun addStopId(stopId: String) = apply { + stopIds = + (stopIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopId) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -627,8 +724,8 @@ private constructor( StopGrouping( id, name, - polylines.map { it.toImmutable() }, - stopIds.map { it.toImmutable() }, + (polylines ?: JsonMissing.of()).map { it.toImmutable() }, + (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -657,11 +754,13 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("names") @ExcludeMissing fun _names() = names + @JsonProperty("names") + @ExcludeMissing + fun _names(): JsonField> = names - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -670,12 +769,14 @@ private constructor( private var validated: Boolean = false fun validate(): Name = apply { - if (!validated) { - name() - names() - type() - validated = true + if (validated) { + return@apply } + + name() + names() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -685,10 +786,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Name]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() - private var names: JsonField> = JsonMissing.of() + private var names: JsonField>? = null private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -696,7 +798,7 @@ private constructor( @JvmSynthetic internal fun from(name: Name) = apply { this.name = name.name - names = name.names + names = name.names.map { it.toMutableList() } type = name.type additionalProperties = name.additionalProperties.toMutableMap() } @@ -707,7 +809,22 @@ private constructor( fun names(names: List) = names(JsonField.of(names)) - fun names(names: JsonField>) = apply { this.names = names } + fun names(names: JsonField>) = apply { + this.names = names.map { it.toMutableList() } + } + + fun addName(name: String) = apply { + names = + (names ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(name) + } + } fun type(type: String) = type(JsonField.of(type)) @@ -738,7 +855,7 @@ private constructor( fun build(): Name = Name( name, - names.map { it.toImmutable() }, + (names ?: JsonMissing.of()).map { it.toImmutable() }, type, additionalProperties.toImmutable(), ) @@ -787,11 +904,15 @@ private constructor( fun points(): Optional = Optional.ofNullable(points.getNullable("points")) - @JsonProperty("length") @ExcludeMissing fun _length() = length + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length - @JsonProperty("levels") @ExcludeMissing fun _levels() = levels + @JsonProperty("levels") + @ExcludeMissing + fun _levels(): JsonField = levels - @JsonProperty("points") @ExcludeMissing fun _points() = points + @JsonProperty("points") + @ExcludeMissing + fun _points(): JsonField = points @JsonAnyGetter @ExcludeMissing @@ -800,12 +921,14 @@ private constructor( private var validated: Boolean = false fun validate(): Polyline = apply { - if (!validated) { - length() - levels() - points() - validated = true + if (validated) { + return@apply } + + length() + levels() + points() + validated = true } fun toBuilder() = Builder().from(this) @@ -815,7 +938,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Polyline]. */ + class Builder internal constructor() { private var length: JsonField = JsonMissing.of() private var levels: JsonField = JsonMissing.of() diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt index d51762c..fa137cd 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt @@ -5,11 +5,14 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Retrieve Trip Details */ class TripDetailRetrieveParams -constructor( +private constructor( private val tripId: String, private val includeSchedule: Boolean?, private val includeStatus: Boolean?, @@ -18,7 +21,7 @@ constructor( private val time: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun tripId(): String = tripId @@ -43,10 +46,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } @@ -71,8 +73,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [TripDetailRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var tripId: String? = null private var includeSchedule: Boolean? = null @@ -101,25 +104,78 @@ constructor( * Whether to include the full schedule element in the tripDetails section (defaults to * true). */ - fun includeSchedule(includeSchedule: Boolean) = apply { + fun includeSchedule(includeSchedule: Boolean?) = apply { this.includeSchedule = includeSchedule } + /** + * Whether to include the full schedule element in the tripDetails section (defaults to + * true). + */ + fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) + + /** + * Whether to include the full schedule element in the tripDetails section (defaults to + * true). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeSchedule(includeSchedule: Optional) = + includeSchedule(includeSchedule.orElse(null) as Boolean?) + + /** + * Whether to include the full status element in the tripDetails section (defaults to true). + */ + fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } + + /** + * Whether to include the full status element in the tripDetails section (defaults to true). + */ + fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) + /** * Whether to include the full status element in the tripDetails section (defaults to true). */ - fun includeStatus(includeStatus: Boolean) = apply { this.includeStatus = includeStatus } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeStatus(includeStatus: Optional) = + includeStatus(includeStatus.orElse(null) as Boolean?) + + /** + * Whether to include the full trip element in the references section (defaults to true). + */ + fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } + + /** + * Whether to include the full trip element in the references section (defaults to true). + */ + fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip as Boolean?) /** * Whether to include the full trip element in the references section (defaults to true). */ - fun includeTrip(includeTrip: Boolean) = apply { this.includeTrip = includeTrip } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeTrip(includeTrip: Optional) = + includeTrip(includeTrip.orElse(null) as Boolean?) /** Service date for the trip as Unix time in milliseconds (optional). */ - fun serviceDate(serviceDate: Long) = apply { this.serviceDate = serviceDate } + fun serviceDate(serviceDate: Long?) = apply { this.serviceDate = serviceDate } + + /** Service date for the trip as Unix time in milliseconds (optional). */ + fun serviceDate(serviceDate: Long) = serviceDate(serviceDate as Long?) + + /** Service date for the trip as Unix time in milliseconds (optional). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun serviceDate(serviceDate: Optional) = + serviceDate(serviceDate.orElse(null) as Long?) + + /** Time parameter to query the system at a specific time (optional). */ + fun time(time: Long?) = apply { this.time = time } + + /** Time parameter to query the system at a specific time (optional). */ + fun time(time: Long) = time(time as Long?) /** Time parameter to query the system at a specific time (optional). */ - fun time(time: Long) = apply { this.time = time } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun time(time: Optional) = time(time.orElse(null) as Long?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -221,7 +277,7 @@ constructor( fun build(): TripDetailRetrieveParams = TripDetailRetrieveParams( - checkNotNull(tripId) { "`tripId` is required but was not set" }, + checkRequired("tripId", tripId), includeSchedule, includeStatus, includeTrip, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt index 4ffb4c1..7277b0b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): TripDetailRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [TripDetailRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): TripDetailRetrieveResponse = TripDetailRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -250,6 +259,9 @@ private constructor( class Entry @JsonCreator private constructor( + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), @JsonProperty("frequency") @ExcludeMissing private val frequency: JsonField = JsonMissing.of(), @@ -265,13 +277,12 @@ private constructor( @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun tripId(): String = tripId.getRequired("tripId") + fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -286,19 +297,25 @@ private constructor( fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - @JsonProperty("schedule") @ExcludeMissing fun _schedule() = schedule + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -307,15 +324,17 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - frequency() - schedule().map { it.validate() } - serviceDate() - situationIds() - status().map { it.validate() } - tripId() - validated = true + if (validated) { + return@apply } + + tripId() + frequency() + schedule().ifPresent { it.validate() } + serviceDate() + situationIds() + status().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -325,28 +344,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { + private var tripId: JsonField? = null private var frequency: JsonField = JsonMissing.of() private var schedule: JsonField = JsonMissing.of() private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() + private var situationIds: JsonField>? = null private var status: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { + tripId = entry.tripId frequency = entry.frequency schedule = entry.schedule serviceDate = entry.serviceDate - situationIds = entry.situationIds + situationIds = entry.situationIds.map { it.toMutableList() } status = entry.status - tripId = entry.tripId additionalProperties = entry.additionalProperties.toMutableMap() } - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -364,17 +390,26 @@ private constructor( situationIds(JsonField.of(situationIds)) fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds + this.situationIds = situationIds.map { it.toMutableList() } + } + + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } } fun status(status: Status) = status(JsonField.of(status)) fun status(status: JsonField) = apply { this.status = status } - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -399,12 +434,12 @@ private constructor( fun build(): Entry = Entry( + checkRequired("tripId", tripId), frequency, schedule, serviceDate, - situationIds.map { it.toImmutable() }, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, status, - tripId, additionalProperties.toImmutable(), ) } @@ -413,9 +448,6 @@ private constructor( class Schedule @JsonCreator private constructor( - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("nextTripId") @ExcludeMissing private val nextTripId: JsonField = JsonMissing.of(), @@ -428,13 +460,13 @@ private constructor( @JsonProperty("timeZone") @ExcludeMissing private val timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - fun nextTripId(): String = nextTripId.getRequired("nextTripId") fun previousTripId(): String = previousTripId.getRequired("previousTripId") @@ -443,17 +475,28 @@ private constructor( fun timeZone(): String = timeZone.getRequired("timeZone") - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) - @JsonProperty("nextTripId") @ExcludeMissing fun _nextTripId() = nextTripId + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId @JsonProperty("previousTripId") @ExcludeMissing - fun _previousTripId() = previousTripId + fun _previousTripId(): JsonField = previousTripId + + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency @JsonAnyGetter @ExcludeMissing @@ -462,14 +505,16 @@ private constructor( private var validated: Boolean = false fun validate(): Schedule = apply { - if (!validated) { - frequency() - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - validated = true + if (validated) { + return@apply } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + validated = true } fun toBuilder() = Builder().from(this) @@ -479,31 +524,26 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Schedule]. */ + class Builder internal constructor() { + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField = JsonMissing.of() - private var previousTripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(schedule: Schedule) = apply { - frequency = schedule.frequency nextTripId = schedule.nextTripId previousTripId = schedule.previousTripId - stopTimes = schedule.stopTimes + stopTimes = schedule.stopTimes.map { it.toMutableList() } timeZone = schedule.timeZone + frequency = schedule.frequency additionalProperties = schedule.additionalProperties.toMutableMap() } - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) fun nextTripId(nextTripId: JsonField) = apply { @@ -520,13 +560,34 @@ private constructor( fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopTime) + } } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) + + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -551,11 +612,11 @@ private constructor( fun build(): Schedule = Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), frequency, - nextTripId, - previousTripId, - stopTimes.map { it.toImmutable() }, - timeZone, additionalProperties.toImmutable(), ) } @@ -604,23 +665,29 @@ private constructor( fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime @JsonProperty("departureTime") @ExcludeMissing - fun _departureTime() = departureTime + fun _departureTime(): JsonField = departureTime @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip + fun _distanceAlongTrip(): JsonField = distanceAlongTrip @JsonProperty("historicalOccupancy") @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy + fun _historicalOccupancy(): JsonField = historicalOccupancy - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId @JsonAnyGetter @ExcludeMissing @@ -629,15 +696,17 @@ private constructor( private var validated: Boolean = false fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true + if (validated) { + return@apply } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true } fun toBuilder() = Builder().from(this) @@ -647,7 +716,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTime]. */ + class Builder internal constructor() { private var arrivalTime: JsonField = JsonMissing.of() private var departureTime: JsonField = JsonMissing.of() @@ -764,17 +834,17 @@ private constructor( return true } - return /* spotless:off */ other is Schedule && frequency == other.frequency && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" } @NoAutoDetect @@ -790,36 +860,18 @@ private constructor( @JsonProperty("closestStop") @ExcludeMissing private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("distanceAlongTrip") @ExcludeMissing private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), @JsonProperty("lastLocationUpdateTime") @ExcludeMissing private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing private val occupancyCapacity: JsonField = JsonMissing.of(), @@ -829,36 +881,54 @@ private constructor( @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), @JsonProperty("phase") @ExcludeMissing private val phase: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), @JsonProperty("predicted") @ExcludeMissing private val predicted: JsonField = JsonMissing.of(), @JsonProperty("scheduleDeviation") @ExcludeMissing private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("serviceDate") @ExcludeMissing private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("vehicleId") @ExcludeMissing private val vehicleId: JsonField = JsonMissing.of(), @@ -875,22 +945,11 @@ private constructor( /** ID of the closest stop to the current location of the transit vehicle. */ fun closestStop(): String = closestStop.getRequired("closestStop") - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -898,14 +957,6 @@ private constructor( fun lastKnownDistanceAlongTrip(): Double = lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - /** * Timestamp of the last known real-time location update from the transit vehicle. */ @@ -915,17 +966,6 @@ private constructor( /** Timestamp of the last known real-time update from the transit vehicle. */ fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") @@ -935,17 +975,9 @@ private constructor( /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - /** Current journey phase of the trip. */ fun phase(): String = phase.getRequired("phase") - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(): Boolean = predicted.getRequired("predicted") @@ -954,25 +986,12 @@ private constructor( */ fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - /** Current status modifiers for the trip. */ fun status(): String = status.getRequired("status") @@ -980,141 +999,212 @@ private constructor( fun totalDistanceAlongTrip(): Double = totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - /** * Time offset from the closest stop to the current position of the transit vehicle * (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip + fun closestStopTimeOffset(): Optional = + Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation + fun lastKnownLocation(): Optional = + Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation + fun lastKnownOrientation(): Optional = + Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(): Optional = + Optional.ofNullable(nextStop.getNullable("nextStop")) /** - * Timestamp of the last known real-time location update from the transit vehicle. + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime + fun nextStopTimeOffset(): Optional = + Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(): Optional = + Optional.ofNullable(orientation.getNullable("orientation")) + + /** Current position of the transit vehicle. */ + fun position(): Optional = + Optional.ofNullable(position.getNullable("position")) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + fun scheduledDistanceAlongTrip(): Optional = + Optional.ofNullable( + scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") + ) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(): Optional> = + Optional.ofNullable(situationIds.getNullable("situationIds")) + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(): Optional = + Optional.ofNullable(vehicleId.getNullable("vehicleId")) + + /** Trip ID of the trip the vehicle is actively serving. */ + @JsonProperty("activeTripId") @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime + fun _activeTripId(): JsonField = activeTripId - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop + /** Index of the active trip into the sequence of trips for the active block. */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** ID of the closest stop to the current location of the transit vehicle. */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). + * Distance, in meters, the transit vehicle has progressed along the active trip. */ - @JsonProperty("nextStopTimeOffset") + @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** Timestamp of the last known real-time update from the transit vehicle. */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime /** Capacity of the transit vehicle in terms of occupancy. */ @JsonProperty("occupancyCapacity") @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity + fun _occupancyCapacity(): JsonField = occupancyCapacity /** Current count of occupants in the transit vehicle. */ @JsonProperty("occupancyCount") @ExcludeMissing - fun _occupancyCount() = occupancyCount + fun _occupancyCount(): JsonField = occupancyCount /** Current occupancy status of the transit vehicle. */ @JsonProperty("occupancyStatus") @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation + fun _occupancyStatus(): JsonField = occupancyStatus /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted /** * Deviation from the schedule in seconds (positive for late, negative for early). */ @JsonProperty("scheduleDeviation") @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip + fun _scheduleDeviation(): JsonField = scheduleDeviation /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Total length of the trip, in meters. */ @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Last known location of the transit vehicle. */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** Last known orientation value received in real-time from the transit vehicle. */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** Current position of the transit vehicle. */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** References to situation elements (if any) applicable to this trip. */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId @JsonAnyGetter @ExcludeMissing @@ -1123,36 +1213,38 @@ private constructor( private var validated: Boolean = false fun validate(): Status = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -1162,34 +1254,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() + /** A builder for [Status]. */ + 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 distanceAlongTrip: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() private var lastKnownLocation: JsonField = JsonMissing.of() private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() private var nextStop: JsonField = JsonMissing.of() private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1198,29 +1291,29 @@ private constructor( activeTripId = status.activeTripId blockTripSequence = status.blockTripSequence closestStop = status.closestStop - closestStopTimeOffset = status.closestStopTimeOffset distanceAlongTrip = status.distanceAlongTrip - frequency = status.frequency lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - lastKnownLocation = status.lastKnownLocation - lastKnownOrientation = status.lastKnownOrientation lastLocationUpdateTime = status.lastLocationUpdateTime lastUpdateTime = status.lastUpdateTime - nextStop = status.nextStop - nextStopTimeOffset = status.nextStopTimeOffset occupancyCapacity = status.occupancyCapacity occupancyCount = status.occupancyCount occupancyStatus = status.occupancyStatus - orientation = status.orientation phase = status.phase - position = status.position predicted = status.predicted scheduleDeviation = status.scheduleDeviation - scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip serviceDate = status.serviceDate - situationIds = status.situationIds this.status = status.status totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } vehicleId = status.vehicleId additionalProperties = status.additionalProperties.toMutableMap() } @@ -1251,21 +1344,6 @@ private constructor( this.closestStop = closestStop } - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - /** * Distance, in meters, the transit vehicle has progressed along the active * trip. @@ -1281,14 +1359,6 @@ private constructor( this.distanceAlongTrip = distanceAlongTrip } - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1305,28 +1375,6 @@ private constructor( this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - /** * Timestamp of the last known real-time location update from the transit * vehicle. @@ -1351,27 +1399,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -1399,26 +1426,12 @@ private constructor( this.occupancyStatus = occupancyStatus } - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - /** Current journey phase of the trip. */ fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ fun phase(phase: JsonField) = apply { this.phase = phase } - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - fun position(position: JsonField) = apply { this.position = position } - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) @@ -1442,22 +1455,6 @@ private constructor( this.scheduleDeviation = scheduleDeviation } - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. @@ -1472,15 +1469,6 @@ private constructor( this.serviceDate = serviceDate } - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - /** Current status modifiers for the trip. */ fun status(status: String) = status(JsonField.of(status)) @@ -1496,6 +1484,125 @@ private constructor( 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)) + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + 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)) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: JsonField) = apply { + 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. */ + 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)) + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + 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)) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + 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)) + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + 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)) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** Current position of the transit vehicle. */ + 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)) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + 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)) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** References to situation elements (if any) applicable to this trip. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) @@ -1528,32 +1635,32 @@ private constructor( fun build(): Status = Status( - activeTripId, - blockTripSequence, - closestStop, + 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, - distanceAlongTrip, frequency, - lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, nextStop, nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, orientation, - phase, position, - predicted, - scheduleDeviation, scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, vehicleId, additionalProperties.toImmutable(), ) @@ -1581,10 +1688,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1593,11 +1700,13 @@ private constructor( private var validated: Boolean = false fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1607,7 +1716,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1704,10 +1814,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1716,11 +1826,13 @@ private constructor( private var validated: Boolean = false fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1730,7 +1842,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Position]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1809,17 +1922,17 @@ private constructor( return true } - return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Status && 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "Status{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 { @@ -1827,17 +1940,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && tripId == other.tripId && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequency, schedule, serviceDate, situationIds, status, tripId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tripId, frequency, schedule, serviceDate, situationIds, status, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, tripId=$tripId, additionalProperties=$additionalProperties}" + "Entry{tripId=$tripId, frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt index 80e1fe0..5d0b04c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt @@ -5,11 +5,14 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Retrieve trip for a specific vehicle */ class TripForVehicleRetrieveParams -constructor( +private constructor( private val vehicleId: String, private val includeSchedule: Boolean?, private val includeStatus: Boolean?, @@ -17,7 +20,7 @@ constructor( private val time: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun vehicleId(): String = vehicleId @@ -46,10 +49,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } @@ -73,8 +75,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [TripForVehicleRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var vehicleId: String? = null private var includeSchedule: Boolean? = null @@ -101,24 +104,73 @@ constructor( * Determines whether full element is included in the section. * Defaults to false. */ - fun includeSchedule(includeSchedule: Boolean) = apply { + fun includeSchedule(includeSchedule: Boolean?) = apply { this.includeSchedule = includeSchedule } + /** + * Determines whether full element is included in the section. + * Defaults to false. + */ + fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) + + /** + * Determines whether full element is included in the section. + * Defaults to false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeSchedule(includeSchedule: Optional) = + includeSchedule(includeSchedule.orElse(null) as Boolean?) + + /** + * Determines whether the full element is included in the section. + * Defaults to true. + */ + fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } + + /** + * Determines whether the full element is included in the section. + * Defaults to true. + */ + fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) + /** * Determines whether the full element is included in the section. * Defaults to true. */ - fun includeStatus(includeStatus: Boolean) = apply { this.includeStatus = includeStatus } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeStatus(includeStatus: Optional) = + includeStatus(includeStatus.orElse(null) as Boolean?) /** * Determines whether full element is included in the section. * Defaults to false. */ - fun includeTrip(includeTrip: Boolean) = apply { this.includeTrip = includeTrip } + fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } + + /** + * Determines whether full element is included in the section. + * Defaults to false. + */ + fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip as Boolean?) + + /** + * Determines whether full element is included in the section. + * Defaults to false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeTrip(includeTrip: Optional) = + includeTrip(includeTrip.orElse(null) as Boolean?) + + /** Time parameter to query the system at a specific time (optional). */ + fun time(time: Long?) = apply { this.time = time } + + /** Time parameter to query the system at a specific time (optional). */ + fun time(time: Long) = time(time as Long?) /** Time parameter to query the system at a specific time (optional). */ - fun time(time: Long) = apply { this.time = time } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun time(time: Optional) = time(time.orElse(null) as Long?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -220,7 +272,7 @@ constructor( fun build(): TripForVehicleRetrieveParams = TripForVehicleRetrieveParams( - checkNotNull(vehicleId) { "`vehicleId` is required but was not set" }, + checkRequired("vehicleId", vehicleId), includeSchedule, includeStatus, includeTrip, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt index 58341fb..3b9377f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): TripForVehicleRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [TripForVehicleRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -145,11 +149,11 @@ private constructor( fun build(): TripForVehicleRetrieveResponse = TripForVehicleRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -172,9 +176,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -183,11 +189,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -197,10 +205,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -241,8 +250,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -251,6 +260,9 @@ private constructor( class Entry @JsonCreator private constructor( + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), @JsonProperty("frequency") @ExcludeMissing private val frequency: JsonField = JsonMissing.of(), @@ -266,13 +278,12 @@ private constructor( @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun tripId(): String = tripId.getRequired("tripId") + fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -287,19 +298,25 @@ private constructor( fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - @JsonProperty("schedule") @ExcludeMissing fun _schedule() = schedule + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -308,15 +325,17 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - frequency() - schedule().map { it.validate() } - serviceDate() - situationIds() - status().map { it.validate() } - tripId() - validated = true + if (validated) { + return@apply } + + tripId() + frequency() + schedule().ifPresent { it.validate() } + serviceDate() + situationIds() + status().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -326,28 +345,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { + private var tripId: JsonField? = null private var frequency: JsonField = JsonMissing.of() private var schedule: JsonField = JsonMissing.of() private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() + private var situationIds: JsonField>? = null private var status: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(entry: Entry) = apply { + tripId = entry.tripId frequency = entry.frequency schedule = entry.schedule serviceDate = entry.serviceDate - situationIds = entry.situationIds + situationIds = entry.situationIds.map { it.toMutableList() } status = entry.status - tripId = entry.tripId additionalProperties = entry.additionalProperties.toMutableMap() } - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -365,17 +391,26 @@ private constructor( situationIds(JsonField.of(situationIds)) fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds + this.situationIds = situationIds.map { it.toMutableList() } + } + + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } } fun status(status: Status) = status(JsonField.of(status)) fun status(status: JsonField) = apply { this.status = status } - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -400,12 +435,12 @@ private constructor( fun build(): Entry = Entry( + checkRequired("tripId", tripId), frequency, schedule, serviceDate, - situationIds.map { it.toImmutable() }, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, status, - tripId, additionalProperties.toImmutable(), ) } @@ -414,9 +449,6 @@ private constructor( class Schedule @JsonCreator private constructor( - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("nextTripId") @ExcludeMissing private val nextTripId: JsonField = JsonMissing.of(), @@ -429,13 +461,13 @@ private constructor( @JsonProperty("timeZone") @ExcludeMissing private val timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - fun nextTripId(): String = nextTripId.getRequired("nextTripId") fun previousTripId(): String = previousTripId.getRequired("previousTripId") @@ -444,17 +476,28 @@ private constructor( fun timeZone(): String = timeZone.getRequired("timeZone") - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) - @JsonProperty("nextTripId") @ExcludeMissing fun _nextTripId() = nextTripId + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId @JsonProperty("previousTripId") @ExcludeMissing - fun _previousTripId() = previousTripId + fun _previousTripId(): JsonField = previousTripId + + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency @JsonAnyGetter @ExcludeMissing @@ -463,14 +506,16 @@ private constructor( private var validated: Boolean = false fun validate(): Schedule = apply { - if (!validated) { - frequency() - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - validated = true + if (validated) { + return@apply } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + validated = true } fun toBuilder() = Builder().from(this) @@ -480,31 +525,26 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Schedule]. */ + class Builder internal constructor() { + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField = JsonMissing.of() - private var previousTripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(schedule: Schedule) = apply { - frequency = schedule.frequency nextTripId = schedule.nextTripId previousTripId = schedule.previousTripId - stopTimes = schedule.stopTimes + stopTimes = schedule.stopTimes.map { it.toMutableList() } timeZone = schedule.timeZone + frequency = schedule.frequency additionalProperties = schedule.additionalProperties.toMutableMap() } - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) fun nextTripId(nextTripId: JsonField) = apply { @@ -521,13 +561,34 @@ private constructor( fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopTime) + } } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) + + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -552,11 +613,11 @@ private constructor( fun build(): Schedule = Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), frequency, - nextTripId, - previousTripId, - stopTimes.map { it.toImmutable() }, - timeZone, additionalProperties.toImmutable(), ) } @@ -605,23 +666,29 @@ private constructor( fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime @JsonProperty("departureTime") @ExcludeMissing - fun _departureTime() = departureTime + fun _departureTime(): JsonField = departureTime @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip + fun _distanceAlongTrip(): JsonField = distanceAlongTrip @JsonProperty("historicalOccupancy") @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy + fun _historicalOccupancy(): JsonField = historicalOccupancy - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId @JsonAnyGetter @ExcludeMissing @@ -630,15 +697,17 @@ private constructor( private var validated: Boolean = false fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true + if (validated) { + return@apply } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true } fun toBuilder() = Builder().from(this) @@ -648,7 +717,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTime]. */ + class Builder internal constructor() { private var arrivalTime: JsonField = JsonMissing.of() private var departureTime: JsonField = JsonMissing.of() @@ -765,17 +835,17 @@ private constructor( return true } - return /* spotless:off */ other is Schedule && frequency == other.frequency && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" } @NoAutoDetect @@ -791,36 +861,18 @@ private constructor( @JsonProperty("closestStop") @ExcludeMissing private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("distanceAlongTrip") @ExcludeMissing private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), @JsonProperty("lastLocationUpdateTime") @ExcludeMissing private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing private val occupancyCapacity: JsonField = JsonMissing.of(), @@ -830,36 +882,54 @@ private constructor( @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), @JsonProperty("phase") @ExcludeMissing private val phase: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), @JsonProperty("predicted") @ExcludeMissing private val predicted: JsonField = JsonMissing.of(), @JsonProperty("scheduleDeviation") @ExcludeMissing private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("serviceDate") @ExcludeMissing private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("vehicleId") @ExcludeMissing private val vehicleId: JsonField = JsonMissing.of(), @@ -876,22 +946,11 @@ private constructor( /** ID of the closest stop to the current location of the transit vehicle. */ fun closestStop(): String = closestStop.getRequired("closestStop") - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -899,14 +958,6 @@ private constructor( fun lastKnownDistanceAlongTrip(): Double = lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - /** * Timestamp of the last known real-time location update from the transit vehicle. */ @@ -916,17 +967,6 @@ private constructor( /** Timestamp of the last known real-time update from the transit vehicle. */ fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") @@ -936,17 +976,9 @@ private constructor( /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - /** Current journey phase of the trip. */ fun phase(): String = phase.getRequired("phase") - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(): Boolean = predicted.getRequired("predicted") @@ -955,25 +987,12 @@ private constructor( */ fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - /** Current status modifiers for the trip. */ fun status(): String = status.getRequired("status") @@ -981,141 +1000,212 @@ private constructor( fun totalDistanceAlongTrip(): Double = totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence() = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - /** * Time offset from the closest stop to the current position of the transit vehicle * (in seconds). */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip + fun closestStopTimeOffset(): Optional = + Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation + fun lastKnownLocation(): Optional = + Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation + fun lastKnownOrientation(): Optional = + Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(): Optional = + Optional.ofNullable(nextStop.getNullable("nextStop")) /** - * Timestamp of the last known real-time location update from the transit vehicle. + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime + fun nextStopTimeOffset(): Optional = + Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(): Optional = + Optional.ofNullable(orientation.getNullable("orientation")) + + /** Current position of the transit vehicle. */ + fun position(): Optional = + Optional.ofNullable(position.getNullable("position")) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + fun scheduledDistanceAlongTrip(): Optional = + Optional.ofNullable( + scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") + ) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(): Optional> = + Optional.ofNullable(situationIds.getNullable("situationIds")) + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(): Optional = + Optional.ofNullable(vehicleId.getNullable("vehicleId")) + + /** Trip ID of the trip the vehicle is actively serving. */ + @JsonProperty("activeTripId") @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime + fun _activeTripId(): JsonField = activeTripId - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop + /** Index of the active trip into the sequence of trips for the active block. */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** ID of the closest stop to the current location of the transit vehicle. */ + @JsonProperty("closestStop") + @ExcludeMissing + fun _closestStop(): JsonField = closestStop /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). + * Distance, in meters, the transit vehicle has progressed along the active trip. */ - @JsonProperty("nextStopTimeOffset") + @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset + fun _distanceAlongTrip(): JsonField = distanceAlongTrip + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + */ + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + */ + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime + + /** Timestamp of the last known real-time update from the transit vehicle. */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime /** Capacity of the transit vehicle in terms of occupancy. */ @JsonProperty("occupancyCapacity") @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity + fun _occupancyCapacity(): JsonField = occupancyCapacity /** Current count of occupants in the transit vehicle. */ @JsonProperty("occupancyCount") @ExcludeMissing - fun _occupancyCount() = occupancyCount + fun _occupancyCount(): JsonField = occupancyCount /** Current occupancy status of the transit vehicle. */ @JsonProperty("occupancyStatus") @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation + fun _occupancyStatus(): JsonField = occupancyStatus /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted /** * Deviation from the schedule in seconds (positive for late, negative for early). */ @JsonProperty("scheduleDeviation") @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip + fun _scheduleDeviation(): JsonField = scheduleDeviation /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Total length of the trip, in meters. */ @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Last known location of the transit vehicle. */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** Last known orientation value received in real-time from the transit vehicle. */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** Current position of the transit vehicle. */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** References to situation elements (if any) applicable to this trip. */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId @JsonAnyGetter @ExcludeMissing @@ -1124,36 +1214,38 @@ private constructor( private var validated: Boolean = false fun validate(): Status = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -1163,34 +1255,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() + /** A builder for [Status]. */ + 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 distanceAlongTrip: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() private var lastKnownLocation: JsonField = JsonMissing.of() private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() private var nextStop: JsonField = JsonMissing.of() private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1199,29 +1292,29 @@ private constructor( activeTripId = status.activeTripId blockTripSequence = status.blockTripSequence closestStop = status.closestStop - closestStopTimeOffset = status.closestStopTimeOffset distanceAlongTrip = status.distanceAlongTrip - frequency = status.frequency lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - lastKnownLocation = status.lastKnownLocation - lastKnownOrientation = status.lastKnownOrientation lastLocationUpdateTime = status.lastLocationUpdateTime lastUpdateTime = status.lastUpdateTime - nextStop = status.nextStop - nextStopTimeOffset = status.nextStopTimeOffset occupancyCapacity = status.occupancyCapacity occupancyCount = status.occupancyCount occupancyStatus = status.occupancyStatus - orientation = status.orientation phase = status.phase - position = status.position predicted = status.predicted scheduleDeviation = status.scheduleDeviation - scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip serviceDate = status.serviceDate - situationIds = status.situationIds this.status = status.status totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } vehicleId = status.vehicleId additionalProperties = status.additionalProperties.toMutableMap() } @@ -1252,21 +1345,6 @@ private constructor( this.closestStop = closestStop } - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - /** * Distance, in meters, the transit vehicle has progressed along the active * trip. @@ -1282,14 +1360,6 @@ private constructor( this.distanceAlongTrip = distanceAlongTrip } - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1306,28 +1376,6 @@ private constructor( this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - /** * Timestamp of the last known real-time location update from the transit * vehicle. @@ -1352,27 +1400,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -1400,26 +1427,12 @@ private constructor( this.occupancyStatus = occupancyStatus } - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - /** Current journey phase of the trip. */ fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ fun phase(phase: JsonField) = apply { this.phase = phase } - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - fun position(position: JsonField) = apply { this.position = position } - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) @@ -1443,22 +1456,6 @@ private constructor( this.scheduleDeviation = scheduleDeviation } - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. @@ -1473,15 +1470,6 @@ private constructor( this.serviceDate = serviceDate } - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds - } - /** Current status modifiers for the trip. */ fun status(status: String) = status(JsonField.of(status)) @@ -1497,6 +1485,125 @@ private constructor( 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)) + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + 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)) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: JsonField) = apply { + 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. */ + 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)) + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + 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)) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + 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)) + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + 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)) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** Current position of the transit vehicle. */ + 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)) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + 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)) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** References to situation elements (if any) applicable to this trip. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) @@ -1529,32 +1636,32 @@ private constructor( fun build(): Status = Status( - activeTripId, - blockTripSequence, - closestStop, + 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, - distanceAlongTrip, frequency, - lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, nextStop, nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, orientation, - phase, position, - predicted, - scheduleDeviation, scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, vehicleId, additionalProperties.toImmutable(), ) @@ -1582,10 +1689,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1594,11 +1701,13 @@ private constructor( private var validated: Boolean = false fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1608,7 +1717,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1705,10 +1815,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1717,11 +1827,13 @@ private constructor( private var validated: Boolean = false fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1731,7 +1843,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Position]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1810,17 +1923,17 @@ private constructor( return true } - return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Status && 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "Status{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 { @@ -1828,17 +1941,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && tripId == other.tripId && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequency, schedule, serviceDate, situationIds, status, tripId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tripId, frequency, schedule, serviceDate, situationIds, status, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, tripId=$tripId, additionalProperties=$additionalProperties}" + "Entry{tripId=$tripId, frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt index a2511a5..d1a60d5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt @@ -4,15 +4,18 @@ package org.onebusaway.models import java.util.Objects import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get details of a specific trip */ class TripRetrieveParams -constructor( +private constructor( private val tripId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun tripId(): String = tripId @@ -20,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -38,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [TripRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var tripId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -154,7 +158,7 @@ constructor( fun build(): TripRetrieveParams = TripRetrieveParams( - checkNotNull(tripId) { "`tripId` is required but was not set" }, + checkRequired("tripId", tripId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt index 0ab0673..c4986cd 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): TripRetrieveResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [TripRetrieveResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): TripRetrieveResponse = TripRetrieveResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -171,9 +175,11 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("entry") @ExcludeMissing fun _entry() = entry + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -182,11 +188,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - entry().validate() - references().validate() - validated = true + if (validated) { + return@apply } + + entry().validate() + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -196,10 +204,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var entry: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var entry: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,8 +249,8 @@ private constructor( fun build(): Data = Data( - entry, - references, + checkRequired("entry", entry), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -250,27 +259,27 @@ private constructor( class Entry @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + private val routeId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + private val serviceId: JsonField = JsonMissing.of(), @JsonProperty("blockId") @ExcludeMissing private val blockId: JsonField = JsonMissing.of(), @JsonProperty("directionId") @ExcludeMissing private val directionId: JsonField = JsonMissing.of(), - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), @JsonProperty("peakOffpeak") @ExcludeMissing private val peakOffpeak: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), @JsonProperty("routeShortName") @ExcludeMissing private val routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), @JsonProperty("shapeId") @ExcludeMissing private val shapeId: JsonField = JsonMissing.of(), @@ -287,23 +296,23 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun id(): String = id.getRequired("id") + + fun routeId(): String = routeId.getRequired("routeId") + + fun serviceId(): String = serviceId.getRequired("serviceId") + fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) fun directionId(): Optional = Optional.ofNullable(directionId.getNullable("directionId")) - fun id(): String = id.getRequired("id") - fun peakOffpeak(): Optional = Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - fun routeId(): String = routeId.getRequired("routeId") - fun routeShortName(): Optional = Optional.ofNullable(routeShortName.getNullable("routeShortName")) - fun serviceId(): String = serviceId.getRequired("serviceId") - fun shapeId(): Optional = Optional.ofNullable(shapeId.getNullable("shapeId")) fun timeZone(): Optional = Optional.ofNullable(timeZone.getNullable("timeZone")) @@ -314,27 +323,39 @@ private constructor( fun tripShortName(): Optional = Optional.ofNullable(tripShortName.getNullable("tripShortName")) - @JsonProperty("blockId") @ExcludeMissing fun _blockId() = blockId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("directionId") @ExcludeMissing fun _directionId() = directionId + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId - @JsonProperty("peakOffpeak") @ExcludeMissing fun _peakOffpeak() = peakOffpeak + @JsonProperty("blockId") @ExcludeMissing fun _blockId(): JsonField = blockId - @JsonProperty("routeId") @ExcludeMissing fun _routeId() = routeId + @JsonProperty("directionId") + @ExcludeMissing + fun _directionId(): JsonField = directionId - @JsonProperty("routeShortName") @ExcludeMissing fun _routeShortName() = routeShortName + @JsonProperty("peakOffpeak") + @ExcludeMissing + fun _peakOffpeak(): JsonField = peakOffpeak - @JsonProperty("serviceId") @ExcludeMissing fun _serviceId() = serviceId + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId() = shapeId + @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone + @JsonProperty("timeZone") @ExcludeMissing fun _timeZone(): JsonField = timeZone - @JsonProperty("tripHeadsign") @ExcludeMissing fun _tripHeadsign() = tripHeadsign + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign - @JsonProperty("tripShortName") @ExcludeMissing fun _tripShortName() = tripShortName + @JsonProperty("tripShortName") + @ExcludeMissing + fun _tripShortName(): JsonField = tripShortName @JsonAnyGetter @ExcludeMissing @@ -343,20 +364,22 @@ private constructor( private var validated: Boolean = false fun validate(): Entry = apply { - if (!validated) { - blockId() - directionId() - id() - peakOffpeak() - routeId() - routeShortName() - serviceId() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true + if (validated) { + return@apply } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + validated = true } fun toBuilder() = Builder().from(this) @@ -366,15 +389,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entry]. */ + class Builder internal constructor() { + 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 id: JsonField = JsonMissing.of() private var peakOffpeak: JsonField = JsonMissing.of() - private var routeId: JsonField = JsonMissing.of() private var routeShortName: JsonField = JsonMissing.of() - private var serviceId: JsonField = JsonMissing.of() private var shapeId: JsonField = JsonMissing.of() private var timeZone: JsonField = JsonMissing.of() private var tripHeadsign: JsonField = JsonMissing.of() @@ -383,13 +407,13 @@ private constructor( @JvmSynthetic internal fun from(entry: Entry) = apply { + id = entry.id + routeId = entry.routeId + serviceId = entry.serviceId blockId = entry.blockId directionId = entry.directionId - id = entry.id peakOffpeak = entry.peakOffpeak - routeId = entry.routeId routeShortName = entry.routeShortName - serviceId = entry.serviceId shapeId = entry.shapeId timeZone = entry.timeZone tripHeadsign = entry.tripHeadsign @@ -397,6 +421,18 @@ private constructor( additionalProperties = entry.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) fun blockId(blockId: JsonField) = apply { this.blockId = blockId } @@ -407,20 +443,12 @@ private constructor( this.directionId = directionId } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) fun peakOffpeak(peakOffpeak: JsonField) = apply { this.peakOffpeak = peakOffpeak } - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - fun routeShortName(routeShortName: String) = routeShortName(JsonField.of(routeShortName)) @@ -428,10 +456,6 @@ private constructor( this.routeShortName = routeShortName } - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } @@ -477,13 +501,13 @@ private constructor( fun build(): Entry = Entry( + checkRequired("id", id), + checkRequired("routeId", routeId), + checkRequired("serviceId", serviceId), blockId, directionId, - id, peakOffpeak, - routeId, routeShortName, - serviceId, shapeId, timeZone, tripHeadsign, @@ -497,17 +521,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && blockId == other.blockId && directionId == other.directionId && id == other.id && peakOffpeak == other.peakOffpeak && routeId == other.routeId && routeShortName == other.routeShortName && serviceId == other.serviceId && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(blockId, directionId, id, peakOffpeak, routeId, routeShortName, serviceId, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{blockId=$blockId, directionId=$directionId, id=$id, peakOffpeak=$peakOffpeak, routeId=$routeId, routeShortName=$routeShortName, serviceId=$serviceId, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" + "Entry{id=$id, routeId=$routeId, serviceId=$serviceId, blockId=$blockId, directionId=$directionId, peakOffpeak=$peakOffpeak, routeShortName=$routeShortName, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt index 90ed900..18afcad 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt @@ -5,11 +5,14 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Retrieve trips for a given location */ class TripsForLocationListParams -constructor( +private constructor( private val lat: Double, private val latSpan: Double, private val lon: Double, @@ -19,7 +22,7 @@ constructor( private val time: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The latitude coordinate of the search center */ fun lat(): Double = lat @@ -46,10 +49,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.lat.let { queryParams.put("lat", listOf(it.toString())) } this.latSpan.let { queryParams.put("latSpan", listOf(it.toString())) } @@ -69,8 +71,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [TripsForLocationListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var lat: Double? = null private var latSpan: Double? = null @@ -110,15 +113,42 @@ constructor( /** * Whether to include full schedule elements in the tripDetails section. Defaults to false. */ - fun includeSchedule(includeSchedule: Boolean) = apply { + fun includeSchedule(includeSchedule: Boolean?) = apply { this.includeSchedule = includeSchedule } + /** + * Whether to include full schedule elements in the tripDetails section. Defaults to false. + */ + fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) + + /** + * Whether to include full schedule elements in the tripDetails section. Defaults to false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeSchedule(includeSchedule: Optional) = + includeSchedule(includeSchedule.orElse(null) as Boolean?) + /** Whether to include full trip elements in the references section. Defaults to false. */ - fun includeTrip(includeTrip: Boolean) = apply { this.includeTrip = includeTrip } + fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } + + /** Whether to include full trip elements in the references section. Defaults to false. */ + fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip as Boolean?) + + /** Whether to include full trip elements in the references section. Defaults to false. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeTrip(includeTrip: Optional) = + includeTrip(includeTrip.orElse(null) as Boolean?) + + /** Specific time for the query. Defaults to the current time. */ + fun time(time: Long?) = apply { this.time = time } + + /** Specific time for the query. Defaults to the current time. */ + fun time(time: Long) = time(time as Long?) /** Specific time for the query. Defaults to the current time. */ - fun time(time: Long) = apply { this.time = time } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun time(time: Optional) = time(time.orElse(null) as Long?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -220,10 +250,10 @@ constructor( fun build(): TripsForLocationListParams = TripsForLocationListParams( - checkNotNull(lat) { "`lat` is required but was not set" }, - checkNotNull(latSpan) { "`latSpan` is required but was not set" }, - checkNotNull(lon) { "`lon` is required but was not set" }, - checkNotNull(lonSpan) { "`lonSpan` is required but was not set" }, + checkRequired("lat", lat), + checkRequired("latSpan", latSpan), + checkRequired("lon", lon), + checkRequired("lonSpan", lonSpan), includeSchedule, includeTrip, time, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt index f0ee349..52cc892 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): TripsForLocationListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [TripsForLocationListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): TripsForLocationListResponse = TripsForLocationListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -163,12 +167,12 @@ private constructor( @JsonProperty("list") @ExcludeMissing private val list: JsonField> = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), @JsonProperty("references") @ExcludeMissing private val references: JsonField = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + private val outOfRange: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -178,21 +182,29 @@ private constructor( fun list(): kotlin.collections.List = list.getRequired("list") + fun references(): References = references.getRequired("references") + /** Indicates if the search location is out of range */ fun outOfRange(): Optional = Optional.ofNullable(outOfRange.getNullable("outOfRange")) - fun references(): References = references.getRequired("references") - /** Indicates if the limit of trips has been exceeded */ - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded + + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references /** Indicates if the search location is out of range */ - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange() = outOfRange - - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange @JsonAnyGetter @ExcludeMissing @@ -201,13 +213,15 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + validated = true } fun toBuilder() = Builder().from(this) @@ -217,20 +231,21 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: 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 references: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list - outOfRange = data.outOfRange + list = data.list.map { it.toMutableList() } references = data.references + outOfRange = data.outOfRange additionalProperties = data.additionalProperties.toMutableMap() } @@ -244,13 +259,22 @@ private constructor( fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } - - /** Indicates if the search location is out of range */ - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } - /** Indicates if the search location is out of range */ - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun references(references: References) = references(JsonField.of(references)) @@ -258,6 +282,12 @@ private constructor( this.references = references } + /** Indicates if the search location is out of range */ + fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) + + /** Indicates if the search location is out of range */ + fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -279,10 +309,10 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), outOfRange, - references, additionalProperties.toImmutable(), ) } @@ -291,28 +321,34 @@ private constructor( class List @JsonCreator private constructor( - @JsonProperty("frequency") + @JsonProperty("schedule") @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") + private val schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), + private val status: JsonField = JsonMissing.of(), @JsonProperty("situationIds") @ExcludeMissing private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("tripId") @ExcludeMissing private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("schedule") + @JsonProperty("frequency") @ExcludeMissing - private val schedule: JsonField = JsonMissing.of(), - @JsonProperty("status") + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") @ExcludeMissing - private val status: JsonField = JsonMissing.of(), + private val serviceDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun schedule(): Schedule = schedule.getRequired("schedule") + + fun status(): Status = status.getRequired("status") + + fun tripId(): String = tripId.getRequired("tripId") + fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -322,23 +358,25 @@ private constructor( fun situationIds(): Optional> = Optional.ofNullable(situationIds.getNullable("situationIds")) - fun tripId(): String = tripId.getRequired("tripId") - - fun schedule(): Schedule = schedule.getRequired("schedule") - - fun status(): Status = status.getRequired("status") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency - @JsonProperty("schedule") @ExcludeMissing fun _schedule() = schedule + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds @JsonAnyGetter @ExcludeMissing @@ -347,15 +385,17 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - frequency() - serviceDate() - situationIds() - tripId() - schedule().validate() - status().validate() - validated = true + if (validated) { + return@apply } + + schedule().validate() + status().validate() + tripId() + frequency() + serviceDate() + situationIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -365,29 +405,43 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { + private var schedule: JsonField? = null + private var status: JsonField? = null + private var situationIds: JsonField>? = null + private var tripId: JsonField? = null private var frequency: JsonField = JsonMissing.of() private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { - frequency = list.frequency - serviceDate = list.serviceDate - situationIds = list.situationIds - tripId = list.tripId schedule = list.schedule status = list.status + tripId = list.tripId + frequency = list.frequency + serviceDate = list.serviceDate + situationIds = list.situationIds.map { it.toMutableList() } additionalProperties = list.additionalProperties.toMutableMap() } - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun status(status: Status) = status(JsonField.of(status)) + + fun status(status: JsonField) = apply { this.status = status } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -401,20 +455,21 @@ private constructor( situationIds(JsonField.of(situationIds)) fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds + this.situationIds = situationIds.map { it.toMutableList() } } - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -440,12 +495,12 @@ private constructor( fun build(): List = List( + checkRequired("schedule", schedule), + checkRequired("status", status), + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("tripId", tripId), frequency, serviceDate, - situationIds.map { it.toImmutable() }, - tripId, - schedule, - status, additionalProperties.toImmutable(), ) } @@ -454,9 +509,6 @@ private constructor( class Schedule @JsonCreator private constructor( - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("nextTripId") @ExcludeMissing private val nextTripId: JsonField = JsonMissing.of(), @@ -470,13 +522,13 @@ private constructor( @JsonProperty("timeZone") @ExcludeMissing private val timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - fun nextTripId(): String = nextTripId.getRequired("nextTripId") fun previousTripId(): String = previousTripId.getRequired("previousTripId") @@ -486,17 +538,28 @@ private constructor( fun timeZone(): String = timeZone.getRequired("timeZone") - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) - @JsonProperty("nextTripId") @ExcludeMissing fun _nextTripId() = nextTripId + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId @JsonProperty("previousTripId") @ExcludeMissing - fun _previousTripId() = previousTripId + fun _previousTripId(): JsonField = previousTripId + + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency @JsonAnyGetter @ExcludeMissing @@ -505,14 +568,16 @@ private constructor( private var validated: Boolean = false fun validate(): Schedule = apply { - if (!validated) { - frequency() - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - validated = true + if (validated) { + return@apply } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + validated = true } fun toBuilder() = Builder().from(this) @@ -522,32 +587,26 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Schedule]. */ + class Builder internal constructor() { private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField = JsonMissing.of() - private var previousTripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = - JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(schedule: Schedule) = apply { - frequency = schedule.frequency nextTripId = schedule.nextTripId previousTripId = schedule.previousTripId - stopTimes = schedule.stopTimes + stopTimes = schedule.stopTimes.map { it.toMutableList() } timeZone = schedule.timeZone + frequency = schedule.frequency additionalProperties = schedule.additionalProperties.toMutableMap() } - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) fun nextTripId(nextTripId: JsonField) = apply { @@ -565,13 +624,34 @@ private constructor( stopTimes(JsonField.of(stopTimes)) fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopTime) + } } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) + + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -596,11 +676,11 @@ private constructor( fun build(): Schedule = Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), frequency, - nextTripId, - previousTripId, - stopTimes.map { it.toImmutable() }, - timeZone, additionalProperties.toImmutable(), ) } @@ -649,23 +729,29 @@ private constructor( fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime @JsonProperty("departureTime") @ExcludeMissing - fun _departureTime() = departureTime + fun _departureTime(): JsonField = departureTime @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip + fun _distanceAlongTrip(): JsonField = distanceAlongTrip @JsonProperty("historicalOccupancy") @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy + fun _historicalOccupancy(): JsonField = historicalOccupancy - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId @JsonAnyGetter @ExcludeMissing @@ -674,15 +760,17 @@ private constructor( private var validated: Boolean = false fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true + if (validated) { + return@apply } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true } fun toBuilder() = Builder().from(this) @@ -692,7 +780,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTime]. */ + class Builder internal constructor() { private var arrivalTime: JsonField = JsonMissing.of() private var departureTime: JsonField = JsonMissing.of() @@ -809,17 +898,17 @@ private constructor( return true } - return /* spotless:off */ other is Schedule && frequency == other.frequency && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" } @NoAutoDetect @@ -835,36 +924,18 @@ private constructor( @JsonProperty("closestStop") @ExcludeMissing private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("distanceAlongTrip") @ExcludeMissing private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), @JsonProperty("lastLocationUpdateTime") @ExcludeMissing private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing private val occupancyCapacity: JsonField = JsonMissing.of(), @@ -874,24 +945,15 @@ private constructor( @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), @JsonProperty("phase") @ExcludeMissing private val phase: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), @JsonProperty("predicted") @ExcludeMissing private val predicted: JsonField = JsonMissing.of(), @JsonProperty("scheduleDeviation") @ExcludeMissing private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("serviceDate") @ExcludeMissing private val serviceDate: JsonField = JsonMissing.of(), @@ -905,6 +967,33 @@ private constructor( @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("vehicleId") @ExcludeMissing private val vehicleId: JsonField = JsonMissing.of(), @@ -921,22 +1010,11 @@ private constructor( /** ID of the closest stop to the current location of the transit vehicle. */ fun closestStop(): String = closestStop.getRequired("closestStop") - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -944,14 +1022,6 @@ private constructor( fun lastKnownDistanceAlongTrip(): Double = lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - /** * Timestamp of the last known real-time location update from the transit vehicle. */ @@ -961,17 +1031,6 @@ private constructor( /** Timestamp of the last known real-time update from the transit vehicle. */ fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") @@ -981,17 +1040,9 @@ private constructor( /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - /** Current journey phase of the trip. */ fun phase(): String = phase.getRequired("phase") - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(): Boolean = predicted.getRequired("predicted") @@ -1000,15 +1051,6 @@ private constructor( */ fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. @@ -1026,38 +1068,78 @@ private constructor( fun totalDistanceAlongTrip(): Double = totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + fun closestStopTimeOffset(): Optional = + Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(): Optional = + Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) + + /** Last known orientation value received in real-time from the transit vehicle. */ + fun lastKnownOrientation(): Optional = + Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(): Optional = + Optional.ofNullable(nextStop.getNullable("nextStop")) + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + fun nextStopTimeOffset(): Optional = + Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(): Optional = + Optional.ofNullable(orientation.getNullable("orientation")) + + /** Current position of the transit vehicle. */ + fun position(): Optional = + Optional.ofNullable(position.getNullable("position")) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + fun scheduledDistanceAlongTrip(): Optional = + Optional.ofNullable( + scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") + ) + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(): Optional = Optional.ofNullable(vehicleId.getNullable("vehicleId")) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId /** Index of the active trip into the sequence of trips for the active block. */ @JsonProperty("blockTripSequence") @ExcludeMissing - fun _blockTripSequence() = blockTripSequence + fun _blockTripSequence(): JsonField = blockTripSequence /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") + @JsonProperty("closestStop") @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset + fun _closestStop(): JsonField = closestStop /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun _distanceAlongTrip(): JsonField = distanceAlongTrip /** * Last known distance along the trip received in real-time from the transit @@ -1065,102 +1147,129 @@ private constructor( */ @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip /** * Timestamp of the last known real-time location update from the transit vehicle. */ @JsonProperty("lastLocationUpdateTime") @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime /** Timestamp of the last known real-time update from the transit vehicle. */ @JsonProperty("lastUpdateTime") @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset + fun _lastUpdateTime(): JsonField = lastUpdateTime /** Capacity of the transit vehicle in terms of occupancy. */ @JsonProperty("occupancyCapacity") @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity + fun _occupancyCapacity(): JsonField = occupancyCapacity /** Current count of occupants in the transit vehicle. */ @JsonProperty("occupancyCount") @ExcludeMissing - fun _occupancyCount() = occupancyCount + fun _occupancyCount(): JsonField = occupancyCount /** Current occupancy status of the transit vehicle. */ @JsonProperty("occupancyStatus") @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation + fun _occupancyStatus(): JsonField = occupancyStatus /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted /** * Deviation from the schedule in seconds (positive for late, negative for early). */ @JsonProperty("scheduleDeviation") @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip + fun _scheduleDeviation(): JsonField = scheduleDeviation /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Total length of the trip, in meters. */ @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Last known location of the transit vehicle. */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** Last known orientation value received in real-time from the transit vehicle. */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** Current position of the transit vehicle. */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** References to situation elements (if any) applicable to this trip. */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId @JsonAnyGetter @ExcludeMissing @@ -1169,36 +1278,38 @@ private constructor( private var validated: Boolean = false fun validate(): Status = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -1208,35 +1319,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() + /** A builder for [Status]. */ + 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 situationIds: JsonField>? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() private var lastKnownLocation: JsonField = JsonMissing.of() private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() private var nextStop: JsonField = JsonMissing.of() private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1245,29 +1356,29 @@ private constructor( activeTripId = status.activeTripId blockTripSequence = status.blockTripSequence closestStop = status.closestStop - closestStopTimeOffset = status.closestStopTimeOffset distanceAlongTrip = status.distanceAlongTrip - frequency = status.frequency lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - lastKnownLocation = status.lastKnownLocation - lastKnownOrientation = status.lastKnownOrientation lastLocationUpdateTime = status.lastLocationUpdateTime lastUpdateTime = status.lastUpdateTime - nextStop = status.nextStop - nextStopTimeOffset = status.nextStopTimeOffset occupancyCapacity = status.occupancyCapacity occupancyCount = status.occupancyCount occupancyStatus = status.occupancyStatus - orientation = status.orientation phase = status.phase - position = status.position predicted = status.predicted scheduleDeviation = status.scheduleDeviation - scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip serviceDate = status.serviceDate - situationIds = status.situationIds this.status = status.status totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } vehicleId = status.vehicleId additionalProperties = status.additionalProperties.toMutableMap() } @@ -1298,21 +1409,6 @@ private constructor( this.closestStop = closestStop } - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - /** * Distance, in meters, the transit vehicle has progressed along the active * trip. @@ -1328,14 +1424,6 @@ private constructor( this.distanceAlongTrip = distanceAlongTrip } - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1352,28 +1440,6 @@ private constructor( this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - /** * Timestamp of the last known real-time location update from the transit * vehicle. @@ -1398,27 +1464,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -1446,26 +1491,12 @@ private constructor( this.occupancyStatus = occupancyStatus } - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - /** Current journey phase of the trip. */ fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ fun phase(phase: JsonField) = apply { this.phase = phase } - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - fun position(position: JsonField) = apply { this.position = position } - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) @@ -1489,22 +1520,6 @@ private constructor( this.scheduleDeviation = scheduleDeviation } - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. @@ -1526,7 +1541,7 @@ private constructor( /** References to situation elements (if any) applicable to this trip. */ fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds + this.situationIds = situationIds.map { it.toMutableList() } } /** Current status modifiers for the trip. */ @@ -1544,6 +1559,116 @@ private constructor( 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)) + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + 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)) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: JsonField) = apply { + 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. */ + 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)) + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + 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)) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + 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)) + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + 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)) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** Current position of the transit vehicle. */ + 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)) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) @@ -1576,32 +1701,32 @@ private constructor( fun build(): Status = Status( - activeTripId, - blockTripSequence, - closestStop, + 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), + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), closestStopTimeOffset, - distanceAlongTrip, frequency, - lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, nextStop, nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, orientation, - phase, position, - predicted, - scheduleDeviation, scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, vehicleId, additionalProperties.toImmutable(), ) @@ -1629,10 +1754,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1641,11 +1766,13 @@ private constructor( private var validated: Boolean = false fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1655,7 +1782,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1752,10 +1880,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1764,11 +1892,13 @@ private constructor( private var validated: Boolean = false fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1778,7 +1908,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Position]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1857,17 +1988,17 @@ private constructor( return true } - return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Status && 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "Status{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 { @@ -1875,17 +2006,17 @@ private constructor( return true } - return /* spotless:off */ other is List && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && tripId == other.tripId && schedule == other.schedule && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && schedule == other.schedule && status == other.status && tripId == other.tripId && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequency, serviceDate, situationIds, tripId, schedule, status, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(schedule, status, tripId, frequency, serviceDate, situationIds, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, tripId=$tripId, schedule=$schedule, status=$status, additionalProperties=$additionalProperties}" + "List{schedule=$schedule, status=$status, tripId=$tripId, frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1893,17 +2024,17 @@ private constructor( return true } - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt index 12d2d35..d583984 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt @@ -5,18 +5,21 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Search for active trips for a specific route. */ class TripsForRouteListParams -constructor( +private constructor( private val routeId: String, private val includeSchedule: Boolean?, private val includeStatus: Boolean?, private val time: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun routeId(): String = routeId @@ -36,10 +39,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } @@ -62,8 +64,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [TripsForRouteListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var routeId: String? = null private var includeSchedule: Boolean? = null @@ -85,18 +88,47 @@ constructor( fun routeId(routeId: String) = apply { this.routeId = routeId } /** Determine whether full schedule elements are included. Defaults to false. */ - fun includeSchedule(includeSchedule: Boolean) = apply { + fun includeSchedule(includeSchedule: Boolean?) = apply { this.includeSchedule = includeSchedule } + /** Determine whether full schedule elements are included. Defaults to false. */ + fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) + + /** Determine whether full schedule elements are included. Defaults to false. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeSchedule(includeSchedule: Optional) = + includeSchedule(includeSchedule.orElse(null) as Boolean?) + + /** + * Determine whether full tripStatus elements with real-time information are included. + * Defaults to false. + */ + fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } + /** * Determine whether full tripStatus elements with real-time information are included. * Defaults to false. */ - fun includeStatus(includeStatus: Boolean) = apply { this.includeStatus = includeStatus } + fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) + + /** + * Determine whether full tripStatus elements with real-time information are included. + * Defaults to false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun includeStatus(includeStatus: Optional) = + includeStatus(includeStatus.orElse(null) as Boolean?) + + /** Query the system at a specific time. Useful for testing. */ + fun time(time: Long?) = apply { this.time = time } + + /** Query the system at a specific time. Useful for testing. */ + fun time(time: Long) = time(time as Long?) /** Query the system at a specific time. Useful for testing. */ - fun time(time: Long) = apply { this.time = time } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun time(time: Optional) = time(time.orElse(null) as Long?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -198,7 +230,7 @@ constructor( fun build(): TripsForRouteListParams = TripsForRouteListParams( - checkNotNull(routeId) { "`routeId` is required but was not set" }, + checkRequired("routeId", routeId), includeSchedule, includeStatus, time, diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt index 4b2acb0..700dcd3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): TripsForRouteListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [TripsForRouteListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): TripsForRouteListResponse = TripsForRouteListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -176,11 +180,17 @@ private constructor( fun references(): References = references.getRequired("references") - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -189,12 +199,14 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -204,17 +216,18 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var limitExceeded: JsonField = JsonMissing.of() - private var list: JsonField> = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var limitExceeded: JsonField? = null + private var list: JsonField>? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { limitExceeded = data.limitExceeded - list = data.list + list = data.list.map { it.toMutableList() } references = data.references additionalProperties = data.additionalProperties.toMutableMap() } @@ -227,7 +240,22 @@ private constructor( fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } fun references(references: References) = references(JsonField.of(references)) @@ -256,9 +284,9 @@ private constructor( fun build(): Data = Data( - limitExceeded, - list.map { it.toImmutable() }, - references, + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -267,6 +295,15 @@ private constructor( class List @JsonCreator private constructor( + @JsonProperty("schedule") + @ExcludeMissing + private val schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + private val tripId: JsonField = JsonMissing.of(), @JsonProperty("frequency") @ExcludeMissing private val frequency: JsonField = JsonMissing.of(), @@ -278,17 +315,15 @@ private constructor( private val situationIds: JsonField> = JsonMissing.of(), @JsonProperty("tripId") @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - private val schedule: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun schedule(): Schedule = schedule.getRequired("schedule") + + fun status(): Status = status.getRequired("status") + + fun tripId(): String = tripId.getRequired("tripId") + fun frequency(): Optional = Optional.ofNullable(frequency.getNullable("frequency")) @@ -298,23 +333,25 @@ private constructor( fun situationIds(): Optional> = Optional.ofNullable(situationIds.getNullable("situationIds")) - fun tripId(): String = tripId.getRequired("tripId") - - fun schedule(): Schedule = schedule.getRequired("schedule") - - fun status(): Status = status.getRequired("status") - - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency - @JsonProperty("schedule") @ExcludeMissing fun _schedule() = schedule + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds @JsonAnyGetter @ExcludeMissing @@ -323,15 +360,17 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - frequency() - serviceDate() - situationIds() - tripId() - schedule().validate() - status().validate() - validated = true + if (validated) { + return@apply } + + schedule().validate() + status().validate() + tripId() + frequency() + serviceDate() + situationIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -341,29 +380,43 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { + private var schedule: JsonField? = null + private var status: JsonField? = null + private var tripId: JsonField? = null private var frequency: JsonField = JsonMissing.of() private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(list: List) = apply { - frequency = list.frequency - serviceDate = list.serviceDate - situationIds = list.situationIds - tripId = list.tripId schedule = list.schedule status = list.status + tripId = list.tripId + frequency = list.frequency + serviceDate = list.serviceDate + situationIds = list.situationIds.map { it.toMutableList() } additionalProperties = list.additionalProperties.toMutableMap() } - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun status(status: Status) = status(JsonField.of(status)) + + fun status(status: JsonField) = apply { this.status = status } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) fun frequency(frequency: JsonField) = apply { this.frequency = frequency } @@ -377,20 +430,21 @@ private constructor( situationIds(JsonField.of(situationIds)) fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds + this.situationIds = situationIds.map { it.toMutableList() } } - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -416,12 +470,12 @@ private constructor( fun build(): List = List( + checkRequired("schedule", schedule), + checkRequired("status", status), + checkRequired("tripId", tripId), frequency, serviceDate, - situationIds.map { it.toImmutable() }, - tripId, - schedule, - status, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -430,9 +484,6 @@ private constructor( class Schedule @JsonCreator private constructor( - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("nextTripId") @ExcludeMissing private val nextTripId: JsonField = JsonMissing.of(), @@ -446,13 +497,13 @@ private constructor( @JsonProperty("timeZone") @ExcludeMissing private val timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - fun nextTripId(): String = nextTripId.getRequired("nextTripId") fun previousTripId(): String = previousTripId.getRequired("previousTripId") @@ -462,17 +513,28 @@ private constructor( fun timeZone(): String = timeZone.getRequired("timeZone") - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) - @JsonProperty("nextTripId") @ExcludeMissing fun _nextTripId() = nextTripId + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId @JsonProperty("previousTripId") @ExcludeMissing - fun _previousTripId() = previousTripId + fun _previousTripId(): JsonField = previousTripId + + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes - @JsonProperty("stopTimes") @ExcludeMissing fun _stopTimes() = stopTimes + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone() = timeZone + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency @JsonAnyGetter @ExcludeMissing @@ -481,14 +543,16 @@ private constructor( private var validated: Boolean = false fun validate(): Schedule = apply { - if (!validated) { - frequency() - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - validated = true + if (validated) { + return@apply } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + validated = true } fun toBuilder() = Builder().from(this) @@ -498,32 +562,26 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Schedule]. */ + class Builder internal constructor() { + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField = JsonMissing.of() - private var previousTripId: JsonField = JsonMissing.of() - private var stopTimes: JsonField> = - JsonMissing.of() - private var timeZone: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(schedule: Schedule) = apply { - frequency = schedule.frequency nextTripId = schedule.nextTripId previousTripId = schedule.previousTripId - stopTimes = schedule.stopTimes + stopTimes = schedule.stopTimes.map { it.toMutableList() } timeZone = schedule.timeZone + frequency = schedule.frequency additionalProperties = schedule.additionalProperties.toMutableMap() } - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) fun nextTripId(nextTripId: JsonField) = apply { @@ -541,13 +599,34 @@ private constructor( stopTimes(JsonField.of(stopTimes)) fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes + this.stopTimes = stopTimes.map { it.toMutableList() } + } + + fun addStopTime(stopTime: StopTime) = apply { + stopTimes = + (stopTimes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopTime) + } } fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } + fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) + + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -572,11 +651,11 @@ private constructor( fun build(): Schedule = Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), frequency, - nextTripId, - previousTripId, - stopTimes.map { it.toImmutable() }, - timeZone, additionalProperties.toImmutable(), ) } @@ -625,23 +704,29 @@ private constructor( fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) - @JsonProperty("arrivalTime") @ExcludeMissing fun _arrivalTime() = arrivalTime + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime @JsonProperty("departureTime") @ExcludeMissing - fun _departureTime() = departureTime + fun _departureTime(): JsonField = departureTime @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip + fun _distanceAlongTrip(): JsonField = distanceAlongTrip @JsonProperty("historicalOccupancy") @ExcludeMissing - fun _historicalOccupancy() = historicalOccupancy + fun _historicalOccupancy(): JsonField = historicalOccupancy - @JsonProperty("stopHeadsign") @ExcludeMissing fun _stopHeadsign() = stopHeadsign + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign - @JsonProperty("stopId") @ExcludeMissing fun _stopId() = stopId + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId @JsonAnyGetter @ExcludeMissing @@ -650,15 +735,17 @@ private constructor( private var validated: Boolean = false fun validate(): StopTime = apply { - if (!validated) { - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true + if (validated) { + return@apply } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + stopId() + validated = true } fun toBuilder() = Builder().from(this) @@ -668,7 +755,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [StopTime]. */ + class Builder internal constructor() { private var arrivalTime: JsonField = JsonMissing.of() private var departureTime: JsonField = JsonMissing.of() @@ -785,17 +873,17 @@ private constructor( return true } - return /* spotless:off */ other is Schedule && frequency == other.frequency && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequency, nextTripId, previousTripId, stopTimes, timeZone, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Schedule{frequency=$frequency, nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, additionalProperties=$additionalProperties}" + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" } @NoAutoDetect @@ -811,36 +899,18 @@ private constructor( @JsonProperty("closestStop") @ExcludeMissing private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("distanceAlongTrip") @ExcludeMissing private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), @JsonProperty("lastLocationUpdateTime") @ExcludeMissing private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing private val occupancyCapacity: JsonField = JsonMissing.of(), @@ -850,37 +920,55 @@ private constructor( @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), @JsonProperty("phase") @ExcludeMissing private val phase: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), @JsonProperty("predicted") @ExcludeMissing private val predicted: JsonField = JsonMissing.of(), @JsonProperty("scheduleDeviation") @ExcludeMissing private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("serviceDate") @ExcludeMissing private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = - JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + private val situationIds: JsonField> = + JsonMissing.of(), @JsonProperty("vehicleId") @ExcludeMissing private val vehicleId: JsonField = JsonMissing.of(), @@ -897,22 +985,11 @@ private constructor( /** ID of the closest stop to the current location of the transit vehicle. */ fun closestStop(): String = closestStop.getRequired("closestStop") - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -920,14 +997,6 @@ private constructor( fun lastKnownDistanceAlongTrip(): Double = lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - /** * Timestamp of the last known real-time location update from the transit vehicle. */ @@ -937,17 +1006,6 @@ private constructor( /** Timestamp of the last known real-time update from the transit vehicle. */ fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") @@ -957,17 +1015,9 @@ private constructor( /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - /** Current journey phase of the trip. */ fun phase(): String = phase.getRequired("phase") - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(): Boolean = predicted.getRequired("predicted") @@ -976,25 +1026,12 @@ private constructor( */ fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - /** Current status modifiers for the trip. */ fun status(): String = status.getRequired("status") @@ -1002,38 +1039,82 @@ private constructor( fun totalDistanceAlongTrip(): Double = totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + fun closestStopTimeOffset(): Optional = + Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(): Optional = + Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) + + /** Last known orientation value received in real-time from the transit vehicle. */ + fun lastKnownOrientation(): Optional = + Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(): Optional = + Optional.ofNullable(nextStop.getNullable("nextStop")) + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + fun nextStopTimeOffset(): Optional = + Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(): Optional = + Optional.ofNullable(orientation.getNullable("orientation")) + + /** Current position of the transit vehicle. */ + fun position(): Optional = + Optional.ofNullable(position.getNullable("position")) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + fun scheduledDistanceAlongTrip(): Optional = + Optional.ofNullable( + scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") + ) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(): Optional> = + Optional.ofNullable(situationIds.getNullable("situationIds")) + + /** ID of the transit vehicle currently serving the trip. */ + fun vehicleId(): Optional = + Optional.ofNullable(vehicleId.getNullable("vehicleId")) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId /** Index of the active trip into the sequence of trips for the active block. */ @JsonProperty("blockTripSequence") @ExcludeMissing - fun _blockTripSequence() = blockTripSequence + fun _blockTripSequence(): JsonField = blockTripSequence /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") + @JsonProperty("closestStop") @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset + fun _closestStop(): JsonField = closestStop /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun _distanceAlongTrip(): JsonField = distanceAlongTrip /** * Last known distance along the trip received in real-time from the transit @@ -1041,102 +1122,129 @@ private constructor( */ @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip /** * Timestamp of the last known real-time location update from the transit vehicle. */ @JsonProperty("lastLocationUpdateTime") @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime /** Timestamp of the last known real-time update from the transit vehicle. */ @JsonProperty("lastUpdateTime") @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset + fun _lastUpdateTime(): JsonField = lastUpdateTime /** Capacity of the transit vehicle in terms of occupancy. */ @JsonProperty("occupancyCapacity") @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity + fun _occupancyCapacity(): JsonField = occupancyCapacity /** Current count of occupants in the transit vehicle. */ @JsonProperty("occupancyCount") @ExcludeMissing - fun _occupancyCount() = occupancyCount + fun _occupancyCount(): JsonField = occupancyCount /** Current occupancy status of the transit vehicle. */ @JsonProperty("occupancyStatus") @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation + fun _occupancyStatus(): JsonField = occupancyStatus /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted /** * Deviation from the schedule in seconds (positive for late, negative for early). */ @JsonProperty("scheduleDeviation") @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip + fun _scheduleDeviation(): JsonField = scheduleDeviation /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Total length of the trip, in meters. */ @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Last known location of the transit vehicle. */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** Last known orientation value received in real-time from the transit vehicle. */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** Current position of the transit vehicle. */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** References to situation elements (if any) applicable to this trip. */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId @JsonAnyGetter @ExcludeMissing @@ -1145,36 +1253,38 @@ private constructor( private var validated: Boolean = false fun validate(): Status = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -1184,35 +1294,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() + /** A builder for [Status]. */ + 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 distanceAlongTrip: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() private var lastKnownLocation: JsonField = JsonMissing.of() private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() private var nextStop: JsonField = JsonMissing.of() private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1221,29 +1331,29 @@ private constructor( activeTripId = status.activeTripId blockTripSequence = status.blockTripSequence closestStop = status.closestStop - closestStopTimeOffset = status.closestStopTimeOffset distanceAlongTrip = status.distanceAlongTrip - frequency = status.frequency lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - lastKnownLocation = status.lastKnownLocation - lastKnownOrientation = status.lastKnownOrientation lastLocationUpdateTime = status.lastLocationUpdateTime lastUpdateTime = status.lastUpdateTime - nextStop = status.nextStop - nextStopTimeOffset = status.nextStopTimeOffset occupancyCapacity = status.occupancyCapacity occupancyCount = status.occupancyCount occupancyStatus = status.occupancyStatus - orientation = status.orientation phase = status.phase - position = status.position predicted = status.predicted scheduleDeviation = status.scheduleDeviation - scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip serviceDate = status.serviceDate - situationIds = status.situationIds this.status = status.status totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } vehicleId = status.vehicleId additionalProperties = status.additionalProperties.toMutableMap() } @@ -1274,21 +1384,6 @@ private constructor( this.closestStop = closestStop } - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - /** * Distance, in meters, the transit vehicle has progressed along the active * trip. @@ -1304,14 +1399,6 @@ private constructor( this.distanceAlongTrip = distanceAlongTrip } - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1328,28 +1415,6 @@ private constructor( this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - /** * Timestamp of the last known real-time location update from the transit * vehicle. @@ -1374,27 +1439,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -1422,26 +1466,12 @@ private constructor( this.occupancyStatus = occupancyStatus } - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - /** Current journey phase of the trip. */ fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ fun phase(phase: JsonField) = apply { this.phase = phase } - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - fun position(position: JsonField) = apply { this.position = position } - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) @@ -1465,22 +1495,6 @@ private constructor( this.scheduleDeviation = scheduleDeviation } - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. @@ -1495,16 +1509,6 @@ private constructor( this.serviceDate = serviceDate } - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = - apply { - this.situationIds = situationIds - } - /** Current status modifiers for the trip. */ fun status(status: String) = status(JsonField.of(status)) @@ -1520,6 +1524,126 @@ private constructor( 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)) + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + 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)) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: JsonField) = apply { + 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. */ + 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)) + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + 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)) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + 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)) + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + 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)) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** Current position of the transit vehicle. */ + 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)) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: kotlin.collections.List) = + situationIds(JsonField.of(situationIds)) + + /** References to situation elements (if any) applicable to this trip. */ + fun situationIds(situationIds: JsonField>) = + apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** References to situation elements (if any) applicable to this trip. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) @@ -1552,32 +1676,32 @@ private constructor( fun build(): Status = Status( - activeTripId, - blockTripSequence, - closestStop, + 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, - distanceAlongTrip, frequency, - lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, nextStop, nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, orientation, - phase, position, - predicted, - scheduleDeviation, scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, vehicleId, additionalProperties.toImmutable(), ) @@ -1605,10 +1729,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1617,11 +1741,13 @@ private constructor( private var validated: Boolean = false fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1631,7 +1757,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1728,10 +1855,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1740,11 +1867,13 @@ private constructor( private var validated: Boolean = false fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1754,7 +1883,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Position]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1833,17 +1963,17 @@ private constructor( return true } - return /* spotless:off */ other is Status && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Status && 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Status{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "Status{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 { @@ -1851,17 +1981,17 @@ private constructor( return true } - return /* spotless:off */ other is List && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && tripId == other.tripId && schedule == other.schedule && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && schedule == other.schedule && status == other.status && tripId == other.tripId && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequency, serviceDate, situationIds, tripId, schedule, status, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(schedule, status, tripId, frequency, serviceDate, situationIds, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, tripId=$tripId, schedule=$schedule, status=$status, additionalProperties=$additionalProperties}" + "List{schedule=$schedule, status=$status, tripId=$tripId, frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt index 959a68a..37a0200 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt @@ -5,16 +5,19 @@ package org.onebusaway.models import java.util.Objects import java.util.Optional import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams +/** Get vehicles for a specific agency */ class VehiclesForAgencyListParams -constructor( +private constructor( private val agencyId: String, private val time: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun agencyId(): String = agencyId @@ -25,10 +28,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.time?.let { queryParams.put("time", listOf(it.toString())) } queryParams.putAll(additionalQueryParams) @@ -49,8 +51,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [VehiclesForAgencyListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var agencyId: String? = null private var time: String? = null @@ -68,7 +71,10 @@ constructor( fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } /** Specific time for querying the status (timestamp format) */ - fun time(time: String) = apply { this.time = time } + fun time(time: String?) = apply { this.time = time } + + /** Specific time for querying the status (timestamp format) */ + fun time(time: Optional) = time(time.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -170,7 +176,7 @@ constructor( fun build(): VehiclesForAgencyListParams = VehiclesForAgencyListParams( - checkNotNull(agencyId) { "`agencyId` is required but was not set" }, + checkRequired("agencyId", agencyId), time, additionalHeaders.build(), additionalQueryParams.build(), diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt index a8ff567..98ae4a2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt @@ -13,6 +13,7 @@ import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkRequired import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable @@ -42,15 +43,15 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime() = currentTime + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing @@ -67,14 +68,16 @@ private constructor( private var validated: Boolean = false fun validate(): VehiclesForAgencyListResponse = apply { - if (!validated) { - code() - currentTime() - text() - version() - data().validate() - validated = true + if (validated) { + return@apply } + + code() + currentTime() + text() + version() + data().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -84,13 +87,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [VehiclesForAgencyListResponse]. */ + class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() - private var currentTime: JsonField = JsonMissing.of() - private var text: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + 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 @@ -144,11 +148,11 @@ private constructor( fun build(): VehiclesForAgencyListResponse = VehiclesForAgencyListResponse( - code, - currentTime, - text, - version, - data, + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), additionalProperties.toImmutable(), ) } @@ -169,18 +173,23 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun list(): kotlin.collections.List = list.getRequired("list") fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") fun references(): References = references.getRequired("references") - @JsonProperty("list") @ExcludeMissing fun _list() = list + @JsonProperty("limitExceeded") + @ExcludeMissing + fun _limitExceeded(): JsonField = limitExceeded - @JsonProperty("limitExceeded") @ExcludeMissing fun _limitExceeded() = limitExceeded + @JsonProperty("list") + @ExcludeMissing + fun _list(): JsonField> = list - @JsonProperty("references") @ExcludeMissing fun _references() = references + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references @JsonAnyGetter @ExcludeMissing @@ -189,12 +198,14 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - list().forEach { it.validate() } - limitExceeded() - references().validate() - validated = true + if (validated) { + return@apply } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -204,24 +215,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { - private var list: JsonField> = JsonMissing.of() - private var limitExceeded: JsonField = JsonMissing.of() - private var references: JsonField = JsonMissing.of() + private var list: JsonField>? = null + private var limitExceeded: JsonField? = null + private var references: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - list = data.list limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } references = data.references additionalProperties = data.additionalProperties.toMutableMap() } fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - fun list(list: JsonField>) = apply { this.list = list } + fun list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) @@ -229,6 +243,19 @@ private constructor( this.limitExceeded = limitExceeded } + fun addList(list: List) = apply { + this.list = + (this.list ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(list) + } + } + fun references(references: References) = references(JsonField.of(references)) fun references(references: JsonField) = apply { @@ -256,9 +283,9 @@ private constructor( fun build(): Data = Data( - list.map { it.toImmutable() }, - limitExceeded, - references, + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("limitExceeded", limitExceeded), + checkRequired("references", references), additionalProperties.toImmutable(), ) } @@ -267,15 +294,12 @@ private constructor( class List @JsonCreator private constructor( - @JsonProperty("vehicleId") + @JsonProperty("lastLocationUpdateTime") @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), + private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), @@ -285,6 +309,9 @@ private constructor( @JsonProperty("tripStatus") @ExcludeMissing private val tripStatus: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + private val vehicleId: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing private val occupancyCapacity: JsonField = JsonMissing.of(), @@ -304,19 +331,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - fun lastLocationUpdateTime(): Long = lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + fun location(): Location = location.getRequired("location") fun tripId(): String = tripId.getRequired("tripId") fun tripStatus(): TripStatus = tripStatus.getRequired("tripStatus") + fun vehicleId(): String = vehicleId.getRequired("vehicleId") + fun occupancyCapacity(): Optional = Optional.ofNullable(occupancyCapacity.getNullable("occupancyCapacity")) @@ -330,33 +357,43 @@ private constructor( fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - @JsonProperty("lastUpdateTime") @ExcludeMissing fun _lastUpdateTime() = lastUpdateTime + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime - @JsonProperty("lastLocationUpdateTime") + @JsonProperty("location") @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime + fun _location(): JsonField = location - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - @JsonProperty("tripId") @ExcludeMissing fun _tripId() = tripId + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus - @JsonProperty("tripStatus") @ExcludeMissing fun _tripStatus() = tripStatus + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId @JsonProperty("occupancyCapacity") @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity + fun _occupancyCapacity(): JsonField = occupancyCapacity - @JsonProperty("occupancyCount") @ExcludeMissing fun _occupancyCount() = occupancyCount + @JsonProperty("occupancyCount") + @ExcludeMissing + fun _occupancyCount(): JsonField = occupancyCount @JsonProperty("occupancyStatus") @ExcludeMissing - fun _occupancyStatus() = occupancyStatus + fun _occupancyStatus(): JsonField = occupancyStatus - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -365,20 +402,22 @@ private constructor( private var validated: Boolean = false fun validate(): List = apply { - if (!validated) { - vehicleId() - lastUpdateTime() - lastLocationUpdateTime() - location().validate() - tripId() - tripStatus().validate() - occupancyCapacity() - occupancyCount() - occupancyStatus() - phase() - status() - validated = true + if (validated) { + return@apply } + + lastLocationUpdateTime() + lastUpdateTime() + location().validate() + tripId() + tripStatus().validate() + vehicleId() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + status() + validated = true } fun toBuilder() = Builder().from(this) @@ -388,14 +427,15 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [List]. */ + class Builder internal constructor() { - private var vehicleId: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var tripId: JsonField = JsonMissing.of() - private var tripStatus: JsonField = JsonMissing.of() + 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 occupancyCapacity: JsonField = JsonMissing.of() private var occupancyCount: JsonField = JsonMissing.of() private var occupancyStatus: JsonField = JsonMissing.of() @@ -405,12 +445,12 @@ private constructor( @JvmSynthetic internal fun from(list: List) = apply { - vehicleId = list.vehicleId - lastUpdateTime = list.lastUpdateTime lastLocationUpdateTime = list.lastLocationUpdateTime + lastUpdateTime = list.lastUpdateTime location = list.location tripId = list.tripId tripStatus = list.tripStatus + vehicleId = list.vehicleId occupancyCapacity = list.occupancyCapacity occupancyCount = list.occupancyCount occupancyStatus = list.occupancyStatus @@ -419,9 +459,12 @@ private constructor( additionalProperties = list.additionalProperties.toMutableMap() } - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = + lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } + fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { + this.lastLocationUpdateTime = lastLocationUpdateTime + } fun lastUpdateTime(lastUpdateTime: Long) = lastUpdateTime(JsonField.of(lastUpdateTime)) @@ -430,13 +473,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - fun location(location: Location) = location(JsonField.of(location)) fun location(location: JsonField) = apply { this.location = location } @@ -451,6 +487,10 @@ private constructor( this.tripStatus = tripStatus } + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } + fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -504,12 +544,12 @@ private constructor( fun build(): List = List( - vehicleId, - lastUpdateTime, - lastLocationUpdateTime, - location, - tripId, - tripStatus, + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("location", location), + checkRequired("tripId", tripId), + checkRequired("tripStatus", tripStatus), + checkRequired("vehicleId", vehicleId), occupancyCapacity, occupancyCount, occupancyStatus, @@ -537,9 +577,9 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -548,11 +588,13 @@ private constructor( private var validated: Boolean = false fun validate(): Location = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -562,7 +604,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Location]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -644,36 +687,18 @@ private constructor( @JsonProperty("closestStop") @ExcludeMissing private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("distanceAlongTrip") @ExcludeMissing private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), @JsonProperty("lastLocationUpdateTime") @ExcludeMissing private val lastLocationUpdateTime: JsonField = JsonMissing.of(), @JsonProperty("lastUpdateTime") @ExcludeMissing private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), @JsonProperty("occupancyCapacity") @ExcludeMissing private val occupancyCapacity: JsonField = JsonMissing.of(), @@ -683,24 +708,15 @@ private constructor( @JsonProperty("occupancyStatus") @ExcludeMissing private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), @JsonProperty("phase") @ExcludeMissing private val phase: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), @JsonProperty("predicted") @ExcludeMissing private val predicted: JsonField = JsonMissing.of(), @JsonProperty("scheduleDeviation") @ExcludeMissing private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("serviceDate") @ExcludeMissing private val serviceDate: JsonField = JsonMissing.of(), @@ -714,6 +730,33 @@ private constructor( @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + private val closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + private val lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + private val lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + private val nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + private val nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + private val orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), @JsonProperty("vehicleId") @ExcludeMissing private val vehicleId: JsonField = JsonMissing.of(), @@ -730,22 +773,11 @@ private constructor( /** ID of the closest stop to the current location of the transit vehicle. */ fun closestStop(): String = closestStop.getRequired("closestStop") - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -753,14 +785,6 @@ private constructor( fun lastKnownDistanceAlongTrip(): Double = lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - /** * Timestamp of the last known real-time location update from the transit vehicle. */ @@ -770,17 +794,6 @@ private constructor( /** Timestamp of the last known real-time update from the transit vehicle. */ fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") @@ -790,17 +803,9 @@ private constructor( /** Current occupancy status of the transit vehicle. */ fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - /** Current journey phase of the trip. */ fun phase(): String = phase.getRequired("phase") - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(): Boolean = predicted.getRequired("predicted") @@ -809,15 +814,6 @@ private constructor( */ fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. @@ -835,38 +831,78 @@ private constructor( fun totalDistanceAlongTrip(): Double = totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + fun closestStopTimeOffset(): Optional = + Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) + + /** Last known location of the transit vehicle. */ + fun lastKnownLocation(): Optional = + Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) + + /** Last known orientation value received in real-time from the transit vehicle. */ + fun lastKnownOrientation(): Optional = + Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + fun nextStop(): Optional = + Optional.ofNullable(nextStop.getNullable("nextStop")) + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + fun nextStopTimeOffset(): Optional = + Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(): Optional = + Optional.ofNullable(orientation.getNullable("orientation")) + + /** Current position of the transit vehicle. */ + fun position(): Optional = + Optional.ofNullable(position.getNullable("position")) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + fun scheduledDistanceAlongTrip(): Optional = + Optional.ofNullable( + scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") + ) + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(): Optional = Optional.ofNullable(vehicleId.getNullable("vehicleId")) /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") @ExcludeMissing fun _activeTripId() = activeTripId + @JsonProperty("activeTripId") + @ExcludeMissing + fun _activeTripId(): JsonField = activeTripId /** Index of the active trip into the sequence of trips for the active block. */ @JsonProperty("blockTripSequence") @ExcludeMissing - fun _blockTripSequence() = blockTripSequence + fun _blockTripSequence(): JsonField = blockTripSequence /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") @ExcludeMissing fun _closestStop() = closestStop - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") + @JsonProperty("closestStop") @ExcludeMissing - fun _closestStopTimeOffset() = closestStopTimeOffset + fun _closestStop(): JsonField = closestStop /** * Distance, in meters, the transit vehicle has progressed along the active trip. */ @JsonProperty("distanceAlongTrip") @ExcludeMissing - fun _distanceAlongTrip() = distanceAlongTrip - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + fun _distanceAlongTrip(): JsonField = distanceAlongTrip /** * Last known distance along the trip received in real-time from the transit @@ -874,102 +910,129 @@ private constructor( */ @JsonProperty("lastKnownDistanceAlongTrip") @ExcludeMissing - fun _lastKnownDistanceAlongTrip() = lastKnownDistanceAlongTrip - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation() = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation() = lastKnownOrientation + fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip /** * Timestamp of the last known real-time location update from the transit vehicle. */ @JsonProperty("lastLocationUpdateTime") @ExcludeMissing - fun _lastLocationUpdateTime() = lastLocationUpdateTime + fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime /** Timestamp of the last known real-time update from the transit vehicle. */ @JsonProperty("lastUpdateTime") @ExcludeMissing - fun _lastUpdateTime() = lastUpdateTime + fun _lastUpdateTime(): JsonField = lastUpdateTime - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") @ExcludeMissing fun _nextStop() = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset() = nextStopTimeOffset - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity() = occupancyCapacity + /** Capacity of the transit vehicle in terms of occupancy. */ + @JsonProperty("occupancyCapacity") + @ExcludeMissing + fun _occupancyCapacity(): JsonField = occupancyCapacity /** Current count of occupants in the transit vehicle. */ @JsonProperty("occupancyCount") @ExcludeMissing - fun _occupancyCount() = occupancyCount + fun _occupancyCount(): JsonField = occupancyCount /** Current occupancy status of the transit vehicle. */ @JsonProperty("occupancyStatus") @ExcludeMissing - fun _occupancyStatus() = occupancyStatus - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") @ExcludeMissing fun _orientation() = orientation + fun _occupancyStatus(): JsonField = occupancyStatus /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase() = phase - - /** Current position of the transit vehicle. */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") @ExcludeMissing fun _predicted() = predicted + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted /** * Deviation from the schedule in seconds (positive for late, negative for early). */ @JsonProperty("scheduleDeviation") @ExcludeMissing - fun _scheduleDeviation() = scheduleDeviation - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip() = scheduledDistanceAlongTrip + fun _scheduleDeviation(): JsonField = scheduleDeviation /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. */ - @JsonProperty("serviceDate") @ExcludeMissing fun _serviceDate() = serviceDate - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") @ExcludeMissing fun _situationIds() = situationIds + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Total length of the trip, in meters. */ @JsonProperty("totalDistanceAlongTrip") @ExcludeMissing - fun _totalDistanceAlongTrip() = totalDistanceAlongTrip + fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + */ + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset + + /** Information about frequency-based scheduling, if applicable to the trip. */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** Last known location of the transit vehicle. */ + @JsonProperty("lastKnownLocation") + @ExcludeMissing + fun _lastKnownLocation(): JsonField = lastKnownLocation + + /** Last known orientation value received in real-time from the transit vehicle. */ + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + fun _lastKnownOrientation(): JsonField = lastKnownOrientation + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + @JsonProperty("nextStop") + @ExcludeMissing + fun _nextStop(): JsonField = nextStop + + /** + * Time offset from the next stop to the current position of the transit vehicle (in + * seconds). + */ + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + @JsonProperty("orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** Current position of the transit vehicle. */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed along + * the active trip. + */ + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip + + /** References to situation elements (if any) applicable to this trip. */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") @ExcludeMissing fun _vehicleId() = vehicleId + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId @JsonAnyGetter @ExcludeMissing @@ -978,36 +1041,38 @@ private constructor( private var validated: Boolean = false fun validate(): TripStatus = apply { - if (!validated) { - activeTripId() - blockTripSequence() - closestStop() - closestStopTimeOffset() - distanceAlongTrip() - frequency() - lastKnownDistanceAlongTrip() - lastKnownLocation().map { it.validate() } - lastKnownOrientation() - lastLocationUpdateTime() - lastUpdateTime() - nextStop() - nextStopTimeOffset() - occupancyCapacity() - occupancyCount() - occupancyStatus() - orientation() - phase() - position().map { it.validate() } - predicted() - scheduleDeviation() - scheduledDistanceAlongTrip() - serviceDate() - situationIds() - status() - totalDistanceAlongTrip() - vehicleId() - validated = true + 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 toBuilder() = Builder().from(this) @@ -1017,35 +1082,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var activeTripId: JsonField = JsonMissing.of() - private var blockTripSequence: JsonField = JsonMissing.of() - private var closestStop: JsonField = JsonMissing.of() + /** 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 situationIds: JsonField>? = null + private var status: JsonField? = null + private var totalDistanceAlongTrip: JsonField? = null private var closestStopTimeOffset: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() - private var lastKnownDistanceAlongTrip: JsonField = JsonMissing.of() private var lastKnownLocation: JsonField = JsonMissing.of() private var lastKnownOrientation: JsonField = JsonMissing.of() - private var lastLocationUpdateTime: JsonField = JsonMissing.of() - private var lastUpdateTime: JsonField = JsonMissing.of() private var nextStop: JsonField = JsonMissing.of() private var nextStopTimeOffset: JsonField = JsonMissing.of() - private var occupancyCapacity: JsonField = JsonMissing.of() - private var occupancyCount: JsonField = JsonMissing.of() - private var occupancyStatus: JsonField = JsonMissing.of() private var orientation: JsonField = JsonMissing.of() - private var phase: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var predicted: JsonField = JsonMissing.of() - private var scheduleDeviation: JsonField = JsonMissing.of() private var scheduledDistanceAlongTrip: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField> = - JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var totalDistanceAlongTrip: JsonField = JsonMissing.of() private var vehicleId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1054,29 +1119,29 @@ private constructor( activeTripId = tripStatus.activeTripId blockTripSequence = tripStatus.blockTripSequence closestStop = tripStatus.closestStop - closestStopTimeOffset = tripStatus.closestStopTimeOffset distanceAlongTrip = tripStatus.distanceAlongTrip - frequency = tripStatus.frequency lastKnownDistanceAlongTrip = tripStatus.lastKnownDistanceAlongTrip - lastKnownLocation = tripStatus.lastKnownLocation - lastKnownOrientation = tripStatus.lastKnownOrientation lastLocationUpdateTime = tripStatus.lastLocationUpdateTime lastUpdateTime = tripStatus.lastUpdateTime - nextStop = tripStatus.nextStop - nextStopTimeOffset = tripStatus.nextStopTimeOffset occupancyCapacity = tripStatus.occupancyCapacity occupancyCount = tripStatus.occupancyCount occupancyStatus = tripStatus.occupancyStatus - orientation = tripStatus.orientation phase = tripStatus.phase - position = tripStatus.position predicted = tripStatus.predicted scheduleDeviation = tripStatus.scheduleDeviation - scheduledDistanceAlongTrip = tripStatus.scheduledDistanceAlongTrip serviceDate = tripStatus.serviceDate - situationIds = tripStatus.situationIds 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() } @@ -1107,21 +1172,6 @@ private constructor( this.closestStop = closestStop } - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: Long) = - closestStopTimeOffset(JsonField.of(closestStopTimeOffset)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(closestStopTimeOffset: JsonField) = apply { - this.closestStopTimeOffset = closestStopTimeOffset - } - /** * Distance, in meters, the transit vehicle has progressed along the active * trip. @@ -1137,14 +1187,6 @@ private constructor( this.distanceAlongTrip = distanceAlongTrip } - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: String) = frequency(JsonField.of(frequency)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - /** * Last known distance along the trip received in real-time from the transit * vehicle. @@ -1161,28 +1203,6 @@ private constructor( this.lastKnownDistanceAlongTrip = lastKnownDistanceAlongTrip } - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = - lastKnownLocation(JsonField.of(lastKnownLocation)) - - /** Last known location of the transit vehicle. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(lastKnownOrientation: JsonField) = apply { - this.lastKnownOrientation = lastKnownOrientation - } - /** * Timestamp of the last known real-time location update from the transit * vehicle. @@ -1207,27 +1227,6 @@ private constructor( this.lastUpdateTime = lastUpdateTime } - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(nextStop: String) = nextStop(JsonField.of(nextStop)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(nextStopTimeOffset: JsonField) = apply { - this.nextStopTimeOffset = nextStopTimeOffset - } - /** Capacity of the transit vehicle in terms of occupancy. */ fun occupancyCapacity(occupancyCapacity: Long) = occupancyCapacity(JsonField.of(occupancyCapacity)) @@ -1255,26 +1254,12 @@ private constructor( this.occupancyStatus = occupancyStatus } - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: Double) = orientation(JsonField.of(orientation)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - /** Current journey phase of the trip. */ fun phase(phase: String) = phase(JsonField.of(phase)) /** Current journey phase of the trip. */ fun phase(phase: JsonField) = apply { this.phase = phase } - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - fun position(position: JsonField) = apply { this.position = position } - /** Indicates if real-time arrival info is available for this trip. */ fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) @@ -1298,22 +1283,6 @@ private constructor( this.scheduleDeviation = scheduleDeviation } - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: Double) = - scheduledDistanceAlongTrip(JsonField.of(scheduledDistanceAlongTrip)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - /** * Time, in milliseconds since the Unix epoch, of midnight for the start of the * service date for the trip. @@ -1335,7 +1304,7 @@ private constructor( /** References to situation elements (if any) applicable to this trip. */ fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds + this.situationIds = situationIds.map { it.toMutableList() } } /** Current status modifiers for the trip. */ @@ -1353,6 +1322,116 @@ private constructor( 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)) + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + */ + 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)) + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: JsonField) = apply { + 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. */ + 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)) + + /** + * Last known orientation value received in real-time from the transit vehicle. + */ + 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)) + + /** ID of the next stop the transit vehicle is scheduled to arrive at. */ + 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)) + + /** + * Time offset from the next stop to the current position of the transit vehicle + * (in seconds). + */ + 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)) + + /** Orientation of the transit vehicle, represented as an angle in degrees. */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + /** Current position of the transit vehicle. */ + fun position(position: Position) = position(JsonField.of(position)) + + /** Current position of the transit vehicle. */ + 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)) + + /** + * Distance, in meters, the transit vehicle is scheduled to have progressed + * along the active trip. + */ + fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = + apply { + this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip + } + + /** References to situation elements (if any) applicable to this trip. */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(situationId) + } + } + /** ID of the transit vehicle currently serving the trip. */ fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) @@ -1385,32 +1464,32 @@ private constructor( fun build(): TripStatus = TripStatus( - activeTripId, - blockTripSequence, - closestStop, + 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), + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("status", status), + checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), closestStopTimeOffset, - distanceAlongTrip, frequency, - lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, - lastLocationUpdateTime, - lastUpdateTime, nextStop, nextStopTimeOffset, - occupancyCapacity, - occupancyCount, - occupancyStatus, orientation, - phase, position, - predicted, - scheduleDeviation, scheduledDistanceAlongTrip, - serviceDate, - situationIds.map { it.toImmutable() }, - status, - totalDistanceAlongTrip, vehicleId, additionalProperties.toImmutable(), ) @@ -1438,10 +1517,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1450,11 +1529,13 @@ private constructor( private var validated: Boolean = false fun validate(): LastKnownLocation = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1464,7 +1545,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1561,10 +1643,10 @@ private constructor( fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat() = lat + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon() = lon + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonAnyGetter @ExcludeMissing @@ -1573,11 +1655,13 @@ private constructor( private var validated: Boolean = false fun validate(): Position = apply { - if (!validated) { - lat() - lon() - validated = true + if (validated) { + return@apply } + + lat() + lon() + validated = true } fun toBuilder() = Builder().from(this) @@ -1587,7 +1671,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Position]. */ + class Builder internal constructor() { private var lat: JsonField = JsonMissing.of() private var lon: JsonField = JsonMissing.of() @@ -1666,17 +1751,17 @@ private constructor( return true } - return /* spotless:off */ other is TripStatus && activeTripId == other.activeTripId && blockTripSequence == other.blockTripSequence && closestStop == other.closestStop && closestStopTimeOffset == other.closestStopTimeOffset && distanceAlongTrip == other.distanceAlongTrip && frequency == other.frequency && lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && lastKnownLocation == other.lastKnownLocation && lastKnownOrientation == other.lastKnownOrientation && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && nextStop == other.nextStop && nextStopTimeOffset == other.nextStopTimeOffset && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && orientation == other.orientation && phase == other.phase && position == other.position && predicted == other.predicted && scheduleDeviation == other.scheduleDeviation && scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && totalDistanceAlongTrip == other.totalDistanceAlongTrip && vehicleId == other.vehicleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeTripId, blockTripSequence, closestStop, closestStopTimeOffset, distanceAlongTrip, frequency, lastKnownDistanceAlongTrip, lastKnownLocation, lastKnownOrientation, lastLocationUpdateTime, lastUpdateTime, nextStop, nextStopTimeOffset, occupancyCapacity, occupancyCount, occupancyStatus, orientation, phase, position, predicted, scheduleDeviation, scheduledDistanceAlongTrip, serviceDate, situationIds, status, totalDistanceAlongTrip, vehicleId, 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) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, closestStopTimeOffset=$closestStopTimeOffset, distanceAlongTrip=$distanceAlongTrip, frequency=$frequency, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, orientation=$orientation, phase=$phase, position=$position, predicted=$predicted, scheduleDeviation=$scheduleDeviation, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + "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 { @@ -1684,17 +1769,17 @@ private constructor( return true } - return /* spotless:off */ other is List && vehicleId == other.vehicleId && lastUpdateTime == other.lastUpdateTime && lastLocationUpdateTime == other.lastLocationUpdateTime && location == other.location && tripId == other.tripId && tripStatus == other.tripStatus && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is List && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && location == other.location && tripId == other.tripId && tripStatus == other.tripStatus && vehicleId == other.vehicleId && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(vehicleId, lastUpdateTime, lastLocationUpdateTime, location, tripId, tripStatus, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(lastLocationUpdateTime, lastUpdateTime, location, tripId, tripStatus, vehicleId, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{vehicleId=$vehicleId, lastUpdateTime=$lastUpdateTime, lastLocationUpdateTime=$lastLocationUpdateTime, location=$location, tripId=$tripId, tripStatus=$tripStatus, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, status=$status, additionalProperties=$additionalProperties}" + "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}" } override fun equals(other: Any?): Boolean { @@ -1702,17 +1787,17 @@ private constructor( return true } - return /* spotless:off */ other is Data && list == other.list && limitExceeded == other.limitExceeded && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(list, limitExceeded, references, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Data{list=$list, limitExceeded=$limitExceeded, references=$references, additionalProperties=$additionalProperties}" + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt index d71c3ec..987fee8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.AgenciesWithCoverageListParams import org.onebusaway.models.AgenciesWithCoverageListResponse class AgenciesWithCoverageServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AgenciesWithCoverageServiceAsync { @@ -38,20 +39,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "agencies-with-coverage.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt index f60ba45..f11f454 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.AgencyRetrieveParams import org.onebusaway.models.AgencyRetrieveResponse class AgencyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AgencyServiceAsync { @@ -34,20 +35,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "agency", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt index 204abfe..f78eb4a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ArrivalAndDepartureListParams import org.onebusaway.models.ArrivalAndDepartureListResponse @@ -18,7 +19,7 @@ import org.onebusaway.models.ArrivalAndDepartureRetrieveParams import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse class ArrivalAndDepartureServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ArrivalAndDepartureServiceAsync { @@ -42,21 +43,19 @@ constructor( "arrival-and-departure-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -77,20 +76,18 @@ constructor( "arrivals-and-departures-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt index 9f096ec..0ecc49b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.BlockRetrieveParams import org.onebusaway.models.BlockRetrieveResponse class BlockServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : BlockServiceAsync { @@ -34,20 +35,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "block", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt index a5fca9d..f3b57a2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ConfigRetrieveParams import org.onebusaway.models.ConfigRetrieveResponse class ConfigServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ConfigServiceAsync { @@ -34,20 +35,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "config.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt index 9ce90d7..399e61e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.CurrentTimeRetrieveParams import org.onebusaway.models.CurrentTimeRetrieveResponse class CurrentTimeServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : CurrentTimeServiceAsync { @@ -35,20 +36,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "current-time.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt index faffec9..63945b6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ReportProblemWithStopRetrieveParams import org.onebusaway.models.ResponseWrapper class ReportProblemWithStopServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ReportProblemWithStopServiceAsync { @@ -39,20 +40,18 @@ constructor( "report-problem-with-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt index 5f05c95..f97f9ec 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ReportProblemWithTripRetrieveParams import org.onebusaway.models.ResponseWrapper class ReportProblemWithTripServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ReportProblemWithTripServiceAsync { @@ -39,20 +40,18 @@ constructor( "report-problem-with-trip", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt index 5eff280..fe189de 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.RouteIdsForAgencyListParams import org.onebusaway.models.RouteIdsForAgencyListResponse class RouteIdsForAgencyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RouteIdsForAgencyServiceAsync { @@ -40,20 +41,18 @@ constructor( "route-ids-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt index aefd043..0cb2551 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.RouteRetrieveParams import org.onebusaway.models.RouteRetrieveResponse class RouteServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RouteServiceAsync { @@ -34,20 +35,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "route", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt index e224551..73593ee 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.RoutesForAgencyListParams import org.onebusaway.models.RoutesForAgencyListResponse class RoutesForAgencyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RoutesForAgencyServiceAsync { @@ -40,20 +41,18 @@ constructor( "routes-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt index c064084..092cc9e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.RoutesForLocationListParams import org.onebusaway.models.RoutesForLocationListResponse class RoutesForLocationServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RoutesForLocationServiceAsync { @@ -35,20 +36,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "routes-for-location.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt index 8becc41..16c23fa 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ScheduleForRouteRetrieveParams import org.onebusaway.models.ScheduleForRouteRetrieveResponse class ScheduleForRouteServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ScheduleForRouteServiceAsync { @@ -40,20 +41,18 @@ constructor( "schedule-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt index 2e7d2db..3461606 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ScheduleForStopRetrieveParams import org.onebusaway.models.ScheduleForStopRetrieveResponse class ScheduleForStopServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ScheduleForStopServiceAsync { @@ -40,20 +41,18 @@ constructor( "schedule-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt index 31e79fa..b2cbde6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.SearchForRouteListParams import org.onebusaway.models.SearchForRouteListResponse class SearchForRouteServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SearchForRouteServiceAsync { @@ -35,20 +36,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "search", "route.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt index 548d135..ffc950d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.SearchForStopListParams import org.onebusaway.models.SearchForStopListResponse class SearchForStopServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SearchForStopServiceAsync { @@ -35,20 +36,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "search", "stop.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt index 62212c7..cc692d4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ShapeRetrieveParams import org.onebusaway.models.ShapeRetrieveResponse class ShapeServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ShapeServiceAsync { @@ -34,20 +35,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "shape", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt index ac255ef..2269905 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopIdsForAgencyListParams import org.onebusaway.models.StopIdsForAgencyListResponse class StopIdsForAgencyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopIdsForAgencyServiceAsync { @@ -40,20 +41,18 @@ constructor( "stop-ids-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt index 224c85b..783e18b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopRetrieveParams import org.onebusaway.models.StopRetrieveResponse class StopServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopServiceAsync { @@ -34,20 +35,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "stop", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt index 2014540..1cb4bcf 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopsForAgencyListParams import org.onebusaway.models.StopsForAgencyListResponse class StopsForAgencyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopsForAgencyServiceAsync { @@ -40,20 +41,18 @@ constructor( "stops-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt index e8c9059..cd2d5ac 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopsForLocationListParams import org.onebusaway.models.StopsForLocationListResponse class StopsForLocationServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopsForLocationServiceAsync { @@ -35,20 +36,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "stops-for-location.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt index 37dfda5..c218860 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopsForRouteListParams import org.onebusaway.models.StopsForRouteListResponse class StopsForRouteServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopsForRouteServiceAsync { @@ -40,20 +41,18 @@ constructor( "stops-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt index 7327ed8..8f03c39 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripDetailRetrieveParams import org.onebusaway.models.TripDetailRetrieveResponse class TripDetailServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripDetailServiceAsync { @@ -35,20 +36,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trip-details", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt index 3fcabfc..a2a4297 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripForVehicleRetrieveParams import org.onebusaway.models.TripForVehicleRetrieveResponse class TripForVehicleServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripForVehicleServiceAsync { @@ -40,20 +41,18 @@ constructor( "trip-for-vehicle", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt index d0b805c..3313c58 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripRetrieveParams import org.onebusaway.models.TripRetrieveResponse class TripServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripServiceAsync { @@ -34,20 +35,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trip", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt index d94a02c..cdc234d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripsForLocationListParams import org.onebusaway.models.TripsForLocationListResponse class TripsForLocationServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripsForLocationServiceAsync { @@ -35,20 +36,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trips-for-location.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt index 56fa6a6..a68955e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripsForRouteListParams import org.onebusaway.models.TripsForRouteListResponse class TripsForRouteServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripsForRouteServiceAsync { @@ -40,20 +41,18 @@ constructor( "trips-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt index 8041ee4..ed8e4a9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt @@ -11,12 +11,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepareAsync import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.VehiclesForAgencyListParams import org.onebusaway.models.VehiclesForAgencyListResponse class VehiclesForAgencyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : VehiclesForAgencyServiceAsync { @@ -40,20 +41,18 @@ constructor( "vehicles-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt index 96e220f..f1781f8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.AgenciesWithCoverageListParams import org.onebusaway.models.AgenciesWithCoverageListResponse class AgenciesWithCoverageServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AgenciesWithCoverageService { @@ -37,19 +38,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "agencies-with-coverage.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt index 601f734..1c98da6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.AgencyRetrieveParams import org.onebusaway.models.AgencyRetrieveResponse class AgencyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AgencyService { @@ -33,19 +34,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "agency", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt index a2b5c2b..20a92a7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt @@ -10,6 +10,7 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ArrivalAndDepartureListParams import org.onebusaway.models.ArrivalAndDepartureListResponse @@ -17,7 +18,7 @@ import org.onebusaway.models.ArrivalAndDepartureRetrieveParams import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse class ArrivalAndDepartureServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ArrivalAndDepartureService { @@ -41,20 +42,16 @@ constructor( "arrival-and-departure-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -75,19 +72,15 @@ constructor( "arrivals-and-departures-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt index e548168..95c79c1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.BlockRetrieveParams import org.onebusaway.models.BlockRetrieveResponse class BlockServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : BlockService { @@ -33,19 +34,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "block", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt index 559ee0e..4f8b585 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ConfigRetrieveParams import org.onebusaway.models.ConfigRetrieveResponse class ConfigServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ConfigService { @@ -33,19 +34,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "config.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt index 4c2fbb3..a468a87 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.CurrentTimeRetrieveParams import org.onebusaway.models.CurrentTimeRetrieveResponse class CurrentTimeServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : CurrentTimeService { @@ -34,19 +35,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "current-time.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt index 96cc31f..4899729 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ReportProblemWithStopRetrieveParams import org.onebusaway.models.ResponseWrapper class ReportProblemWithStopServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ReportProblemWithStopService { @@ -38,19 +39,15 @@ constructor( "report-problem-with-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt index 58edddb..76b40c0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ReportProblemWithTripRetrieveParams import org.onebusaway.models.ResponseWrapper class ReportProblemWithTripServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ReportProblemWithTripService { @@ -38,19 +39,15 @@ constructor( "report-problem-with-trip", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt index f8bc0a8..afc9602 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.RouteIdsForAgencyListParams import org.onebusaway.models.RouteIdsForAgencyListResponse class RouteIdsForAgencyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RouteIdsForAgencyService { @@ -39,19 +40,15 @@ constructor( "route-ids-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt index 34b2b54..64d3eb2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.RouteRetrieveParams import org.onebusaway.models.RouteRetrieveResponse class RouteServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RouteService { @@ -33,19 +34,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "route", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt index 635e3ec..f1850cb 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.RoutesForAgencyListParams import org.onebusaway.models.RoutesForAgencyListResponse class RoutesForAgencyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RoutesForAgencyService { @@ -39,19 +40,15 @@ constructor( "routes-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt index 224ef56..c28bfc4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.RoutesForLocationListParams import org.onebusaway.models.RoutesForLocationListResponse class RoutesForLocationServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RoutesForLocationService { @@ -34,19 +35,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "routes-for-location.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt index e8258ab..ffbfe43 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ScheduleForRouteRetrieveParams import org.onebusaway.models.ScheduleForRouteRetrieveResponse class ScheduleForRouteServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ScheduleForRouteService { @@ -39,19 +40,15 @@ constructor( "schedule-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt index d3e5860..114f9b2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ScheduleForStopRetrieveParams import org.onebusaway.models.ScheduleForStopRetrieveResponse class ScheduleForStopServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ScheduleForStopService { @@ -39,19 +40,15 @@ constructor( "schedule-for-stop", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt index 7f891ca..3be0bc5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.SearchForRouteListParams import org.onebusaway.models.SearchForRouteListResponse class SearchForRouteServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SearchForRouteService { @@ -34,19 +35,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "search", "route.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt index 1d11851..ec7bcd4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.SearchForStopListParams import org.onebusaway.models.SearchForStopListResponse class SearchForStopServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SearchForStopService { @@ -34,19 +35,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "search", "stop.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt index 688e7f9..1ddb284 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.ShapeRetrieveParams import org.onebusaway.models.ShapeRetrieveResponse class ShapeServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ShapeService { @@ -33,19 +34,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "shape", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt index 44057c5..fe012fc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopIdsForAgencyListParams import org.onebusaway.models.StopIdsForAgencyListResponse class StopIdsForAgencyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopIdsForAgencyService { @@ -39,19 +40,15 @@ constructor( "stop-ids-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt index 408115e..7a5d88a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopRetrieveParams import org.onebusaway.models.StopRetrieveResponse class StopServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopService { @@ -33,19 +34,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "stop", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt index 5c47981..5fdab39 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopsForAgencyListParams import org.onebusaway.models.StopsForAgencyListResponse class StopsForAgencyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopsForAgencyService { @@ -39,19 +40,15 @@ constructor( "stops-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt index c372642..69c3566 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopsForLocationListParams import org.onebusaway.models.StopsForLocationListResponse class StopsForLocationServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopsForLocationService { @@ -34,19 +35,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "stops-for-location.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt index 747794f..0468d86 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.StopsForRouteListParams import org.onebusaway.models.StopsForRouteListResponse class StopsForRouteServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : StopsForRouteService { @@ -39,19 +40,15 @@ constructor( "stops-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt index 6715731..0db93f0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripDetailRetrieveParams import org.onebusaway.models.TripDetailRetrieveResponse class TripDetailServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripDetailService { @@ -34,19 +35,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trip-details", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt index e70fa50..3718f47 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripForVehicleRetrieveParams import org.onebusaway.models.TripForVehicleRetrieveResponse class TripForVehicleServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripForVehicleService { @@ -39,19 +40,15 @@ constructor( "trip-for-vehicle", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt index 91e1972..57d1a7a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripRetrieveParams import org.onebusaway.models.TripRetrieveResponse class TripServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripService { @@ -33,19 +34,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trip", "${params.getPathParam(0)}.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt index 7505571..536a1d1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripsForLocationListParams import org.onebusaway.models.TripsForLocationListResponse class TripsForLocationServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripsForLocationService { @@ -34,19 +35,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("api", "where", "trips-for-location.json") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt index 029f847..7e3fe19 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.TripsForRouteListParams import org.onebusaway.models.TripsForRouteListResponse class TripsForRouteServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TripsForRouteService { @@ -39,19 +40,15 @@ constructor( "trips-for-route", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt index 5bcd201..7030568 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt @@ -10,12 +10,13 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.prepare import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.models.VehiclesForAgencyListParams import org.onebusaway.models.VehiclesForAgencyListResponse class VehiclesForAgencyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : VehiclesForAgencyService { @@ -39,19 +40,15 @@ constructor( "vehicles-for-agency", "${params.getPathParam(0)}.json" ) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } 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 22b8b7f..0cda7ea 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 @@ -4,39 +4,84 @@ import com.github.tomakehurst.wiremock.client.WireMock.* 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.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource import org.onebusaway.client.okhttp.OkHttpClient +import org.onebusaway.core.RequestOptions @WireMockTest internal class RetryingHttpClientTest { + private var openResponseCount = 0 private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - httpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + httpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions + ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions + ): CompletableFuture = + okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } + + override fun close() = okHttpClient.close() + + private fun trackClose(response: HttpResponse): HttpResponse { + openResponseCount++ + return object : HttpResponse { + private var isClosed = false + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = response.body() + + override fun close() { + response.close() + if (isClosed) { + return + } + openResponseCount-- + isClosed = true + } + } + } + } resetAllScenarios() } - @Test - fun byDefaultShouldNotAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } - @Test - fun whenProvidedShouldAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) @@ -45,21 +90,28 @@ internal class RetryingHttpClientTest { val retryingClient = RetryingHttpClient.builder() .httpClient(httpClient) + .maxRetries(2) .idempotencyHeader("X-Some-Header") .build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun retryAfterHeader(async: Boolean) { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + fun execute_withRetryAfterHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // first we fail with a retry after header given as a date + // 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") @@ -68,14 +120,16 @@ internal class RetryingHttpClientTest { ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we fail with a retry after header given as a delay + // Then we fail with a retry after header given as a delay + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DATE") .willReturn(serviceUnavailable().withHeader("Retry-After", "1.234")) .willSetStateTo("RETRY_AFTER_DELAY") ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we return a success + // Then we return a success + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DELAY") .willReturn(ok()) .willSetStateTo("COMPLETED") @@ -84,8 +138,10 @@ internal class RetryingHttpClientTest { RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) assertThat(response.statusCode()).isEqualTo(200) verify( @@ -103,17 +159,12 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")) ) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun overwriteRetryCountHeader(async: Boolean) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .putHeader("x-stainless-retry-count", "42") - .build() + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date @@ -134,8 +185,14 @@ internal class RetryingHttpClientTest { RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async + ) assertThat(response.statusCode()).isEqualTo(200) verify( @@ -143,12 +200,12 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")) ) + assertNoResponseLeaks() } - @Test - fun retryAfterMsHeader() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") @@ -165,8 +222,22 @@ internal class RetryingHttpClientTest { ) val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) + + // When retrying, all failed responses should be closed. Only the final returned response should + // be open. + private fun assertNoResponseLeaks() = assertThat(openResponseCount).isEqualTo(1) } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt index 8a87713..22f9102 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt @@ -65,7 +65,8 @@ internal class SerializerTest { } @NoAutoDetect - class Builder { + class Builder internal constructor() { + private var isActive: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt index 7fea7da..7a32ee3 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class AgenciesWithCoverageListParamsTest { @Test - fun createAgenciesWithCoverageListParams() { + fun create() { AgenciesWithCoverageListParams.builder().build() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt index 56d8a08..9b28a54 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class AgencyRetrieveParamsTest { @Test - fun createAgencyRetrieveParams() { + fun create() { AgencyRetrieveParams.builder().agencyId("agencyID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt index 15676cb..26808dd 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt @@ -10,7 +10,7 @@ import org.onebusaway.core.http.QueryParams class ArrivalAndDepartureListParamsTest { @Test - fun createArrivalAndDepartureListParams() { + fun create() { ArrivalAndDepartureListParams.builder() .stopId("1_75403") .minutesAfter(0L) @@ -20,7 +20,7 @@ class ArrivalAndDepartureListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ArrivalAndDepartureListParams.builder() .stopId("1_75403") @@ -32,14 +32,14 @@ class ArrivalAndDepartureListParamsTest { expected.put("minutesAfter", "0") expected.put("minutesBefore", "0") expected.put("time", "2019-12-27T18:11:19.117Z") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ArrivalAndDepartureListParams.builder().stopId("1_75403").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt index af85193..37b7569 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class ArrivalAndDepartureRetrieveParamsTest { @Test - fun createArrivalAndDepartureRetrieveParams() { + fun create() { ArrivalAndDepartureRetrieveParams.builder() .stopId("1_75403") .serviceDate(0L) @@ -21,7 +21,7 @@ class ArrivalAndDepartureRetrieveParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ArrivalAndDepartureRetrieveParams.builder() .stopId("1_75403") @@ -37,11 +37,11 @@ class ArrivalAndDepartureRetrieveParamsTest { expected.put("stopSequence", "0") expected.put("time", "0") expected.put("vehicleId", "vehicleId") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ArrivalAndDepartureRetrieveParams.builder() .stopId("1_75403") @@ -51,7 +51,7 @@ class ArrivalAndDepartureRetrieveParamsTest { val expected = QueryParams.builder() expected.put("serviceDate", "0") expected.put("tripId", "tripId") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt index feb2888..e3d6b10 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class BlockRetrieveParamsTest { @Test - fun createBlockRetrieveParams() { + fun create() { BlockRetrieveParams.builder().blockId("blockID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt index 7d6183d..09c62a4 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class ConfigRetrieveParamsTest { @Test - fun createConfigRetrieveParams() { + fun create() { ConfigRetrieveParams.builder().build() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt index d8f5418..7045aac 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class CurrentTimeRetrieveParamsTest { @Test - fun createCurrentTimeRetrieveParams() { + fun create() { CurrentTimeRetrieveParams.builder().build() } } 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 f21fd6b..2eb893a 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 @@ -11,163 +11,130 @@ class ReferencesTest { fun createReferences() { val references = References.builder() - .agencies( - listOf( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) + .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() ) - .routes( - listOf( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") - .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() ) - .situations( - listOf( - References.Situation.builder() - .id("id") - .creationTime(0L) - .activeWindows( - listOf( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) - .build() - ) - ) - .allAffects( - listOf( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) - ) - .consequenceMessage("consequenceMessage") - .consequences( - listOf( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( + .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() - .diversionPath( - References.Situation.Consequence - .ConditionDetails - .DiversionPath - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .diversionStopIds(listOf("string")) + .length(0L) + .levels("levels") + .points("points") .build() ) + .addDiversionStopId("string") .build() ) - ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .publicationWindows( - listOf( - 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() - ) + .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() ) - .stops( - listOf( - References.Stop.builder() - .id("id") - .lat(0.0) - .lon(0.0) - .name("name") - .parent("parent") - .routeIds(listOf("string")) - .staticRouteIds(listOf("string")) - .code("code") - .direction("direction") - .locationType(0L) - .wheelchairBoarding("wheelchairBoarding") - .build() - ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .locationType(0L) + .wheelchairBoarding("wheelchairBoarding") + .build() ) - .stopTimes( - listOf( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() ) - .trips( - listOf( - 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() - ) + .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() assertThat(references).isNotNull @@ -206,42 +173,38 @@ class ReferencesTest { References.Situation.builder() .id("id") .creationTime(0L) - .activeWindows( - listOf(References.Situation.ActiveWindow.builder().from(0L).to(0L).build()) + .addActiveWindow( + References.Situation.ActiveWindow.builder().from(0L).to(0L).build() ) - .allAffects( - listOf( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) + .addAllAffect( + References.Situation.AllAffect.builder() + .agencyId("agencyId") + .applicationId("applicationId") + .directionId("directionId") + .routeId("routeId") + .stopId("stopId") + .tripId("tripId") + .build() ) .consequenceMessage("consequenceMessage") - .consequences( - listOf( - 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() - ) - .diversionStopIds(listOf("string")) - .build() - ) - .build() - ) + .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() @@ -249,10 +212,8 @@ class ReferencesTest { .value("value") .build() ) - .publicationWindows( - listOf( - References.Situation.PublicationWindow.builder().from(0L).to(0L).build() - ) + .addPublicationWindow( + References.Situation.PublicationWindow.builder().from(0L).to(0L).build() ) .reason(References.Situation.Reason.EQUIPMENT_REASON) .severity("severity") @@ -270,8 +231,8 @@ class ReferencesTest { .lon(0.0) .name("name") .parent("parent") - .routeIds(listOf("string")) - .staticRouteIds(listOf("string")) + .addRouteId("string") + .addStaticRouteId("string") .code("code") .direction("direction") .locationType(0L) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt index 9715973..a4a0191 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class ReportProblemWithStopRetrieveParamsTest { @Test - fun createReportProblemWithStopRetrieveParams() { + fun create() { ReportProblemWithStopRetrieveParams.builder() .stopId("stopID") .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) @@ -21,7 +21,7 @@ class ReportProblemWithStopRetrieveParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ReportProblemWithStopRetrieveParams.builder() .stopId("stopID") @@ -37,14 +37,14 @@ class ReportProblemWithStopRetrieveParamsTest { expected.put("userLat", "0.0") expected.put("userLocationAccuracy", "0.0") expected.put("userLon", "0.0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ReportProblemWithStopRetrieveParams.builder().stopId("stopID").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt index 6c00abc..45cbdba 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class ReportProblemWithTripRetrieveParamsTest { @Test - fun createReportProblemWithTripRetrieveParams() { + fun create() { ReportProblemWithTripRetrieveParams.builder() .tripId("tripID") .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) @@ -26,7 +26,7 @@ class ReportProblemWithTripRetrieveParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ReportProblemWithTripRetrieveParams.builder() .tripId("tripID") @@ -52,14 +52,14 @@ class ReportProblemWithTripRetrieveParamsTest { expected.put("userOnVehicle", "true") expected.put("userVehicleNumber", "userVehicleNumber") expected.put("vehicleID", "vehicleID") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ReportProblemWithTripRetrieveParams.builder().tripId("tripID").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt index 27815d0..6f4a70b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class RouteIdsForAgencyListParamsTest { @Test - fun createRouteIdsForAgencyListParams() { + fun create() { RouteIdsForAgencyListParams.builder().agencyId("agencyID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt index 2648eee..beb1604 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class RouteRetrieveParamsTest { @Test - fun createRouteRetrieveParams() { + fun create() { RouteRetrieveParams.builder().routeId("routeID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt index 25e5db1..c9c18f8 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class RoutesForAgencyListParamsTest { @Test - fun createRoutesForAgencyListParams() { + fun create() { RoutesForAgencyListParams.builder().agencyId("40").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt index 7ae2da5..895f0e8 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class RoutesForLocationListParamsTest { @Test - fun createRoutesForLocationListParams() { + fun create() { RoutesForLocationListParams.builder() .lat(0.0) .lon(0.0) @@ -21,7 +21,7 @@ class RoutesForLocationListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = RoutesForLocationListParams.builder() .lat(0.0) @@ -38,15 +38,15 @@ class RoutesForLocationListParamsTest { expected.put("lonSpan", "0.0") expected.put("query", "query") expected.put("radius", "0.0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = RoutesForLocationListParams.builder().lat(0.0).lon(0.0).build() val expected = QueryParams.builder() expected.put("lat", "0.0") expected.put("lon", "0.0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt index ad74668..75b741c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt @@ -10,7 +10,7 @@ import org.onebusaway.core.http.QueryParams class ScheduleForRouteRetrieveParamsTest { @Test - fun createScheduleForRouteRetrieveParams() { + fun create() { ScheduleForRouteRetrieveParams.builder() .routeId("1_100223") .date(LocalDate.parse("2019-12-27")) @@ -18,7 +18,7 @@ class ScheduleForRouteRetrieveParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ScheduleForRouteRetrieveParams.builder() .routeId("1_100223") @@ -26,14 +26,14 @@ class ScheduleForRouteRetrieveParamsTest { .build() val expected = QueryParams.builder() expected.put("date", "2019-12-27") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ScheduleForRouteRetrieveParams.builder().routeId("1_100223").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt index b70616d..a1704c2 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt @@ -10,7 +10,7 @@ import org.onebusaway.core.http.QueryParams class ScheduleForStopRetrieveParamsTest { @Test - fun createScheduleForStopRetrieveParams() { + fun create() { ScheduleForStopRetrieveParams.builder() .stopId("stopID") .date(LocalDate.parse("2019-12-27")) @@ -18,7 +18,7 @@ class ScheduleForStopRetrieveParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ScheduleForStopRetrieveParams.builder() .stopId("stopID") @@ -26,14 +26,14 @@ class ScheduleForStopRetrieveParamsTest { .build() val expected = QueryParams.builder() expected.put("date", "2019-12-27") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ScheduleForStopRetrieveParams.builder().stopId("stopID").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt index d75e481..0f323d3 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt @@ -9,24 +9,24 @@ import org.onebusaway.core.http.QueryParams class SearchForRouteListParamsTest { @Test - fun createSearchForRouteListParams() { + fun create() { SearchForRouteListParams.builder().input("input").maxCount(0L).build() } @Test - fun getQueryParams() { + fun queryParams() { val params = SearchForRouteListParams.builder().input("input").maxCount(0L).build() val expected = QueryParams.builder() expected.put("input", "input") expected.put("maxCount", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = SearchForRouteListParams.builder().input("input").build() val expected = QueryParams.builder() expected.put("input", "input") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt index 368c33b..2581cf1 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt @@ -9,24 +9,24 @@ import org.onebusaway.core.http.QueryParams class SearchForStopListParamsTest { @Test - fun createSearchForStopListParams() { + fun create() { SearchForStopListParams.builder().input("input").maxCount(0L).build() } @Test - fun getQueryParams() { + fun queryParams() { val params = SearchForStopListParams.builder().input("input").maxCount(0L).build() val expected = QueryParams.builder() expected.put("input", "input") expected.put("maxCount", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = SearchForStopListParams.builder().input("input").build() val expected = QueryParams.builder() expected.put("input", "input") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt index be4ffff..9ddb3bf 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class ShapeRetrieveParamsTest { @Test - fun createShapeRetrieveParams() { + fun create() { ShapeRetrieveParams.builder().shapeId("shapeID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt index 67d9e2b..e9f8805 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class StopIdsForAgencyListParamsTest { @Test - fun createStopIdsForAgencyListParams() { + fun create() { StopIdsForAgencyListParams.builder().agencyId("agencyID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt index 1c0577b..2ca4aab 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class StopRetrieveParamsTest { @Test - fun createStopRetrieveParams() { + fun create() { StopRetrieveParams.builder().stopId("stopID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt index 9a74b02..5df5004 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class StopsForAgencyListParamsTest { @Test - fun createStopsForAgencyListParams() { + fun create() { StopsForAgencyListParams.builder().agencyId("agencyID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt index e0f8bf1..e88198b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class StopsForLocationListParamsTest { @Test - fun createStopsForLocationListParams() { + fun create() { StopsForLocationListParams.builder() .lat(0.0) .lon(0.0) @@ -21,7 +21,7 @@ class StopsForLocationListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = StopsForLocationListParams.builder() .lat(0.0) @@ -38,15 +38,15 @@ class StopsForLocationListParamsTest { expected.put("lonSpan", "0.0") expected.put("query", "query") expected.put("radius", "0.0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = StopsForLocationListParams.builder().lat(0.0).lon(0.0).build() val expected = QueryParams.builder() expected.put("lat", "0.0") expected.put("lon", "0.0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt index 14c60aa..69c1b8f 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class StopsForRouteListParamsTest { @Test - fun createStopsForRouteListParams() { + fun create() { StopsForRouteListParams.builder() .routeId("routeID") .includePolylines(true) @@ -18,7 +18,7 @@ class StopsForRouteListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = StopsForRouteListParams.builder() .routeId("routeID") @@ -28,14 +28,14 @@ class StopsForRouteListParamsTest { val expected = QueryParams.builder() expected.put("includePolylines", "true") expected.put("time", "time") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = StopsForRouteListParams.builder().routeId("routeID").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt index e8d54bc..13efd64 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class TripDetailRetrieveParamsTest { @Test - fun createTripDetailRetrieveParams() { + fun create() { TripDetailRetrieveParams.builder() .tripId("tripID") .includeSchedule(true) @@ -21,7 +21,7 @@ class TripDetailRetrieveParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = TripDetailRetrieveParams.builder() .tripId("tripID") @@ -37,14 +37,14 @@ class TripDetailRetrieveParamsTest { expected.put("includeTrip", "true") expected.put("serviceDate", "0") expected.put("time", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = TripDetailRetrieveParams.builder().tripId("tripID").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt index 7ffc796..1792d80 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class TripForVehicleRetrieveParamsTest { @Test - fun createTripForVehicleRetrieveParams() { + fun create() { TripForVehicleRetrieveParams.builder() .vehicleId("vehicleID") .includeSchedule(true) @@ -20,7 +20,7 @@ class TripForVehicleRetrieveParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = TripForVehicleRetrieveParams.builder() .vehicleId("vehicleID") @@ -34,14 +34,14 @@ class TripForVehicleRetrieveParamsTest { expected.put("includeStatus", "true") expected.put("includeTrip", "true") expected.put("time", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = TripForVehicleRetrieveParams.builder().vehicleId("vehicleID").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt index 0bc7f7f..cd59a34 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class TripRetrieveParamsTest { @Test - fun createTripRetrieveParams() { + fun create() { TripRetrieveParams.builder().tripId("tripID").build() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt index c4eb862..d5df439 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class TripsForLocationListParamsTest { @Test - fun createTripsForLocationListParams() { + fun create() { TripsForLocationListParams.builder() .lat(0.0) .latSpan(0.0) @@ -22,7 +22,7 @@ class TripsForLocationListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = TripsForLocationListParams.builder() .lat(0.0) @@ -41,11 +41,11 @@ class TripsForLocationListParamsTest { expected.put("includeSchedule", "true") expected.put("includeTrip", "true") expected.put("time", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = TripsForLocationListParams.builder().lat(0.0).latSpan(0.0).lon(0.0).lonSpan(0.0).build() val expected = QueryParams.builder() @@ -53,6 +53,6 @@ class TripsForLocationListParamsTest { expected.put("latSpan", "0.0") expected.put("lon", "0.0") expected.put("lonSpan", "0.0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt index 43f6c77..85d5cea 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt @@ -9,7 +9,7 @@ import org.onebusaway.core.http.QueryParams class TripsForRouteListParamsTest { @Test - fun createTripsForRouteListParams() { + fun create() { TripsForRouteListParams.builder() .routeId("routeID") .includeSchedule(true) @@ -19,7 +19,7 @@ class TripsForRouteListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = TripsForRouteListParams.builder() .routeId("routeID") @@ -31,14 +31,14 @@ class TripsForRouteListParamsTest { expected.put("includeSchedule", "true") expected.put("includeStatus", "true") expected.put("time", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = TripsForRouteListParams.builder().routeId("routeID").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt index 4797643..cf6f7e1 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt @@ -9,23 +9,23 @@ import org.onebusaway.core.http.QueryParams class VehiclesForAgencyListParamsTest { @Test - fun createVehiclesForAgencyListParams() { + fun create() { VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() } @Test - fun getQueryParams() { + fun queryParams() { val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() val expected = QueryParams.builder() expected.put("time", "time") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt index 1162b3b..b97cc0b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt @@ -73,164 +73,144 @@ class ErrorHandlingTest { ) .references( References.builder() - .agencies( - listOf( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) + .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() ) - .routes( - listOf( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") - .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() ) - .situations( - listOf( - References.Situation.builder() - .id("id") - .creationTime(0L) - .activeWindows( - listOf( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) - .build() - ) - ) - .allAffects( - listOf( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) - ) - .consequenceMessage("consequenceMessage") - .consequences( - listOf( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( + .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() - .diversionPath( - References.Situation.Consequence - .ConditionDetails - .DiversionPath - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .diversionStopIds(listOf("string")) + .length(0L) + .levels("levels") + .points("points") .build() ) + .addDiversionStopId("string") .build() ) - ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .publicationWindows( - listOf( - 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() - ) + .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() ) - .stops( - listOf( - References.Stop.builder() - .id("id") - .lat(0.0) - .lon(0.0) - .name("name") - .parent("parent") - .routeIds(listOf("string")) - .staticRouteIds(listOf("string")) - .code("code") - .direction("direction") - .locationType(0L) - .wheelchairBoarding("wheelchairBoarding") - .build() - ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .locationType(0L) + .wheelchairBoarding("wheelchairBoarding") + .build() ) - .stopTimes( - listOf( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() ) - .trips( - listOf( - 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() - ) + .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/services/ServiceParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt index 34c128c..44bf670 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt @@ -69,164 +69,144 @@ class ServiceParamsTest { ) .references( References.builder() - .agencies( - listOf( - References.Agency.builder() - .id("id") - .name("name") - .timezone("timezone") - .url("url") - .disclaimer("disclaimer") - .email("email") - .fareUrl("fareUrl") - .lang("lang") - .phone("phone") - .privateService(true) - .build() - ) + .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() ) - .routes( - listOf( - References.Route.builder() - .id("id") - .agencyId("agencyId") - .type(0L) - .color("color") - .description("description") - .longName("longName") - .nullSafeShortName("nullSafeShortName") - .shortName("shortName") - .textColor("textColor") - .url("url") - .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() ) - .situations( - listOf( - References.Situation.builder() - .id("id") - .creationTime(0L) - .activeWindows( - listOf( - References.Situation.ActiveWindow.builder() - .from(0L) - .to(0L) - .build() - ) - ) - .allAffects( - listOf( - References.Situation.AllAffect.builder() - .agencyId("agencyId") - .applicationId("applicationId") - .directionId("directionId") - .routeId("routeId") - .stopId("stopId") - .tripId("tripId") - .build() - ) - ) - .consequenceMessage("consequenceMessage") - .consequences( - listOf( - References.Situation.Consequence.builder() - .condition("condition") - .conditionDetails( + .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() - .diversionPath( - References.Situation.Consequence - .ConditionDetails - .DiversionPath - .builder() - .length(0L) - .levels("levels") - .points("points") - .build() - ) - .diversionStopIds(listOf("string")) + .length(0L) + .levels("levels") + .points("points") .build() ) + .addDiversionStopId("string") .build() ) - ) - .description( - References.Situation.Description.builder() - .lang("lang") - .value("value") - .build() - ) - .publicationWindows( - listOf( - 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() - ) + .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() ) - .stops( - listOf( - References.Stop.builder() - .id("id") - .lat(0.0) - .lon(0.0) - .name("name") - .parent("parent") - .routeIds(listOf("string")) - .staticRouteIds(listOf("string")) - .code("code") - .direction("direction") - .locationType(0L) - .wheelchairBoarding("wheelchairBoarding") - .build() - ) + .addStop( + References.Stop.builder() + .id("id") + .lat(0.0) + .lon(0.0) + .name("name") + .parent("parent") + .addRouteId("string") + .addStaticRouteId("string") + .code("code") + .direction("direction") + .locationType(0L) + .wheelchairBoarding("wheelchairBoarding") + .build() ) - .stopTimes( - listOf( - References.StopTime.builder() - .arrivalTime(0L) - .departureTime(0L) - .distanceAlongTrip(0.0) - .historicalOccupancy("historicalOccupancy") - .stopHeadsign("stopHeadsign") - .stopId("stopId") - .build() - ) + .addStopTime( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() ) - .trips( - listOf( - 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() - ) + .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() ) From 51a4c8cab3782706a773525083c4b17da4543064 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Feb 2025 11:22:15 +0000 Subject: [PATCH 08/11] chore(internal): codegen related update (#78) --- .../core/http/PhantomReachableClosingHttpClient.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt index f923a21..756f8a2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt @@ -4,6 +4,11 @@ import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions import org.onebusaway.core.closeWhenPhantomReachable +/** + * A delegating wrapper around an `HttpClient` that closes it once it's only phantom reachable. + * + * This class ensures the `HttpClient` is closed even if the user forgets to close it. + */ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { init { closeWhenPhantomReachable(this, httpClient) From a9266bd3053952157431e4aee9b36aae6b637164 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 17 May 2025 13:47:25 +0000 Subject: [PATCH 09/11] feat(api): api update --- .stats.yml | 2 +- .../org/onebusaway/models/References.kt | 45 +++++++++---------- .../ScheduleForRouteRetrieveResponse.kt | 45 +++++++++---------- .../models/SearchForStopListResponse.kt | 45 +++++++++---------- .../onebusaway/models/StopRetrieveResponse.kt | 45 +++++++++---------- .../models/StopsForAgencyListResponse.kt | 45 +++++++++---------- .../models/StopsForLocationListResponse.kt | 45 +++++++++---------- .../org/onebusaway/models/ReferencesTest.kt | 4 +- .../onebusaway/services/ErrorHandlingTest.kt | 2 +- .../onebusaway/services/ServiceParamsTest.kt | 2 +- 10 files changed, 137 insertions(+), 143 deletions(-) diff --git a/.stats.yml b/.stats.yml index d4b713b..3928277 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-6f08502508c8ad25235971add3124a1cde4f1c3ec705d5df455d750e0adcb90b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-4fcbe9547537b22a2d68329e1d94e0c1a6f81b5af734ca213f7b95eef5da7adb.yml 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 3f3b947..b855db0 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 @@ -2466,6 +2466,9 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing @@ -2485,9 +2488,6 @@ private constructor( @JsonProperty("direction") @ExcludeMissing private val direction: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -2499,6 +2499,8 @@ private constructor( fun lat(): Double = lat.getRequired("lat") + fun locationType(): Long = locationType.getRequired("locationType") + fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -2513,9 +2515,6 @@ private constructor( fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) @@ -2523,6 +2522,10 @@ private constructor( @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -2541,10 +2544,6 @@ private constructor( @JsonProperty("direction") @ExcludeMissing fun _direction(): JsonField = direction - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - @JsonProperty("wheelchairBoarding") @ExcludeMissing fun _wheelchairBoarding(): JsonField = wheelchairBoarding @@ -2562,6 +2561,7 @@ private constructor( id() lat() + locationType() lon() name() parent() @@ -2569,7 +2569,6 @@ private constructor( staticRouteIds() code() direction() - locationType() wheelchairBoarding() validated = true } @@ -2586,6 +2585,7 @@ private 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 @@ -2593,7 +2593,6 @@ private constructor( private var staticRouteIds: JsonField>? = null private var code: JsonField = JsonMissing.of() private var direction: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2601,6 +2600,7 @@ private constructor( internal fun from(stop: Stop) = apply { id = stop.id lat = stop.lat + locationType = stop.locationType lon = stop.lon name = stop.name parent = stop.parent @@ -2608,7 +2608,6 @@ private constructor( staticRouteIds = stop.staticRouteIds.map { it.toMutableList() } code = stop.code direction = stop.direction - locationType = stop.locationType wheelchairBoarding = stop.wheelchairBoarding additionalProperties = stop.additionalProperties.toMutableMap() } @@ -2621,6 +2620,12 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -2680,12 +2685,6 @@ private constructor( fun direction(direction: JsonField) = apply { this.direction = direction } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) @@ -2716,6 +2715,7 @@ private constructor( Stop( checkRequired("id", id), checkRequired("lat", lat), + checkRequired("locationType", locationType), checkRequired("lon", lon), checkRequired("name", name), checkRequired("parent", parent), @@ -2723,7 +2723,6 @@ private constructor( checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - locationType, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -2734,17 +2733,17 @@ private constructor( return true } - return /* spotless:off */ other is Stop && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Stop{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "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}" } @NoAutoDetect diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt index be77b8a..f686c9f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt @@ -475,6 +475,9 @@ private constructor( @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @@ -496,9 +499,6 @@ private constructor( @JsonProperty("direction") @ExcludeMissing private val direction: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -510,6 +510,8 @@ private constructor( fun lat(): Double = lat.getRequired("lat") + fun locationType(): Long = locationType.getRequired("locationType") + fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -525,9 +527,6 @@ private constructor( fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) @@ -535,6 +534,10 @@ private constructor( @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -555,10 +558,6 @@ private constructor( @ExcludeMissing fun _direction(): JsonField = direction - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - @JsonProperty("wheelchairBoarding") @ExcludeMissing fun _wheelchairBoarding(): JsonField = wheelchairBoarding @@ -576,6 +575,7 @@ private constructor( id() lat() + locationType() lon() name() parent() @@ -583,7 +583,6 @@ private constructor( staticRouteIds() code() direction() - locationType() wheelchairBoarding() validated = true } @@ -600,6 +599,7 @@ private 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 @@ -607,7 +607,6 @@ private constructor( private var staticRouteIds: JsonField>? = null private var code: JsonField = JsonMissing.of() private var direction: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -615,6 +614,7 @@ private constructor( internal fun from(stop: Stop) = apply { id = stop.id lat = stop.lat + locationType = stop.locationType lon = stop.lon name = stop.name parent = stop.parent @@ -622,7 +622,6 @@ private constructor( staticRouteIds = stop.staticRouteIds.map { it.toMutableList() } code = stop.code direction = stop.direction - locationType = stop.locationType wheelchairBoarding = stop.wheelchairBoarding additionalProperties = stop.additionalProperties.toMutableMap() } @@ -635,6 +634,12 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -696,12 +701,6 @@ private constructor( this.direction = direction } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) @@ -735,6 +734,7 @@ private constructor( Stop( checkRequired("id", id), checkRequired("lat", lat), + checkRequired("locationType", locationType), checkRequired("lon", lon), checkRequired("name", name), checkRequired("parent", parent), @@ -744,7 +744,6 @@ private constructor( }, code, direction, - locationType, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -755,17 +754,17 @@ private constructor( return true } - return /* spotless:off */ other is Stop && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Stop{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "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}" } @NoAutoDetect diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt index ef89eff..ad7f970 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt @@ -318,6 +318,9 @@ private constructor( @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @@ -340,9 +343,6 @@ private constructor( @JsonProperty("direction") @ExcludeMissing private val direction: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -354,6 +354,8 @@ private constructor( fun lat(): Double = lat.getRequired("lat") + fun locationType(): Long = locationType.getRequired("locationType") + fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -370,9 +372,6 @@ private constructor( fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) @@ -380,6 +379,10 @@ private constructor( @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -400,10 +403,6 @@ private constructor( @ExcludeMissing fun _direction(): JsonField = direction - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - @JsonProperty("wheelchairBoarding") @ExcludeMissing fun _wheelchairBoarding(): JsonField = wheelchairBoarding @@ -421,6 +420,7 @@ private constructor( id() lat() + locationType() lon() name() parent() @@ -428,7 +428,6 @@ private constructor( staticRouteIds() code() direction() - locationType() wheelchairBoarding() validated = true } @@ -445,6 +444,7 @@ private 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 @@ -452,7 +452,6 @@ private constructor( private var staticRouteIds: JsonField>? = null private var code: JsonField = JsonMissing.of() private var direction: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -460,6 +459,7 @@ private constructor( internal fun from(list: List) = apply { id = list.id lat = list.lat + locationType = list.locationType lon = list.lon name = list.name parent = list.parent @@ -467,7 +467,6 @@ private constructor( staticRouteIds = list.staticRouteIds.map { it.toMutableList() } code = list.code direction = list.direction - locationType = list.locationType wheelchairBoarding = list.wheelchairBoarding additionalProperties = list.additionalProperties.toMutableMap() } @@ -480,6 +479,12 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -541,12 +546,6 @@ private constructor( fun direction(direction: JsonField) = apply { this.direction = direction } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) @@ -580,6 +579,7 @@ private constructor( List( checkRequired("id", id), checkRequired("lat", lat), + checkRequired("locationType", locationType), checkRequired("lon", lon), checkRequired("name", name), checkRequired("parent", parent), @@ -587,7 +587,6 @@ private constructor( checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - locationType, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -598,17 +597,17 @@ private constructor( return true } - return /* spotless:off */ other is List && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "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 { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt index 1650ec1..5de09a5 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt @@ -265,6 +265,9 @@ private constructor( @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @@ -286,9 +289,6 @@ private constructor( @JsonProperty("direction") @ExcludeMissing private val direction: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -300,6 +300,8 @@ private constructor( fun lat(): Double = lat.getRequired("lat") + fun locationType(): Long = locationType.getRequired("locationType") + fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -315,9 +317,6 @@ private constructor( fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) @@ -325,6 +324,10 @@ private constructor( @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -345,10 +348,6 @@ private constructor( @ExcludeMissing fun _direction(): JsonField = direction - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - @JsonProperty("wheelchairBoarding") @ExcludeMissing fun _wheelchairBoarding(): JsonField = wheelchairBoarding @@ -366,6 +365,7 @@ private constructor( id() lat() + locationType() lon() name() parent() @@ -373,7 +373,6 @@ private constructor( staticRouteIds() code() direction() - locationType() wheelchairBoarding() validated = true } @@ -390,6 +389,7 @@ private 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 @@ -397,7 +397,6 @@ private constructor( private var staticRouteIds: JsonField>? = null private var code: JsonField = JsonMissing.of() private var direction: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -405,6 +404,7 @@ private constructor( internal fun from(entry: Entry) = apply { id = entry.id lat = entry.lat + locationType = entry.locationType lon = entry.lon name = entry.name parent = entry.parent @@ -412,7 +412,6 @@ private constructor( staticRouteIds = entry.staticRouteIds.map { it.toMutableList() } code = entry.code direction = entry.direction - locationType = entry.locationType wheelchairBoarding = entry.wheelchairBoarding additionalProperties = entry.additionalProperties.toMutableMap() } @@ -425,6 +424,12 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -484,12 +489,6 @@ private constructor( fun direction(direction: JsonField) = apply { this.direction = direction } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) @@ -523,6 +522,7 @@ private constructor( Entry( checkRequired("id", id), checkRequired("lat", lat), + checkRequired("locationType", locationType), checkRequired("lon", lon), checkRequired("name", name), checkRequired("parent", parent), @@ -530,7 +530,6 @@ private constructor( checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - locationType, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -541,17 +540,17 @@ private constructor( return true } - return /* spotless:off */ other is Entry && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Entry && 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Entry{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "Entry{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 { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt index 0e16b9a..e78c5d8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt @@ -233,6 +233,9 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing @@ -252,9 +255,6 @@ private constructor( @JsonProperty("direction") @ExcludeMissing private val direction: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -266,6 +266,8 @@ private constructor( fun lat(): Double = lat.getRequired("lat") + fun locationType(): Long = locationType.getRequired("locationType") + fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -281,9 +283,6 @@ private constructor( fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) @@ -291,6 +290,10 @@ private constructor( @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -309,10 +312,6 @@ private constructor( @JsonProperty("direction") @ExcludeMissing fun _direction(): JsonField = direction - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - @JsonProperty("wheelchairBoarding") @ExcludeMissing fun _wheelchairBoarding(): JsonField = wheelchairBoarding @@ -330,6 +329,7 @@ private constructor( id() lat() + locationType() lon() name() parent() @@ -337,7 +337,6 @@ private constructor( staticRouteIds() code() direction() - locationType() wheelchairBoarding() validated = true } @@ -354,6 +353,7 @@ private 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 @@ -361,7 +361,6 @@ private constructor( private var staticRouteIds: JsonField>? = null private var code: JsonField = JsonMissing.of() private var direction: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -369,6 +368,7 @@ private constructor( internal fun from(list: List) = apply { id = list.id lat = list.lat + locationType = list.locationType lon = list.lon name = list.name parent = list.parent @@ -376,7 +376,6 @@ private constructor( staticRouteIds = list.staticRouteIds.map { it.toMutableList() } code = list.code direction = list.direction - locationType = list.locationType wheelchairBoarding = list.wheelchairBoarding additionalProperties = list.additionalProperties.toMutableMap() } @@ -389,6 +388,12 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -449,12 +454,6 @@ private constructor( fun direction(direction: JsonField) = apply { this.direction = direction } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) @@ -485,6 +484,7 @@ private constructor( List( checkRequired("id", id), checkRequired("lat", lat), + checkRequired("locationType", locationType), checkRequired("lon", lon), checkRequired("name", name), checkRequired("parent", parent), @@ -492,7 +492,6 @@ private constructor( checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - locationType, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -503,17 +502,17 @@ private constructor( return true } - return /* spotless:off */ other is List && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "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 { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt index 6a8b14c..5fc7409 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt @@ -319,6 +319,9 @@ private constructor( @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + private val locationType: JsonField = JsonMissing.of(), @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), @@ -341,9 +344,6 @@ private constructor( @JsonProperty("direction") @ExcludeMissing private val direction: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), @JsonProperty("wheelchairBoarding") @ExcludeMissing private val wheelchairBoarding: JsonField = JsonMissing.of(), @@ -355,6 +355,8 @@ private constructor( fun lat(): Double = lat.getRequired("lat") + fun locationType(): Long = locationType.getRequired("locationType") + fun lon(): Double = lon.getRequired("lon") fun name(): String = name.getRequired("name") @@ -371,9 +373,6 @@ private constructor( fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - fun locationType(): Optional = - Optional.ofNullable(locationType.getNullable("locationType")) - fun wheelchairBoarding(): Optional = Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) @@ -381,6 +380,10 @@ private constructor( @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + @JsonProperty("locationType") + @ExcludeMissing + fun _locationType(): JsonField = locationType + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -401,10 +404,6 @@ private constructor( @ExcludeMissing fun _direction(): JsonField = direction - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - @JsonProperty("wheelchairBoarding") @ExcludeMissing fun _wheelchairBoarding(): JsonField = wheelchairBoarding @@ -422,6 +421,7 @@ private constructor( id() lat() + locationType() lon() name() parent() @@ -429,7 +429,6 @@ private constructor( staticRouteIds() code() direction() - locationType() wheelchairBoarding() validated = true } @@ -446,6 +445,7 @@ private 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 @@ -453,7 +453,6 @@ private constructor( private var staticRouteIds: JsonField>? = null private var code: JsonField = JsonMissing.of() private var direction: JsonField = JsonMissing.of() - private var locationType: JsonField = JsonMissing.of() private var wheelchairBoarding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -461,6 +460,7 @@ private constructor( internal fun from(list: List) = apply { id = list.id lat = list.lat + locationType = list.locationType lon = list.lon name = list.name parent = list.parent @@ -468,7 +468,6 @@ private constructor( staticRouteIds = list.staticRouteIds.map { it.toMutableList() } code = list.code direction = list.direction - locationType = list.locationType wheelchairBoarding = list.wheelchairBoarding additionalProperties = list.additionalProperties.toMutableMap() } @@ -481,6 +480,12 @@ private constructor( fun lat(lat: JsonField) = apply { this.lat = lat } + fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) + + fun locationType(locationType: JsonField) = apply { + this.locationType = locationType + } + fun lon(lon: Double) = lon(JsonField.of(lon)) fun lon(lon: JsonField) = apply { this.lon = lon } @@ -542,12 +547,6 @@ private constructor( fun direction(direction: JsonField) = apply { this.direction = direction } - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - fun wheelchairBoarding(wheelchairBoarding: String) = wheelchairBoarding(JsonField.of(wheelchairBoarding)) @@ -581,6 +580,7 @@ private constructor( List( checkRequired("id", id), checkRequired("lat", lat), + checkRequired("locationType", locationType), checkRequired("lon", lon), checkRequired("name", name), checkRequired("parent", parent), @@ -588,7 +588,6 @@ private constructor( checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, code, direction, - locationType, wheelchairBoarding, additionalProperties.toImmutable(), ) @@ -599,17 +598,17 @@ private constructor( return true } - return /* spotless:off */ other is List && id == other.id && lat == other.lat && lon == other.lon && name == other.name && parent == other.parent && routeIds == other.routeIds && staticRouteIds == other.staticRouteIds && code == other.code && direction == other.direction && locationType == other.locationType && wheelchairBoarding == other.wheelchairBoarding && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, lon, name, parent, routeIds, staticRouteIds, code, direction, locationType, wheelchairBoarding, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "List{id=$id, lat=$lat, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, locationType=$locationType, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + "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 { 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 2eb893a..7111a2c 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 @@ -100,6 +100,7 @@ class ReferencesTest { References.Stop.builder() .id("id") .lat(0.0) + .locationType(0L) .lon(0.0) .name("name") .parent("parent") @@ -107,7 +108,6 @@ class ReferencesTest { .addStaticRouteId("string") .code("code") .direction("direction") - .locationType(0L) .wheelchairBoarding("wheelchairBoarding") .build() ) @@ -228,6 +228,7 @@ class ReferencesTest { References.Stop.builder() .id("id") .lat(0.0) + .locationType(0L) .lon(0.0) .name("name") .parent("parent") @@ -235,7 +236,6 @@ class ReferencesTest { .addStaticRouteId("string") .code("code") .direction("direction") - .locationType(0L) .wheelchairBoarding("wheelchairBoarding") .build() ) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt index b97cc0b..5b505b3 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt @@ -176,6 +176,7 @@ class ErrorHandlingTest { References.Stop.builder() .id("id") .lat(0.0) + .locationType(0L) .lon(0.0) .name("name") .parent("parent") @@ -183,7 +184,6 @@ class ErrorHandlingTest { .addStaticRouteId("string") .code("code") .direction("direction") - .locationType(0L) .wheelchairBoarding("wheelchairBoarding") .build() ) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt index 44bf670..b16e585 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt @@ -172,6 +172,7 @@ class ServiceParamsTest { References.Stop.builder() .id("id") .lat(0.0) + .locationType(0L) .lon(0.0) .name("name") .parent("parent") @@ -179,7 +180,6 @@ class ServiceParamsTest { .addStaticRouteId("string") .code("code") .direction("direction") - .locationType(0L) .wheelchairBoarding("wheelchairBoarding") .build() ) From 8f6f893129b9b061d933432fc8ecc36be5e5ad7f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 7 Jul 2025 23:33:27 +0000 Subject: [PATCH 10/11] chore(internal): codegen related update --- .github/workflows/ci.yml | 30 +- .github/workflows/publish-sonatype.yml | 2 +- .gitignore | 1 + .stats.yml | 2 + README.md | 471 +- SECURITY.md | 4 +- build.gradle.kts | 19 + buildSrc/build.gradle.kts | 6 +- .../kotlin/onebusaway-sdk.java.gradle.kts | 11 +- .../kotlin/onebusaway-sdk.kotlin.gradle.kts | 32 +- .../kotlin/onebusaway-sdk.publish.gradle.kts | 8 + gradle.properties | 17 +- .../onebusaway/client/okhttp/OkHttpClient.kt | 36 +- .../okhttp/OnebusawaySdkOkHttpClient.kt | 43 +- .../okhttp/OnebusawaySdkOkHttpClientAsync.kt | 44 +- onebusaway-sdk-java-core/build.gradle.kts | 27 +- .../onebusaway/client/OnebusawaySdkClient.kt | 67 + .../client/OnebusawaySdkClientAsync.kt | 68 + .../client/OnebusawaySdkClientAsyncImpl.kt | 198 +- .../client/OnebusawaySdkClientImpl.kt | 189 +- .../org/onebusaway/core/BaseDeserializer.kt | 33 +- .../main/kotlin/org/onebusaway/core/Check.kt | 67 + .../org/onebusaway/core/ClientOptions.kt | 53 +- .../org/onebusaway/core/HttpRequestBodies.kt | 111 - .../org/onebusaway/core/ObjectMappers.kt | 152 +- .../org/onebusaway/core/PrepareRequest.kt | 2 +- .../org/onebusaway/core/RequestOptions.kt | 37 +- .../kotlin/org/onebusaway/core/Timeout.kt | 167 + .../main/kotlin/org/onebusaway/core/Utils.kt | 64 + .../main/kotlin/org/onebusaway/core/Values.kt | 493 +- .../onebusaway/core/handlers/ErrorHandler.kt | 151 +- .../onebusaway/core/handlers/JsonHandler.kt | 9 +- .../core/http/AsyncStreamResponse.kt | 157 + .../org/onebusaway/core/http/Headers.kt | 4 +- .../org/onebusaway/core/http/HttpClient.kt | 12 +- .../onebusaway/core/http/HttpRequestBodies.kt | 106 + .../onebusaway/core/http/HttpRequestBody.kt | 4 +- .../org/onebusaway/core/http/HttpResponse.kt | 6 +- .../onebusaway/core/http/HttpResponseFor.kt | 25 + ...ntomReachableClosingAsyncStreamResponse.kt | 56 + .../http/PhantomReachableClosingHttpClient.kt | 2 +- .../PhantomReachableClosingStreamResponse.kt | 21 + .../org/onebusaway/core/http/QueryParams.kt | 4 +- .../core/http/RetryingHttpClient.kt | 69 +- .../onebusaway/core/http/StreamResponse.kt | 19 + .../onebusaway/errors/BadRequestException.kt | 81 +- .../errors/InternalServerException.kt | 93 +- .../onebusaway/errors/NotFoundException.kt | 77 +- .../onebusaway/errors/OnebusawaySdkError.kt | 76 - .../errors/OnebusawaySdkServiceException.kt | 22 +- .../errors/PermissionDeniedException.kt | 81 +- .../onebusaway/errors/RateLimitException.kt | 81 +- .../errors/UnauthorizedException.kt | 81 +- .../errors/UnexpectedStatusCodeException.kt | 94 +- .../errors/UnprocessableEntityException.kt | 81 +- .../AgenciesWithCoverageListResponse.kt | 489 -- .../models/AgencyRetrieveResponse.kt | 557 --- .../models/ArrivalAndDepartureListResponse.kt | 2589 ---------- .../ArrivalAndDepartureRetrieveResponse.kt | 2390 ---------- .../models/BlockRetrieveResponse.kt | 1153 ----- .../models/ConfigRetrieveResponse.kt | 975 ---- .../models/CurrentTimeRetrieveResponse.kt | 412 -- .../org/onebusaway/models/References.kt | 4060 ++++++++++++---- .../org/onebusaway/models/ResponseWrapper.kt | 176 +- .../models/RouteIdsForAgencyListResponse.kt | 325 -- .../models/RouteRetrieveResponse.kt | 544 --- .../models/RoutesForAgencyListResponse.kt | 580 --- .../models/RoutesForLocationListResponse.kt | 597 --- .../ScheduleForRouteRetrieveResponse.kt | 1727 ------- .../models/ScheduleForStopRetrieveResponse.kt | 1214 ----- .../models/SearchForRouteListResponse.kt | 597 --- .../models/SearchForStopListResponse.kt | 647 --- .../models/ShapeRetrieveResponse.kt | 426 -- .../models/StopIdsForAgencyListResponse.kt | 325 -- .../onebusaway/models/StopRetrieveResponse.kt | 590 --- .../models/StopsForAgencyListResponse.kt | 534 --- .../models/StopsForLocationListResponse.kt | 648 --- .../models/StopsForRouteListResponse.kt | 1089 ----- .../models/TripDetailRetrieveResponse.kt | 1990 -------- .../models/TripForVehicleRetrieveResponse.kt | 1991 -------- .../onebusaway/models/TripRetrieveResponse.kt | 571 --- .../models/TripsForLocationListResponse.kt | 2056 -------- .../models/TripsForRouteListResponse.kt | 2031 -------- .../models/VehiclesForAgencyListResponse.kt | 1819 ------- .../AgenciesWithCoverageListParams.kt | 23 +- .../AgenciesWithCoverageListResponse.kt | 876 ++++ .../{ => agency}/AgencyRetrieveParams.kt | 51 +- .../models/agency/AgencyRetrieveResponse.kt | 1031 ++++ .../ArrivalAndDepartureListParams.kt | 94 +- .../ArrivalAndDepartureListResponse.kt | 4174 +++++++++++++++++ .../ArrivalAndDepartureRetrieveParams.kt | 101 +- .../ArrivalAndDepartureRetrieveResponse.kt | 3922 ++++++++++++++++ .../models/{ => block}/BlockRetrieveParams.kt | 51 +- .../models/block/BlockRetrieveResponse.kt | 1985 ++++++++ .../{ => config}/ConfigRetrieveParams.kt | 20 +- .../models/config/ConfigRetrieveResponse.kt | 1731 +++++++ .../CurrentTimeRetrieveParams.kt | 22 +- .../CurrentTimeRetrieveResponse.kt | 689 +++ .../ReportProblemWithStopRetrieveParams.kt | 195 +- .../ReportProblemWithTripRetrieveParams.kt | 240 +- .../models/{ => route}/RouteRetrieveParams.kt | 51 +- .../models/route/RouteRetrieveResponse.kt | 1000 ++++ .../RouteIdsForAgencyListParams.kt | 49 +- .../RouteIdsForAgencyListResponse.kt | 566 +++ .../RoutesForAgencyListParams.kt | 49 +- .../RoutesForAgencyListResponse.kt | 1060 +++++ .../RoutesForLocationListParams.kt | 86 +- .../RoutesForLocationListResponse.kt | 1098 +++++ .../ScheduleForRouteRetrieveParams.kt | 67 +- .../ScheduleForRouteRetrieveResponse.kt | 3102 ++++++++++++ .../ScheduleForStopRetrieveParams.kt | 67 +- .../ScheduleForStopRetrieveResponse.kt | 2122 +++++++++ .../SearchForRouteListParams.kt | 57 +- .../SearchForRouteListResponse.kt | 1095 +++++ .../SearchForStopListParams.kt | 57 +- .../SearchForStopListResponse.kt | 1175 +++++ .../models/{ => shape}/ShapeRetrieveParams.kt | 51 +- .../models/shape/ShapeRetrieveResponse.kt | 741 +++ .../models/{ => stop}/StopRetrieveParams.kt | 51 +- .../models/stop/StopRetrieveResponse.kt | 1079 +++++ .../StopIdsForAgencyListParams.kt | 49 +- .../StopIdsForAgencyListResponse.kt | 565 +++ .../StopsForAgencyListParams.kt | 47 +- .../StopsForAgencyListResponse.kt | 1005 ++++ .../StopsForLocationListParams.kt | 93 +- .../StopsForLocationListResponse.kt | 1175 +++++ .../StopsForRouteListParams.kt | 74 +- .../StopsForRouteListResponse.kt | 1753 +++++++ .../models/{ => trip}/TripRetrieveParams.kt | 51 +- .../models/trip/TripRetrieveResponse.kt | 1051 +++++ .../TripDetailRetrieveParams.kt | 124 +- .../tripdetails/TripDetailRetrieveResponse.kt | 3317 +++++++++++++ .../TripForVehicleRetrieveParams.kt | 116 +- .../TripForVehicleRetrieveResponse.kt | 3319 +++++++++++++ .../TripsForLocationListParams.kt | 128 +- .../TripsForLocationListResponse.kt | 3428 ++++++++++++++ .../TripsForRouteListParams.kt | 96 +- .../TripsForRouteListResponse.kt | 3387 +++++++++++++ .../VehiclesForAgencyListParams.kt | 63 +- .../VehiclesForAgencyListResponse.kt | 3052 ++++++++++++ .../async/AgenciesWithCoverageServiceAsync.kt | 67 +- .../AgenciesWithCoverageServiceAsyncImpl.kt | 81 +- .../services/async/AgencyServiceAsync.kt | 98 +- .../services/async/AgencyServiceAsyncImpl.kt | 83 +- .../async/ArrivalAndDepartureServiceAsync.kt | 167 +- .../ArrivalAndDepartureServiceAsyncImpl.kt | 169 +- .../services/async/BlockServiceAsync.kt | 96 +- .../services/async/BlockServiceAsyncImpl.kt | 83 +- .../services/async/ConfigServiceAsync.kt | 66 +- .../services/async/ConfigServiceAsyncImpl.kt | 78 +- .../services/async/CurrentTimeServiceAsync.kt | 67 +- .../async/CurrentTimeServiceAsyncImpl.kt | 79 +- .../ReportProblemWithStopServiceAsync.kt | 98 +- .../ReportProblemWithStopServiceAsyncImpl.kt | 89 +- .../ReportProblemWithTripServiceAsync.kt | 98 +- .../ReportProblemWithTripServiceAsyncImpl.kt | 89 +- .../async/RouteIdsForAgencyServiceAsync.kt | 103 +- .../RouteIdsForAgencyServiceAsyncImpl.kt | 92 +- .../services/async/RouteServiceAsync.kt | 96 +- .../services/async/RouteServiceAsyncImpl.kt | 83 +- .../async/RoutesForAgencyServiceAsync.kt | 102 +- .../async/RoutesForAgencyServiceAsyncImpl.kt | 92 +- .../async/RoutesForLocationServiceAsync.kt | 45 +- .../RoutesForLocationServiceAsyncImpl.kt | 77 +- .../async/ScheduleForRouteServiceAsync.kt | 103 +- .../async/ScheduleForRouteServiceAsyncImpl.kt | 92 +- .../async/ScheduleForStopServiceAsync.kt | 103 +- .../async/ScheduleForStopServiceAsyncImpl.kt | 92 +- .../async/SearchForRouteServiceAsync.kt | 44 +- .../async/SearchForRouteServiceAsyncImpl.kt | 77 +- .../async/SearchForStopServiceAsync.kt | 44 +- .../async/SearchForStopServiceAsyncImpl.kt | 79 +- .../services/async/ShapeServiceAsync.kt | 96 +- .../services/async/ShapeServiceAsyncImpl.kt | 83 +- .../async/StopIdsForAgencyServiceAsync.kt | 102 +- .../async/StopIdsForAgencyServiceAsyncImpl.kt | 92 +- .../services/async/StopServiceAsync.kt | 96 +- .../services/async/StopServiceAsyncImpl.kt | 83 +- .../async/StopsForAgencyServiceAsync.kt | 99 +- .../async/StopsForAgencyServiceAsyncImpl.kt | 92 +- .../async/StopsForLocationServiceAsync.kt | 44 +- .../async/StopsForLocationServiceAsyncImpl.kt | 77 +- .../async/StopsForRouteServiceAsync.kt | 99 +- .../async/StopsForRouteServiceAsyncImpl.kt | 94 +- .../services/async/TripDetailServiceAsync.kt | 102 +- .../async/TripDetailServiceAsyncImpl.kt | 84 +- .../async/TripForVehicleServiceAsync.kt | 103 +- .../async/TripForVehicleServiceAsyncImpl.kt | 92 +- .../services/async/TripServiceAsync.kt | 96 +- .../services/async/TripServiceAsyncImpl.kt | 83 +- .../async/TripsForLocationServiceAsync.kt | 44 +- .../async/TripsForLocationServiceAsyncImpl.kt | 77 +- .../async/TripsForRouteServiceAsync.kt | 99 +- .../async/TripsForRouteServiceAsyncImpl.kt | 94 +- .../async/VehiclesForAgencyServiceAsync.kt | 103 +- .../VehiclesForAgencyServiceAsyncImpl.kt | 92 +- .../blocking/AgenciesWithCoverageService.kt | 65 +- .../AgenciesWithCoverageServiceImpl.kt | 74 +- .../services/blocking/AgencyService.kt | 91 +- .../services/blocking/AgencyServiceImpl.kt | 77 +- .../blocking/ArrivalAndDepartureService.kt | 156 +- .../ArrivalAndDepartureServiceImpl.kt | 156 +- .../services/blocking/BlockService.kt | 89 +- .../services/blocking/BlockServiceImpl.kt | 77 +- .../services/blocking/ConfigService.kt | 60 +- .../services/blocking/ConfigServiceImpl.kt | 72 +- .../services/blocking/CurrentTimeService.kt | 62 +- .../blocking/CurrentTimeServiceImpl.kt | 73 +- .../blocking/ReportProblemWithStopService.kt | 92 +- .../ReportProblemWithStopServiceImpl.kt | 82 +- .../blocking/ReportProblemWithTripService.kt | 92 +- .../ReportProblemWithTripServiceImpl.kt | 82 +- .../blocking/RouteIdsForAgencyService.kt | 95 +- .../blocking/RouteIdsForAgencyServiceImpl.kt | 88 +- .../services/blocking/RouteService.kt | 89 +- .../services/blocking/RouteServiceImpl.kt | 77 +- .../blocking/RoutesForAgencyService.kt | 94 +- .../blocking/RoutesForAgencyServiceImpl.kt | 88 +- .../blocking/RoutesForLocationService.kt | 43 +- .../blocking/RoutesForLocationServiceImpl.kt | 73 +- .../blocking/ScheduleForRouteService.kt | 99 +- .../blocking/ScheduleForRouteServiceImpl.kt | 88 +- .../blocking/ScheduleForStopService.kt | 96 +- .../blocking/ScheduleForStopServiceImpl.kt | 88 +- .../blocking/SearchForRouteService.kt | 41 +- .../blocking/SearchForRouteServiceImpl.kt | 73 +- .../services/blocking/SearchForStopService.kt | 41 +- .../blocking/SearchForStopServiceImpl.kt | 73 +- .../services/blocking/ShapeService.kt | 89 +- .../services/blocking/ShapeServiceImpl.kt | 77 +- .../blocking/StopIdsForAgencyService.kt | 95 +- .../blocking/StopIdsForAgencyServiceImpl.kt | 88 +- .../services/blocking/StopService.kt | 88 +- .../services/blocking/StopServiceImpl.kt | 76 +- .../blocking/StopsForAgencyService.kt | 93 +- .../blocking/StopsForAgencyServiceImpl.kt | 88 +- .../blocking/StopsForLocationService.kt | 43 +- .../blocking/StopsForLocationServiceImpl.kt | 73 +- .../services/blocking/StopsForRouteService.kt | 91 +- .../blocking/StopsForRouteServiceImpl.kt | 88 +- .../services/blocking/TripDetailService.kt | 92 +- .../blocking/TripDetailServiceImpl.kt | 78 +- .../blocking/TripForVehicleService.kt | 97 +- .../blocking/TripForVehicleServiceImpl.kt | 88 +- .../services/blocking/TripService.kt | 88 +- .../services/blocking/TripServiceImpl.kt | 76 +- .../blocking/TripsForLocationService.kt | 43 +- .../blocking/TripsForLocationServiceImpl.kt | 73 +- .../services/blocking/TripsForRouteService.kt | 91 +- .../blocking/TripsForRouteServiceImpl.kt | 88 +- .../blocking/VehiclesForAgencyService.kt | 95 +- .../blocking/VehiclesForAgencyServiceImpl.kt | 88 +- .../org/onebusaway/TestServerExtension.kt | 2 +- .../org/onebusaway/core/ObjectMappersTest.kt | 102 + .../onebusaway/core/PhantomReachableTest.kt | 4 +- .../kotlin/org/onebusaway/core/UtilsTest.kt | 33 + .../kotlin/org/onebusaway/core/ValuesTest.kt | 144 + .../core/http/AsyncStreamResponseTest.kt | 268 ++ .../org/onebusaway/core/http/HeadersTest.kt | 96 +- .../onebusaway/core/http/QueryParamsTest.kt | 82 +- .../core/http/RetryingHttpClientTest.kt | 58 +- .../onebusaway/core/http/SerializerTest.kt | 106 - .../org/onebusaway/models/ReferencesTest.kt | 149 +- .../onebusaway/models/ResponseWrapperTest.kt | 23 +- .../models/TripsForLocationListParamsTest.kt | 58 - .../AgenciesWithCoverageListParamsTest.kt | 4 +- .../AgenciesWithCoverageListResponseTest.kt | 520 ++ .../{ => agency}/AgencyRetrieveParamsTest.kt | 13 +- .../agency/AgencyRetrieveResponseTest.kt | 534 +++ .../ArrivalAndDepartureListParamsTest.kt | 43 +- .../ArrivalAndDepartureListResponseTest.kt | 772 +++ .../ArrivalAndDepartureRetrieveParamsTest.kt | 56 +- ...ArrivalAndDepartureRetrieveResponseTest.kt | 742 +++ .../{ => block}/BlockRetrieveParamsTest.kt | 13 +- .../models/block/BlockRetrieveResponseTest.kt | 617 +++ .../{ => config}/ConfigRetrieveParamsTest.kt | 4 +- .../config/ConfigRetrieveResponseTest.kt | 585 +++ .../CurrentTimeRetrieveParamsTest.kt | 4 +- .../CurrentTimeRetrieveResponseTest.kt | 507 ++ ...ReportProblemWithStopRetrieveParamsTest.kt | 59 +- ...ReportProblemWithTripRetrieveParamsTest.kt | 69 +- .../{ => route}/RouteRetrieveParamsTest.kt | 13 +- .../models/route/RouteRetrieveResponseTest.kt | 531 +++ .../RouteIdsForAgencyListParamsTest.kt | 13 +- .../RouteIdsForAgencyListResponseTest.kt | 496 ++ .../RoutesForAgencyListParamsTest.kt | 13 +- .../RoutesForAgencyListResponseTest.kt | 534 +++ .../RoutesForLocationListParamsTest.kt | 35 +- .../RoutesForLocationListResponseTest.kt | 538 +++ .../ScheduleForRouteRetrieveParamsTest.kt | 34 +- .../ScheduleForRouteRetrieveResponseTest.kt | 270 ++ .../ScheduleForStopRetrieveParamsTest.kt | 34 +- .../ScheduleForStopRetrieveResponseTest.kt | 636 +++ .../SearchForRouteListParamsTest.kt | 20 +- .../SearchForRouteListResponseTest.kt | 537 +++ .../SearchForStopListParamsTest.kt | 20 +- .../SearchForStopListResponseTest.kt | 540 +++ .../{ => shape}/ShapeRetrieveParamsTest.kt | 13 +- .../models/shape/ShapeRetrieveResponseTest.kt | 510 ++ .../{ => stop}/StopRetrieveParamsTest.kt | 13 +- .../models/stop/StopRetrieveResponseTest.kt | 534 +++ .../StopIdsForAgencyListParamsTest.kt | 13 +- .../StopIdsForAgencyListResponseTest.kt | 495 ++ .../StopsForAgencyListParamsTest.kt | 13 +- .../StopsForAgencyListResponseTest.kt | 522 +++ .../StopsForLocationListParamsTest.kt | 35 +- .../StopsForLocationListResponseTest.kt | 540 +++ .../StopsForRouteListParamsTest.kt | 38 +- .../StopsForRouteListResponseTest.kt | 596 +++ .../{ => trip}/TripRetrieveParamsTest.kt | 13 +- .../models/trip/TripRetrieveResponseTest.kt | 534 +++ .../TripDetailRetrieveParamsTest.kt | 47 +- .../TripDetailRetrieveResponseTest.kt | 702 +++ .../TripForVehicleRetrieveParamsTest.kt | 45 +- .../TripForVehicleRetrieveResponseTest.kt | 707 +++ .../TripsForLocationListParamsTest.kt | 75 + .../TripsForLocationListResponseTest.kt | 708 +++ .../TripsForRouteListParamsTest.kt | 43 +- .../TripsForRouteListResponseTest.kt | 704 +++ .../VehiclesForAgencyListParamsTest.kt | 34 +- .../VehiclesForAgencyListResponseTest.kt | 684 +++ .../onebusaway/services/ErrorHandlingTest.kt | 499 +- .../onebusaway/services/ServiceParamsTest.kt | 206 +- .../AgenciesWithCoverageServiceAsyncTest.kt | 27 + .../services/async/AgencyServiceAsyncTest.kt | 27 + .../ArrivalAndDepartureServiceAsyncTest.kt | 63 + .../services/async/BlockServiceAsyncTest.kt | 27 + .../services/async/ConfigServiceAsyncTest.kt | 27 + .../async/CurrentTimeServiceAsyncTest.kt | 27 + .../ReportProblemWithStopServiceAsyncTest.kt | 38 + .../ReportProblemWithTripServiceAsyncTest.kt | 43 + .../RouteIdsForAgencyServiceAsyncTest.kt | 27 + .../services/async/RouteServiceAsyncTest.kt | 27 + .../async/RoutesForAgencyServiceAsyncTest.kt | 27 + .../RoutesForLocationServiceAsyncTest.kt | 38 + .../async/ScheduleForRouteServiceAsyncTest.kt | 35 + .../async/ScheduleForStopServiceAsyncTest.kt | 35 + .../async/SearchForRouteServiceAsyncTest.kt | 31 + .../async/SearchForStopServiceAsyncTest.kt | 31 + .../services/async/ShapeServiceAsyncTest.kt | 27 + .../async/StopIdsForAgencyServiceAsyncTest.kt | 27 + .../services/async/StopServiceAsyncTest.kt | 27 + .../async/StopsForAgencyServiceAsyncTest.kt | 27 + .../async/StopsForLocationServiceAsyncTest.kt | 38 + .../async/StopsForRouteServiceAsyncTest.kt | 35 + .../async/TripDetailServiceAsyncTest.kt | 38 + .../async/TripForVehicleServiceAsyncTest.kt | 37 + .../services/async/TripServiceAsyncTest.kt | 27 + .../async/TripsForLocationServiceAsyncTest.kt | 39 + .../async/TripsForRouteServiceAsyncTest.kt | 36 + .../VehiclesForAgencyServiceAsyncTest.kt | 31 + .../AgenciesWithCoverageServiceTest.kt | 12 +- .../services/blocking/AgencyServiceTest.kt | 12 +- .../ArrivalAndDepartureServiceTest.kt | 22 +- .../services/blocking/BlockServiceTest.kt | 12 +- .../services/blocking/ConfigServiceTest.kt | 11 +- .../blocking/CurrentTimeServiceTest.kt | 12 +- .../ReportProblemWithStopServiceTest.kt | 15 +- .../ReportProblemWithTripServiceTest.kt | 15 +- .../blocking/RouteIdsForAgencyServiceTest.kt | 14 +- .../services/blocking/RouteServiceTest.kt | 12 +- .../blocking/RoutesForAgencyServiceTest.kt | 12 +- .../blocking/RoutesForLocationServiceTest.kt | 12 +- .../blocking/ScheduleForRouteServiceTest.kt | 12 +- .../blocking/ScheduleForStopServiceTest.kt | 12 +- .../blocking/SearchForRouteServiceTest.kt | 12 +- .../blocking/SearchForStopServiceTest.kt | 12 +- .../services/blocking/ShapeServiceTest.kt | 12 +- .../blocking/StopIdsForAgencyServiceTest.kt | 14 +- .../services/blocking/StopServiceTest.kt | 12 +- .../blocking/StopsForAgencyServiceTest.kt | 14 +- .../blocking/StopsForLocationServiceTest.kt | 12 +- .../blocking/StopsForRouteServiceTest.kt | 12 +- .../blocking/TripDetailServiceTest.kt | 12 +- .../blocking/TripForVehicleServiceTest.kt | 12 +- .../services/blocking/TripServiceTest.kt | 12 +- .../blocking/TripsForLocationServiceTest.kt | 20 +- .../blocking/TripsForRouteServiceTest.kt | 12 +- .../blocking/VehiclesForAgencyServiceTest.kt | 12 +- onebusaway-sdk-java-example/build.gradle.kts | 7 +- .../example/AgenciesWithCoverage.java | 3 +- .../java/org/onebusaway/example/Agency.java | 3 +- .../example/ArrivalAndDepartureForStop.java | 3 +- .../example/ArrivalsAndDeparturesForStop.java | 3 +- .../java/org/onebusaway/example/Block.java | 3 +- .../org/onebusaway/example/CurrentTime.java | 3 +- .../java/org/onebusaway/example/Route.java | 8 +- .../onebusaway/example/RouteForAgency.java | 3 +- .../onebusaway/example/RoutesForLocation.java | 3 +- .../onebusaway/example/ScheduleForRoute.java | 3 +- .../onebusaway/example/SearchForRoute.java | 3 +- .../org/onebusaway/example/SearchForStop.java | 3 +- .../java/org/onebusaway/example/Shape.java | 3 +- .../java/org/onebusaway/example/Stop.java | 3 +- .../onebusaway/example/StopsForLocation.java | 2 + .../org/onebusaway/example/StopsForRoute.java | 3 +- .../onebusaway/example/StopsIdsForAgency.java | 3 +- .../java/org/onebusaway/example/Trip.java | 3 +- .../org/onebusaway/example/TripDetails.java | 3 +- .../onebusaway/example/TripForVehicle.java | 3 +- .../org/onebusaway/example/TripsForRoute.java | 3 +- .../onebusaway/example/VehiclesForAgency.java | 3 +- onebusaway-sdk-java/build.gradle.kts | 21 + scripts/format | 2 +- scripts/lint | 2 +- scripts/test | 2 +- 406 files changed, 82902 insertions(+), 35019 deletions(-) delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/HttpRequestBodies.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/AsyncStreamResponse.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBodies.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponseFor.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingAsyncStreamResponse.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingStreamResponse.kt create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/StreamResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt delete mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => agencieswithcoverage}/AgenciesWithCoverageListParams.kt (92%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => agency}/AgencyRetrieveParams.kt (85%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => arrivalanddeparture}/ArrivalAndDepartureListParams.kt (78%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => arrivalanddeparture}/ArrivalAndDepartureRetrieveParams.kt (77%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => block}/BlockRetrieveParams.kt (85%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => config}/ConfigRetrieveParams.kt (93%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => currenttime}/CurrentTimeRetrieveParams.kt (93%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => reportproblemwithstop}/ReportProblemWithStopRetrieveParams.kt (71%) rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => reportproblemwithtrip}/ReportProblemWithTripRetrieveParams.kt (71%) rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => route}/RouteRetrieveParams.kt (85%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => routeidsforagency}/RouteIdsForAgencyListParams.kt (86%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => routesforagency}/RoutesForAgencyListParams.kt (86%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => routesforlocation}/RoutesForLocationListParams.kt (78%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => scheduleforroute}/ScheduleForRouteRetrieveParams.kt (83%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => scheduleforstop}/ScheduleForStopRetrieveParams.kt (84%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => searchforroute}/SearchForRouteListParams.kt (84%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => searchforstop}/SearchForStopListParams.kt (84%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => shape}/ShapeRetrieveParams.kt (85%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => stop}/StopRetrieveParams.kt (85%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => stopidsforagency}/StopIdsForAgencyListParams.kt (86%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => stopsforagency}/StopsForAgencyListParams.kt (86%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => stopsforlocation}/StopsForLocationListParams.kt (79%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => stopsforroute}/StopsForRouteListParams.kt (81%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => trip}/TripRetrieveParams.kt (85%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => tripdetails}/TripDetailRetrieveParams.kt (77%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => tripforvehicle}/TripForVehicleRetrieveParams.kt (78%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => tripsforlocation}/TripsForLocationListParams.kt (75%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => tripsforroute}/TripsForRouteListParams.kt (79%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt rename onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/{ => vehiclesforagency}/VehiclesForAgencyListParams.kt (83%) create mode 100644 onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ObjectMappersTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/UtilsTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ValuesTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/AsyncStreamResponseTest.kt delete mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt delete mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => agencieswithcoverage}/AgenciesWithCoverageListParamsTest.kt (64%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => agency}/AgencyRetrieveParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => arrivalanddeparture}/ArrivalAndDepartureListParamsTest.kt (60%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => arrivalanddeparture}/ArrivalAndDepartureRetrieveParamsTest.kt (60%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => block}/BlockRetrieveParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => config}/ConfigRetrieveParamsTest.kt (69%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => currenttime}/CurrentTimeRetrieveParamsTest.kt (67%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => reportproblemwithstop}/ReportProblemWithStopRetrieveParamsTest.kt (50%) rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => reportproblemwithtrip}/ReportProblemWithTripRetrieveParamsTest.kt (53%) rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => route}/RouteRetrieveParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => routeidsforagency}/RouteIdsForAgencyListParamsTest.kt (58%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => routesforagency}/RoutesForAgencyListParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => routesforlocation}/RoutesForLocationListParamsTest.kt (55%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => scheduleforroute}/ScheduleForRouteRetrieveParamsTest.kt (62%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => scheduleforstop}/ScheduleForStopRetrieveParamsTest.kt (61%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => searchforroute}/SearchForRouteListParamsTest.kt (58%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => searchforstop}/SearchForStopListParamsTest.kt (58%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => shape}/ShapeRetrieveParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => stop}/StopRetrieveParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => stopidsforagency}/StopIdsForAgencyListParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => stopsforagency}/StopsForAgencyListParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => stopsforlocation}/StopsForLocationListParamsTest.kt (55%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => stopsforroute}/StopsForRouteListParamsTest.kt (60%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => trip}/TripRetrieveParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => tripdetails}/TripDetailRetrieveParamsTest.kt (58%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => tripforvehicle}/TripForVehicleRetrieveParamsTest.kt (58%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponseTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParamsTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => tripsforroute}/TripsForRouteListParamsTest.kt (58%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponseTest.kt rename onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/{ => vehiclesforagency}/VehiclesForAgencyListParamsTest.kt (57%) create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgencyServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/BlockServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ConfigServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ShapeServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncTest.kt create mode 100644 onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncTest.kt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71594a4..ef24b0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,43 +1,40 @@ name: CI on: push: - branches: - - main - pull_request: - branches: - - main - - next + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: + timeout-minutes: 10 name: lint - runs-on: ubuntu-latest - + runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 - - name: Validate Gradle wrapper - uses: gradle/actions/wrapper-validation@v3 - - name: Set up Java uses: actions/setup-java@v4 with: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v4 - name: Run lints run: ./scripts/lint test: + timeout-minutes: 10 name: test - runs-on: ubuntu-latest - + runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 @@ -47,7 +44,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle @@ -55,4 +52,3 @@ jobs: - name: Run tests run: ./scripts/test - diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index cabf487..04592b7 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" + ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/.gitignore b/.gitignore index 39c31e3..4e81838 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .prism.log .gradle .idea +.kotlin build codegen.log kls_database.db diff --git a/.stats.yml b/.stats.yml index 3928277..ad9cf70 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +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 +config_hash: 3871f5d21bb38ddd334ec04721dea64d diff --git a/README.md b/README.md index 6224414..c12dcb0 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,21 @@ [![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.23) +[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.23/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.23) -The Onebusaway SDK Java SDK provides convenient access to the Onebusaway SDK REST API from applications written in Java. +The Onebusaway SDK Java SDK provides convenient access to the [Onebusaway SDK REST API](https://developer.onebusaway.org) from applications written in Java. The Onebusaway SDK Java SDK is similar to the Onebusaway SDK Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. -It is generated with [Stainless](https://www.stainlessapi.com/). +It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). + + +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.23). + + ## Installation @@ -28,9 +33,9 @@ implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.23") ```xml - org.onebusaway - onebusaway-sdk-java - 0.1.0-alpha.23 + org.onebusaway + onebusaway-sdk-java + 0.1.0-alpha.23 ``` @@ -42,9 +47,31 @@ This library requires Java 8 or later. ## Usage -### Configure the client +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; + +// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); + +CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(); +``` + +## Client configuration + +Configure the client using environment variables: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); +``` -Use `OnebusawaySdkOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`: +Or manually: ```java import org.onebusaway.client.OnebusawaySdkClient; @@ -55,129 +82,171 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .build(); ``` -Alternately, set the environment with `ONEBUSAWAY_API_KEY`, and use `OnebusawaySdkOkHttpClient.fromEnv()` to read from the environment. +Or using a combination of the two approaches: ```java import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); - -// Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + // Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables .fromEnv() - // ... set properties on the builder + .apiKey("My API Key") .build(); ``` -| Property | Environment variable | Required | Default value | -| -------- | -------------------- | -------- | ------------- | -| apiKey | `ONEBUSAWAY_API_KEY` | true | — | +See this table for the available options: -Read the documentation for more configuration options. +| Setter | Environment variable | Required | Default value | +| --------- | ------------------------- | -------- | ----------------------------------------- | +| `apiKey` | `ONEBUSAWAY_API_KEY` | true | - | +| `baseUrl` | `ONEBUSAWAY_SDK_BASE_URL` | true | `"https://api.pugetsound.onebusaway.org"` | ---- +> [!TIP] +> Don't create more than one client in the same application. Each client has a connection pool and +> thread pools, which are more efficient to share between requests. -### Example: creating a resource +## Requests and responses -To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes, then pass that to the `retrieve` method of the `currentTime` service. +To send a request to the Onebusaway SDK API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -```java -import org.onebusaway.models.CurrentTimeRetrieveParams; -import org.onebusaway.models.CurrentTimeRetrieveResponse; +For example, `client.currentTime().retrieve(...)` should be called with an instance of `CurrentTimeRetrieveParams`, and it will return an instance of `CurrentTimeRetrieveResponse`. -CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder().build(); -CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(params); -``` +## Immutability ---- +Each class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it. -## Requests +Each class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy. -### Parameters and bodies +Because each class is immutable, builder modification will _never_ affect already built class instances. -To make a request to the Onebusaway SDK API, you generally build an instance of the appropriate `Params` class. +## Asynchronous execution -See [Undocumented request params](#undocumented-request-params) for how to send arbitrary parameters. +The default client is synchronous. To switch to asynchronous execution, call the `async()` method: -## Responses +```java +import java.util.concurrent.CompletableFuture; +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; -### Response validation +// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); + +CompletableFuture currentTime = client.async().currentTime().retrieve(); +``` -When receiving a response, the Onebusaway SDK Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `OnebusawaySdkInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model. +Or create an asynchronous client from the beginning: ```java -import org.onebusaway.models.CurrentTimeRetrieveResponse; +import java.util.concurrent.CompletableFuture; +import org.onebusaway.client.OnebusawaySdkClientAsync; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; -CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve().validate(); +// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClientAsync client = OnebusawaySdkOkHttpClientAsync.fromEnv(); + +CompletableFuture currentTime = client.currentTime().retrieve(); ``` -### Response properties as JSON +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. -In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value. +## Raw responses -```java -import java.util.Optional; -import org.onebusaway.core.JsonField; +The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body. -JsonField field = responseObj._field(); +To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: -if (field.isMissing()) { - // Value was not specified in the JSON response -} else if (field.isNull()) { - // Value was provided as a literal null -} else { - // See if value was provided as a string - Optional jsonString = field.asString(); +```java +import org.onebusaway.core.http.Headers; +import org.onebusaway.core.http.HttpResponseFor; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; - // If the value given by the API did not match the shape that the SDK expects - // you can deserialise into a custom type - MyClass myObj = responseObj._field().asUnknown().orElseThrow().convert(MyClass.class); -} -``` +HttpResponseFor currentTime = client.currentTime().withRawResponse().retrieve(); -### Additional model properties +int statusCode = currentTime.statusCode(); +Headers headers = currentTime.headers(); +``` -Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method: +You can still deserialize the response into an instance of a Java class if needed: ```java -import org.onebusaway.core.JsonValue; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; -JsonValue secret = references._additionalProperties().get("secret_field"); +CurrentTimeRetrieveResponse parsedCurrentTime = currentTime.parse(); ``` ---- +## Error handling ---- +The SDK throws custom unchecked exception types: -## Error handling +- [`OnebusawaySdkServiceException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: + + | Status | Exception | + | ------ | ---------------------------------------------------------------------------------------------------------------------------------- | + | 400 | [`BadRequestException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt) | + | 401 | [`UnauthorizedException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt) | + | 403 | [`PermissionDeniedException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt) | + | 404 | [`NotFoundException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt) | + | 422 | [`UnprocessableEntityException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt) | + | 429 | [`RateLimitException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt) | + | 5xx | [`InternalServerException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt) | + | others | [`UnexpectedStatusCodeException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt) | + +- [`OnebusawaySdkIoException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkIoException.kt): I/O networking errors. + +- [`OnebusawaySdkInvalidDataException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. + +- [`OnebusawaySdkException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. + +## 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 +$ export ONEBUSAWAY_SDK_LOG=info +``` -This library throws exceptions in a single hierarchy for easy handling: +Or to `debug` for more verbose logging: -- **`OnebusawaySdkException`** - Base exception for all exceptions +```sh +$ export ONEBUSAWAY_SDK_LOG=debug +``` + +## Jackson + +The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. -- **`OnebusawaySdkServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server. +The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config). - | 400 | BadRequestException | - | ------ | ----------------------------- | - | 401 | AuthenticationException | - | 403 | PermissionDeniedException | - | 404 | NotFoundException | - | 422 | UnprocessableEntityException | - | 429 | RateLimitException | - | 5xx | InternalServerException | - | others | UnexpectedStatusCodeException | +If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`OnebusawaySdkOkHttpClient`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt) or [`OnebusawaySdkOkHttpClientAsync`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt). -- **`OnebusawaySdkIoException`** - I/O networking errors -- **`OnebusawaySdkInvalidDataException`** - any other exceptions on the client side, e.g.: - - We failed to serialize the request body - - We failed to parse the response body (has access to response code and body) +> [!CAUTION] +> We make no guarantee that the SDK works correctly when the Jackson version check is disabled. ## Network options ### Retries -Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. You can provide a `maxRetries` on the client builder to configure this: +The SDK automatically retries 2 times by default, with a short exponential backoff. + +Only the following error types are retried: + +- Connection errors (for example, due to a network connectivity problem) +- 408 Request Timeout +- 409 Conflict +- 429 Rate Limit +- 5xx Internal + +The API may also explicitly instruct the SDK to retry or not retry a response. + +To set a custom number of retries, configure the client using the `maxRetries` method: ```java import org.onebusaway.client.OnebusawaySdkClient; @@ -191,7 +260,17 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() ### Timeouts -Requests time out after 1 minute by default. You can configure this on the client builder: +Requests time out after 1 minute by default. + +To set a custom timeout, configure the method call using the `timeout` method: + +```java +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; + +CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); +``` + +Or configure the default for all method calls at the client level: ```java import java.time.Duration; @@ -206,7 +285,7 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() ### Proxies -Requests can be routed through a proxy. You can configure this on the client builder: +To route requests through a proxy, configure the client using the `proxy` method: ```java import java.net.InetSocketAddress; @@ -216,23 +295,61 @@ import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() .fromEnv() - .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("example.com", 8080))) + .proxy(new Proxy( + Proxy.Type.HTTP, new InetSocketAddress( + "https://example.com", 8080 + ) + )) .build(); ``` -## Making custom/undocumented requests +### Custom HTTP client + +The SDK consists of three artifacts: + +- `onebusaway-sdk-java-core` + - Contains core SDK logic + - Does not depend on [OkHttp](https://square.github.io/okhttp) + - Exposes [`OnebusawaySdkClient`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt), [`OnebusawaySdkClientAsync`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt), [`OnebusawaySdkClientImpl`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt), and [`OnebusawaySdkClientAsyncImpl`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt), all of which can work with any HTTP client +- `onebusaway-sdk-java-client-okhttp` + - Depends on [OkHttp](https://square.github.io/okhttp) + - Exposes [`OnebusawaySdkOkHttpClient`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt) and [`OnebusawaySdkOkHttpClientAsync`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt), which provide a way to construct [`OnebusawaySdkClientImpl`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt) and [`OnebusawaySdkClientAsyncImpl`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt), respectively, using OkHttp +- `onebusaway-sdk-java` + - Depends on and exposes the APIs of both `onebusaway-sdk-java-core` and `onebusaway-sdk-java-client-okhttp` + - Does not have its own logic + +This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies. + +#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) + +> [!TIP] +> Try the available [network options](#network-options) before replacing the default client. -This library is typed for convenient access to the documented API. If you need to access undocumented params or response properties, the library can still be used. +To use a customized `OkHttpClient`: -### Undocumented request params +1. Replace your [`onebusaway-sdk-java` dependency](#installation) with `onebusaway-sdk-java-core` +2. Copy `onebusaway-sdk-java-client-okhttp`'s [`OkHttpClient`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt) class into your code and customize it +3. Construct [`OnebusawaySdkClientImpl`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt) or [`OnebusawaySdkClientAsyncImpl`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt), similarly to [`OnebusawaySdkOkHttpClient`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt) or [`OnebusawaySdkOkHttpClientAsync`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt), using your customized client -In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to the `retrieve` method of the `currentTime` service. +### Completely custom HTTP client -Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using raw setters: +To use a completely custom HTTP client: + +1. Replace your [`onebusaway-sdk-java` dependency](#installation) with `onebusaway-sdk-java-core` +2. Write a class that implements the [`HttpClient`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt) interface +3. Construct [`OnebusawaySdkClientImpl`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt) or [`OnebusawaySdkClientAsyncImpl`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt), similarly to [`OnebusawaySdkOkHttpClient`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt) or [`OnebusawaySdkOkHttpClientAsync`](onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt), using your new client class + +## Undocumented API functionality + +The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. + +### Parameters + +To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class: ```java import org.onebusaway.core.JsonValue; -import org.onebusaway.models.CurrentTimeRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder() .putAdditionalHeader("Secret-Header", "42") @@ -241,28 +358,186 @@ CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder() .build(); ``` -You can also use the `putAdditionalProperty` method on nested headers, query params, or body objects. +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. -### Undocumented response properties +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt) object to its setter: -To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `res._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. +```java +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; -## Logging +CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder().build(); +``` -We use the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). +The most straightforward way to create a [`JsonValue`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt) is using its `from(...)` method: -You can enable logging by setting the environment variable `ONEBUSAWAY_SDK_LOG` to `info`. +```java +import java.util.List; +import java.util.Map; +import org.onebusaway.core.JsonValue; -```sh -$ export ONEBUSAWAY_SDK_LOG=info +// Create primitive JSON values +JsonValue nullValue = JsonValue.from(null); +JsonValue booleanValue = JsonValue.from(true); +JsonValue numberValue = JsonValue.from(42); +JsonValue stringValue = JsonValue.from("Hello World!"); + +// Create a JSON array value equivalent to `["Hello", "World"]` +JsonValue arrayValue = JsonValue.from(List.of( + "Hello", "World" +)); + +// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` +JsonValue objectValue = JsonValue.from(Map.of( + "a", 1, + "b", 2 +)); + +// Create an arbitrarily nested JSON equivalent to: +// { +// "a": [1, 2], +// "b": [3, 4] +// } +JsonValue complexValue = JsonValue.from(Map.of( + "a", List.of( + 1, 2 + ), + "b", List.of( + 3, 4 + ) +)); ``` -Or to `debug` for more verbose logging. +Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. -```sh -$ export ONEBUSAWAY_SDK_LOG=debug +To forcibly omit a required parameter or property, pass [`JsonMissing`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt): + +```java +import org.onebusaway.core.JsonMissing; +import org.onebusaway.models.agency.AgencyRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; + +CurrentTimeRetrieveParams params = AgencyRetrieveParams.builder() + .agencyId(JsonMissing.of()) + .build(); +``` + +### Response properties + +To access undocumented response properties, call the `_additionalProperties()` method: + +```java +import java.util.Map; +import org.onebusaway.core.JsonValue; + +Map additionalProperties = client.currentTime().retrieve(params)._additionalProperties(); +JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); + +String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { + @Override + public String visitNull() { + return "It's null!"; + } + + @Override + public String visitBoolean(boolean value) { + return "It's a boolean!"; + } + + @Override + public String visitNumber(Number value) { + return "It's a number!"; + } + + // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject` + // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden +}); +``` + +To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: + +```java +import java.util.Optional; +import org.onebusaway.core.JsonField; + +JsonField field = client.currentTime().retrieve(params)._field(); + +if (field.isMissing()) { + // The property is absent from the JSON response +} else if (field.isNull()) { + // The property was set to literal null +} else { + // Check if value was provided as a string + // Other methods include `asNumber()`, `asBoolean()`, etc. + Optional jsonString = field.asString(); + + // Try to deserialize into a custom type + MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); +} +``` + +### Response validation + +In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. + +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()`: + +```java +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; + +CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(params).validate(); +``` + +Or configure the method call to validate the response using the `responseValidation` method: + +```java +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; + +CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(RequestOptions.builder().responseValidation(true).build()); +``` + +Or configure the default for all method calls at the client level: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + .fromEnv() + .responseValidation(true) + .build(); ``` +## FAQ + +### Why don't you use plain `enum` classes? + +Java `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value. + +### Why do you represent fields using `JsonField` instead of just plain `T`? + +Using `JsonField` enables a few features: + +- Allowing usage of [undocumented API functionality](#undocumented-api-functionality) +- Lazily [validating the API response against the expected shape](#response-validation) +- Representing absent vs explicitly null values + +### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)? + +It is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class. + +### Why don't you use checked exceptions? + +Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason. + +Checked exceptions: + +- Are verbose to handle +- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error +- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function) +- Don't play well with lambdas (also due to the function coloring problem) + ## Semantic versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: diff --git a/SECURITY.md b/SECURITY.md index 62ac016..8be07dc 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,9 @@ ## Reporting Security Issues -This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. -To report a security issue, please contact the Stainless team at security@stainlessapi.com. +To report a security issue, please contact the Stainless team at security@stainless.com. ## Responsible Disclosure diff --git a/build.gradle.kts b/build.gradle.kts index 6c2c685..534d0c5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,23 @@ +plugins { + id("org.jetbrains.dokka") version "2.0.0" +} + +repositories { + mavenCentral() +} + allprojects { group = "org.onebusaway" version = "0.1.0-alpha.23" // x-release-please-version } + +subprojects { + apply(plugin = "org.jetbrains.dokka") +} + +// Avoid race conditions between `dokkaJavadocCollector` and `dokkaJavadocJar` tasks +tasks.named("dokkaJavadocCollector").configure { + subprojects.flatMap { it.tasks } + .filter { it.project.name != "onebusaway-sdk-java" && it.name == "dokkaJavadocJar" } + .forEach { mustRunAfter(it) } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 8a1d7a1..778c89d 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `kotlin-dsl` - kotlin("jvm") version "2.1.0" + kotlin("jvm") version "1.9.20" id("com.vanniktech.maven.publish") version "0.28.0" } @@ -10,7 +10,7 @@ repositories { } dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23") + implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts index a2c35b9..dfbacb8 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts @@ -21,8 +21,11 @@ configure { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } tasks.withType().configureEach { @@ -39,9 +42,13 @@ tasks.named("jar") { } } -tasks.named("test") { +tasks.withType().configureEach { useJUnitPlatform() + // Run tests in parallel to some degree. + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 + testLogging { exceptionFormat = TestExceptionFormat.FULL } diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts index 5eecc1c..be0b5d4 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts @@ -1,5 +1,6 @@ import com.diffplug.gradle.spotless.SpotlessExtension -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion plugins { id("onebusaway-sdk.java") @@ -8,7 +9,21 @@ plugins { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) + } + + compilerOptions { + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. + "-nowarn", + ) + jvmTarget.set(JvmTarget.JVM_1_8) + languageVersion.set(KotlinVersion.KOTLIN_1_8) + apiVersion.set(KotlinVersion.KOTLIN_1_8) + coreLibrariesVersion = "1.8.0" } } @@ -19,14 +34,7 @@ configure { } } -tasks.withType().configureEach { - kotlinOptions { - freeCompilerArgs = listOf( - "-Xjvm-default=all", - "-Xjdk-release=1.8", - // Suppress deprecation warnings because we may still reference and test deprecated members. - "-Xsuppress-warning=DEPRECATION" - ) - jvmTarget = "1.8" - } +tasks.withType().configureEach { + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") } diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts index 457c5c2..8ba555d 100644 --- a/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts @@ -1,3 +1,5 @@ +import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinJvm import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost @@ -19,6 +21,12 @@ configure { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) coordinates(project.group.toString(), project.name, project.version.toString()) + configure( + KotlinJvm( + javadocJar = JavadocJar.Dokka("dokkaJavadoc"), + sourcesJar = true, + ) + ) pom { name.set("OneBusAway") diff --git a/gradle.properties b/gradle.properties index a3bc58f..ff76593 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,17 @@ org.gradle.caching=true -org.gradle.jvmargs=-Xmx4g +org.gradle.configuration-cache=true org.gradle.parallel=true -kotlin.daemon.jvmargs=-Xmx4g +org.gradle.daemon=false +# These options improve our compilation and test performance. They are inherited by the Kotlin daemon. +org.gradle.jvmargs=\ + -Xms1g \ + -Xmx4g \ + -XX:+UseParallelGC \ + -XX:InitialCodeCacheSize=256m \ + -XX:ReservedCodeCacheSize=1G \ + -XX:MetaspaceSize=256m \ + -XX:TieredStopAtLevel=1 \ + -XX:GCTimeRatio=4 \ + -XX:CICompilerCount=4 \ + -XX:+OptimizeStringConcat \ + -XX:+UseStringDeduplication 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 16d85ce..32d8d5e 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 @@ -19,6 +19,7 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink import org.onebusaway.core.RequestOptions +import org.onebusaway.core.Timeout import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.HttpClient @@ -32,10 +33,7 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) return try { @@ -93,13 +91,12 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val clientBuilder.addNetworkInterceptor(HttpLoggingInterceptor().setLevel(logLevel)) } - val timeout = requestOptions.timeout - if (timeout != null) { + requestOptions.timeout?.let { clientBuilder - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .connectTimeout(it.connect()) + .readTimeout(it.read()) + .writeTimeout(it.write()) + .callTimeout(it.request()) } val client = clientBuilder.build() @@ -122,13 +119,13 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val ) { builder.header( "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString() + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { builder.header( "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString() + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), ) } @@ -200,23 +197,24 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { private var baseUrl: HttpUrl? = null - // The default timeout is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) .proxy(proxy) .build(), checkRequired("baseUrl", baseUrl), 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 807aa13..1c947e1 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 @@ -9,6 +9,7 @@ import java.time.Duration import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.OnebusawaySdkClientImpl import org.onebusaway.core.ClientOptions +import org.onebusaway.core.Timeout import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams @@ -16,6 +17,9 @@ class OnebusawaySdkOkHttpClient private constructor() { companion object { + /** + * Returns a mutable builder for constructing an instance of [OnebusawaySdkOkHttpClient]. + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): OnebusawaySdkClient = builder().fromEnv().build() @@ -25,14 +29,20 @@ class OnebusawaySdkOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } @@ -119,7 +129,19 @@ class OnebusawaySdkOkHttpClient private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } @@ -133,12 +155,17 @@ class OnebusawaySdkOkHttpClient private constructor() { fun fromEnv() = apply { clientOptions.fromEnv() } + /** + * Returns an immutable instance of [OnebusawaySdkClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OnebusawaySdkClient = OnebusawaySdkClientImpl( clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() 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 6611264..40b84fd 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 @@ -9,6 +9,7 @@ import java.time.Duration import org.onebusaway.client.OnebusawaySdkClientAsync import org.onebusaway.client.OnebusawaySdkClientAsyncImpl import org.onebusaway.core.ClientOptions +import org.onebusaway.core.Timeout import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams @@ -16,6 +17,10 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { companion object { + /** + * Returns a mutable builder for constructing an instance of + * [OnebusawaySdkOkHttpClientAsync]. + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): OnebusawaySdkClientAsync = builder().fromEnv().build() @@ -25,14 +30,20 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } @@ -119,7 +130,19 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } @@ -133,12 +156,17 @@ class OnebusawaySdkOkHttpClientAsync private constructor() { fun fromEnv() = apply { clientOptions.fromEnv() } + /** + * Returns an immutable instance of [OnebusawaySdkClientAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OnebusawaySdkClientAsync = OnebusawaySdkClientAsyncImpl( clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() diff --git a/onebusaway-sdk-java-core/build.gradle.kts b/onebusaway-sdk-java-core/build.gradle.kts index 6a0859b..c020c89 100644 --- a/onebusaway-sdk-java-core/build.gradle.kts +++ b/onebusaway-sdk-java-core/build.gradle.kts @@ -3,14 +3,28 @@ plugins { id("onebusaway-sdk.publish") } +configurations.all { + resolutionStrategy { + // Compile and test against a lower Jackson version to ensure we're compatible with it. + // We publish with a higher version (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.13.4") + force("com.fasterxml.jackson.core:jackson-databind:2.13.4") + force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + } +} + dependencies { - api("com.fasterxml.jackson.core:jackson-core:2.18.1") - api("com.fasterxml.jackson.core:jackson-databind:2.18.1") + api("com.fasterxml.jackson.core:jackson-core:2.18.2") + api("com.fasterxml.jackson.core:jackson-databind:2.18.2") + api("com.google.errorprone:error_prone_annotations:2.33.0") - implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1") + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") @@ -20,6 +34,7 @@ dependencies { testImplementation("org.assertj:assertj-core:3.25.3") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") testImplementation("org.mockito:mockito-core:5.14.2") testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") 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 b09d68b..6128438 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 @@ -55,6 +55,11 @@ interface OnebusawaySdkClient { */ fun async(): OnebusawaySdkClientAsync + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun agenciesWithCoverage(): AgenciesWithCoverageService fun agency(): AgencyService @@ -123,4 +128,66 @@ interface OnebusawaySdkClient { * method. */ fun close() + + /** + * A view of [OnebusawaySdkClient] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun agenciesWithCoverage(): AgenciesWithCoverageService.WithRawResponse + + fun agency(): AgencyService.WithRawResponse + + fun vehiclesForAgency(): VehiclesForAgencyService.WithRawResponse + + fun config(): ConfigService.WithRawResponse + + fun currentTime(): CurrentTimeService.WithRawResponse + + fun stopsForLocation(): StopsForLocationService.WithRawResponse + + fun stopsForRoute(): StopsForRouteService.WithRawResponse + + fun stopsForAgency(): StopsForAgencyService.WithRawResponse + + fun stop(): StopService.WithRawResponse + + fun stopIdsForAgency(): StopIdsForAgencyService.WithRawResponse + + fun scheduleForStop(): ScheduleForStopService.WithRawResponse + + fun route(): RouteService.WithRawResponse + + fun routeIdsForAgency(): RouteIdsForAgencyService.WithRawResponse + + fun routesForLocation(): RoutesForLocationService.WithRawResponse + + fun routesForAgency(): RoutesForAgencyService.WithRawResponse + + fun scheduleForRoute(): ScheduleForRouteService.WithRawResponse + + fun arrivalAndDeparture(): ArrivalAndDepartureService.WithRawResponse + + fun trip(): TripService.WithRawResponse + + fun tripsForLocation(): TripsForLocationService.WithRawResponse + + fun tripDetails(): TripDetailService.WithRawResponse + + fun tripForVehicle(): TripForVehicleService.WithRawResponse + + fun tripsForRoute(): TripsForRouteService.WithRawResponse + + fun reportProblemWithStop(): ReportProblemWithStopService.WithRawResponse + + fun reportProblemWithTrip(): ReportProblemWithTripService.WithRawResponse + + fun searchForStop(): SearchForStopService.WithRawResponse + + fun searchForRoute(): SearchForRouteService.WithRawResponse + + fun block(): BlockService.WithRawResponse + + fun shape(): ShapeService.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 aee0c2e..df8c27f 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 @@ -55,6 +55,11 @@ interface OnebusawaySdkClientAsync { */ fun sync(): OnebusawaySdkClient + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync fun agency(): AgencyServiceAsync @@ -123,4 +128,67 @@ interface OnebusawaySdkClientAsync { * method. */ fun close() + + /** + * A view of [OnebusawaySdkClientAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse + + fun agency(): AgencyServiceAsync.WithRawResponse + + fun vehiclesForAgency(): VehiclesForAgencyServiceAsync.WithRawResponse + + fun config(): ConfigServiceAsync.WithRawResponse + + fun currentTime(): CurrentTimeServiceAsync.WithRawResponse + + fun stopsForLocation(): StopsForLocationServiceAsync.WithRawResponse + + fun stopsForRoute(): StopsForRouteServiceAsync.WithRawResponse + + fun stopsForAgency(): StopsForAgencyServiceAsync.WithRawResponse + + fun stop(): StopServiceAsync.WithRawResponse + + fun stopIdsForAgency(): StopIdsForAgencyServiceAsync.WithRawResponse + + fun scheduleForStop(): ScheduleForStopServiceAsync.WithRawResponse + + fun route(): RouteServiceAsync.WithRawResponse + + fun routeIdsForAgency(): RouteIdsForAgencyServiceAsync.WithRawResponse + + fun routesForLocation(): RoutesForLocationServiceAsync.WithRawResponse + + fun routesForAgency(): RoutesForAgencyServiceAsync.WithRawResponse + + fun scheduleForRoute(): ScheduleForRouteServiceAsync.WithRawResponse + + fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync.WithRawResponse + + fun trip(): TripServiceAsync.WithRawResponse + + fun tripsForLocation(): TripsForLocationServiceAsync.WithRawResponse + + fun tripDetails(): TripDetailServiceAsync.WithRawResponse + + fun tripForVehicle(): TripForVehicleServiceAsync.WithRawResponse + + fun tripsForRoute(): TripsForRouteServiceAsync.WithRawResponse + + fun reportProblemWithStop(): ReportProblemWithStopServiceAsync.WithRawResponse + + fun reportProblemWithTrip(): ReportProblemWithTripServiceAsync.WithRawResponse + + fun searchForStop(): SearchForStopServiceAsync.WithRawResponse + + fun searchForRoute(): SearchForRouteServiceAsync.WithRawResponse + + fun block(): BlockServiceAsync.WithRawResponse + + fun shape(): ShapeServiceAsync.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 5c218c1..b03336a 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 @@ -61,9 +61,8 @@ import org.onebusaway.services.async.TripsForRouteServiceAsyncImpl import org.onebusaway.services.async.VehiclesForAgencyServiceAsync import org.onebusaway.services.async.VehiclesForAgencyServiceAsyncImpl -class OnebusawaySdkClientAsyncImpl( - private val clientOptions: ClientOptions, -) : OnebusawaySdkClientAsync { +class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) : + OnebusawaySdkClientAsync { private val clientOptionsWithUserAgent = if (clientOptions.headers.names().contains("User-Agent")) clientOptions @@ -76,6 +75,10 @@ class OnebusawaySdkClientAsyncImpl( // Pass the original clientOptions so that this client sets its own User-Agent. private val sync: OnebusawaySdkClient by lazy { OnebusawaySdkClientImpl(clientOptions) } + private val withRawResponse: OnebusawaySdkClientAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val agenciesWithCoverage: AgenciesWithCoverageServiceAsync by lazy { AgenciesWithCoverageServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -186,6 +189,8 @@ class OnebusawaySdkClientAsyncImpl( override fun sync(): OnebusawaySdkClient = sync + override fun withRawResponse(): OnebusawaySdkClientAsync.WithRawResponse = withRawResponse + override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync = agenciesWithCoverage override fun agency(): AgencyServiceAsync = agency @@ -243,4 +248,191 @@ class OnebusawaySdkClientAsyncImpl( override fun shape(): ShapeServiceAsync = shape override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OnebusawaySdkClientAsync.WithRawResponse { + + private val agenciesWithCoverage: AgenciesWithCoverageServiceAsync.WithRawResponse by lazy { + AgenciesWithCoverageServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val agency: AgencyServiceAsync.WithRawResponse by lazy { + AgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val vehiclesForAgency: VehiclesForAgencyServiceAsync.WithRawResponse by lazy { + VehiclesForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val config: ConfigServiceAsync.WithRawResponse by lazy { + ConfigServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val currentTime: CurrentTimeServiceAsync.WithRawResponse by lazy { + CurrentTimeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForLocation: StopsForLocationServiceAsync.WithRawResponse by lazy { + StopsForLocationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForRoute: StopsForRouteServiceAsync.WithRawResponse by lazy { + StopsForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForAgency: StopsForAgencyServiceAsync.WithRawResponse by lazy { + StopsForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stop: StopServiceAsync.WithRawResponse by lazy { + StopServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val stopIdsForAgency: StopIdsForAgencyServiceAsync.WithRawResponse by lazy { + StopIdsForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val scheduleForStop: ScheduleForStopServiceAsync.WithRawResponse by lazy { + ScheduleForStopServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val route: RouteServiceAsync.WithRawResponse by lazy { + RouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val routeIdsForAgency: RouteIdsForAgencyServiceAsync.WithRawResponse by lazy { + RouteIdsForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val routesForLocation: RoutesForLocationServiceAsync.WithRawResponse by lazy { + RoutesForLocationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val routesForAgency: RoutesForAgencyServiceAsync.WithRawResponse by lazy { + RoutesForAgencyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val scheduleForRoute: ScheduleForRouteServiceAsync.WithRawResponse by lazy { + ScheduleForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val arrivalAndDeparture: ArrivalAndDepartureServiceAsync.WithRawResponse by lazy { + ArrivalAndDepartureServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val trip: TripServiceAsync.WithRawResponse by lazy { + TripServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tripsForLocation: TripsForLocationServiceAsync.WithRawResponse by lazy { + TripsForLocationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tripDetails: TripDetailServiceAsync.WithRawResponse by lazy { + TripDetailServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tripForVehicle: TripForVehicleServiceAsync.WithRawResponse by lazy { + TripForVehicleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tripsForRoute: TripsForRouteServiceAsync.WithRawResponse by lazy { + TripsForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val reportProblemWithStop: + ReportProblemWithStopServiceAsync.WithRawResponse by lazy { + ReportProblemWithStopServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val reportProblemWithTrip: + ReportProblemWithTripServiceAsync.WithRawResponse by lazy { + ReportProblemWithTripServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val searchForStop: SearchForStopServiceAsync.WithRawResponse by lazy { + SearchForStopServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val searchForRoute: SearchForRouteServiceAsync.WithRawResponse by lazy { + SearchForRouteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val block: BlockServiceAsync.WithRawResponse by lazy { + BlockServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val shape: ShapeServiceAsync.WithRawResponse by lazy { + ShapeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse = + agenciesWithCoverage + + override fun agency(): AgencyServiceAsync.WithRawResponse = agency + + override fun vehiclesForAgency(): VehiclesForAgencyServiceAsync.WithRawResponse = + vehiclesForAgency + + override fun config(): ConfigServiceAsync.WithRawResponse = config + + override fun currentTime(): CurrentTimeServiceAsync.WithRawResponse = currentTime + + override fun stopsForLocation(): StopsForLocationServiceAsync.WithRawResponse = + stopsForLocation + + override fun stopsForRoute(): StopsForRouteServiceAsync.WithRawResponse = stopsForRoute + + override fun stopsForAgency(): StopsForAgencyServiceAsync.WithRawResponse = stopsForAgency + + override fun stop(): StopServiceAsync.WithRawResponse = stop + + override fun stopIdsForAgency(): StopIdsForAgencyServiceAsync.WithRawResponse = + stopIdsForAgency + + override fun scheduleForStop(): ScheduleForStopServiceAsync.WithRawResponse = + scheduleForStop + + override fun route(): RouteServiceAsync.WithRawResponse = route + + override fun routeIdsForAgency(): RouteIdsForAgencyServiceAsync.WithRawResponse = + routeIdsForAgency + + override fun routesForLocation(): RoutesForLocationServiceAsync.WithRawResponse = + routesForLocation + + override fun routesForAgency(): RoutesForAgencyServiceAsync.WithRawResponse = + routesForAgency + + override fun scheduleForRoute(): ScheduleForRouteServiceAsync.WithRawResponse = + scheduleForRoute + + override fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync.WithRawResponse = + arrivalAndDeparture + + override fun trip(): TripServiceAsync.WithRawResponse = trip + + override fun tripsForLocation(): TripsForLocationServiceAsync.WithRawResponse = + tripsForLocation + + override fun tripDetails(): TripDetailServiceAsync.WithRawResponse = tripDetails + + override fun tripForVehicle(): TripForVehicleServiceAsync.WithRawResponse = tripForVehicle + + override fun tripsForRoute(): TripsForRouteServiceAsync.WithRawResponse = tripsForRoute + + override fun reportProblemWithStop(): ReportProblemWithStopServiceAsync.WithRawResponse = + reportProblemWithStop + + override fun reportProblemWithTrip(): ReportProblemWithTripServiceAsync.WithRawResponse = + reportProblemWithTrip + + override fun searchForStop(): SearchForStopServiceAsync.WithRawResponse = searchForStop + + override fun searchForRoute(): SearchForRouteServiceAsync.WithRawResponse = searchForRoute + + override fun block(): BlockServiceAsync.WithRawResponse = block + + override fun shape(): ShapeServiceAsync.WithRawResponse = shape + } } 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 bcc58db..b3213c5 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 @@ -61,9 +61,7 @@ import org.onebusaway.services.blocking.TripsForRouteServiceImpl import org.onebusaway.services.blocking.VehiclesForAgencyService import org.onebusaway.services.blocking.VehiclesForAgencyServiceImpl -class OnebusawaySdkClientImpl( - private val clientOptions: ClientOptions, -) : OnebusawaySdkClient { +class OnebusawaySdkClientImpl(private val clientOptions: ClientOptions) : OnebusawaySdkClient { private val clientOptionsWithUserAgent = if (clientOptions.headers.names().contains("User-Agent")) clientOptions @@ -78,6 +76,10 @@ class OnebusawaySdkClientImpl( OnebusawaySdkClientAsyncImpl(clientOptions) } + private val withRawResponse: OnebusawaySdkClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val agenciesWithCoverage: AgenciesWithCoverageService by lazy { AgenciesWithCoverageServiceImpl(clientOptionsWithUserAgent) } @@ -178,6 +180,8 @@ class OnebusawaySdkClientImpl( override fun async(): OnebusawaySdkClientAsync = async + override fun withRawResponse(): OnebusawaySdkClient.WithRawResponse = withRawResponse + override fun agenciesWithCoverage(): AgenciesWithCoverageService = agenciesWithCoverage override fun agency(): AgencyService = agency @@ -235,4 +239,183 @@ class OnebusawaySdkClientImpl( override fun shape(): ShapeService = shape override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OnebusawaySdkClient.WithRawResponse { + + private val agenciesWithCoverage: AgenciesWithCoverageService.WithRawResponse by lazy { + AgenciesWithCoverageServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val agency: AgencyService.WithRawResponse by lazy { + AgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val vehiclesForAgency: VehiclesForAgencyService.WithRawResponse by lazy { + VehiclesForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val config: ConfigService.WithRawResponse by lazy { + ConfigServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val currentTime: CurrentTimeService.WithRawResponse by lazy { + CurrentTimeServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForLocation: StopsForLocationService.WithRawResponse by lazy { + StopsForLocationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForRoute: StopsForRouteService.WithRawResponse by lazy { + StopsForRouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stopsForAgency: StopsForAgencyService.WithRawResponse by lazy { + StopsForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stop: StopService.WithRawResponse by lazy { + StopServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val stopIdsForAgency: StopIdsForAgencyService.WithRawResponse by lazy { + StopIdsForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val scheduleForStop: ScheduleForStopService.WithRawResponse by lazy { + ScheduleForStopServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val route: RouteService.WithRawResponse by lazy { + RouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val routeIdsForAgency: RouteIdsForAgencyService.WithRawResponse by lazy { + RouteIdsForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val routesForLocation: RoutesForLocationService.WithRawResponse by lazy { + RoutesForLocationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val routesForAgency: RoutesForAgencyService.WithRawResponse by lazy { + RoutesForAgencyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val scheduleForRoute: ScheduleForRouteService.WithRawResponse by lazy { + ScheduleForRouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val arrivalAndDeparture: ArrivalAndDepartureService.WithRawResponse by lazy { + ArrivalAndDepartureServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val trip: TripService.WithRawResponse by lazy { + TripServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tripsForLocation: TripsForLocationService.WithRawResponse by lazy { + TripsForLocationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tripDetails: TripDetailService.WithRawResponse by lazy { + TripDetailServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tripForVehicle: TripForVehicleService.WithRawResponse by lazy { + TripForVehicleServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tripsForRoute: TripsForRouteService.WithRawResponse by lazy { + TripsForRouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val reportProblemWithStop: ReportProblemWithStopService.WithRawResponse by lazy { + ReportProblemWithStopServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val reportProblemWithTrip: ReportProblemWithTripService.WithRawResponse by lazy { + ReportProblemWithTripServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val searchForStop: SearchForStopService.WithRawResponse by lazy { + SearchForStopServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val searchForRoute: SearchForRouteService.WithRawResponse by lazy { + SearchForRouteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val block: BlockService.WithRawResponse by lazy { + BlockServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val shape: ShapeService.WithRawResponse by lazy { + ShapeServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun agenciesWithCoverage(): AgenciesWithCoverageService.WithRawResponse = + agenciesWithCoverage + + override fun agency(): AgencyService.WithRawResponse = agency + + override fun vehiclesForAgency(): VehiclesForAgencyService.WithRawResponse = + vehiclesForAgency + + override fun config(): ConfigService.WithRawResponse = config + + override fun currentTime(): CurrentTimeService.WithRawResponse = currentTime + + override fun stopsForLocation(): StopsForLocationService.WithRawResponse = stopsForLocation + + override fun stopsForRoute(): StopsForRouteService.WithRawResponse = stopsForRoute + + override fun stopsForAgency(): StopsForAgencyService.WithRawResponse = stopsForAgency + + override fun stop(): StopService.WithRawResponse = stop + + override fun stopIdsForAgency(): StopIdsForAgencyService.WithRawResponse = stopIdsForAgency + + override fun scheduleForStop(): ScheduleForStopService.WithRawResponse = scheduleForStop + + override fun route(): RouteService.WithRawResponse = route + + override fun routeIdsForAgency(): RouteIdsForAgencyService.WithRawResponse = + routeIdsForAgency + + override fun routesForLocation(): RoutesForLocationService.WithRawResponse = + routesForLocation + + override fun routesForAgency(): RoutesForAgencyService.WithRawResponse = routesForAgency + + override fun scheduleForRoute(): ScheduleForRouteService.WithRawResponse = scheduleForRoute + + override fun arrivalAndDeparture(): ArrivalAndDepartureService.WithRawResponse = + arrivalAndDeparture + + override fun trip(): TripService.WithRawResponse = trip + + override fun tripsForLocation(): TripsForLocationService.WithRawResponse = tripsForLocation + + override fun tripDetails(): TripDetailService.WithRawResponse = tripDetails + + override fun tripForVehicle(): TripForVehicleService.WithRawResponse = tripForVehicle + + override fun tripsForRoute(): TripsForRouteService.WithRawResponse = tripsForRoute + + override fun reportProblemWithStop(): ReportProblemWithStopService.WithRawResponse = + reportProblemWithStop + + override fun reportProblemWithTrip(): ReportProblemWithTripService.WithRawResponse = + reportProblemWithTrip + + override fun searchForStop(): SearchForStopService.WithRawResponse = searchForStop + + override fun searchForRoute(): SearchForRouteService.WithRawResponse = searchForRoute + + override fun block(): BlockService.WithRawResponse = block + + override fun shape(): ShapeService.WithRawResponse = shape + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt index 9602a26..e2902a3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt @@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.BeanProperty import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.JavaType import com.fasterxml.jackson.databind.JsonDeserializer -import com.fasterxml.jackson.databind.JsonMappingException import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer @@ -18,7 +17,7 @@ abstract class BaseDeserializer(type: KClass) : override fun createContextual( context: DeserializationContext, - property: BeanProperty? + property: BeanProperty?, ): JsonDeserializer { return this } @@ -29,31 +28,17 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: TypeReference, - validate: (T) -> Unit = {} - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: JavaType, - validate: (T) -> Unit = {} - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt index b6fd22d..8ec084c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt @@ -2,9 +2,27 @@ package org.onebusaway.core +import com.fasterxml.jackson.core.Version +import com.fasterxml.jackson.core.util.VersionUtil + +fun checkRequired(name: String, condition: Boolean) = + check(condition) { "`$name` is required, but was not set" } + fun checkRequired(name: String, value: T?): T = checkNotNull(value) { "`$name` is required, but was not set" } +@JvmSynthetic +internal fun checkKnown(name: String, value: JsonField): T = + value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkKnown(name: String, value: MultipartField): T = + value.value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + @JvmSynthetic internal fun checkLength(name: String, value: String, length: Int): String = value.also { @@ -27,3 +45,52 @@ internal fun checkMaxLength(name: String, value: String, maxLength: Int): String "`$name` must have at most length $maxLength, but was ${it.length}" } } + +@JvmSynthetic +internal fun checkJacksonVersionCompatibility() { + val incompatibleJacksonVersions = + RUNTIME_JACKSON_VERSIONS.mapNotNull { + val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] + when { + it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> + it to "incompatible major version" + it.minorVersion < MINIMUM_JACKSON_VERSION.minorVersion -> + it to "minor version too low" + it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && + it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> + it to "patch version too low" + badVersionReason != null -> it to badVersionReason + else -> null + } + } + check(incompatibleJacksonVersions.isEmpty()) { + """ +This SDK requires a minimum Jackson version of $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: + +${incompatibleJacksonVersions.asSequence().map { (version, incompatibilityReason) -> + "- `${version.toFullString().replace("/", ":")}` ($incompatibilityReason)" +}.joinToString("\n")} + +This can happen if you are either: +1. Directly depending on different Jackson versions +2. Depending on some library that depends on different Jackson versions, potentially transitively + +Double-check that you are depending on compatible Jackson versions. + +See https://www.github.com/OneBusAway/java-sdk#jackson for more information. + """ + .trimIndent() + } +} + +private val MINIMUM_JACKSON_VERSION: Version = VersionUtil.parseVersion("2.13.4", null, null) +private val BAD_JACKSON_VERSIONS: Map = + mapOf("2.18.1" to "due to https://github.com/FasterXML/jackson-databind/issues/4639") +private val RUNTIME_JACKSON_VERSIONS: List = + listOf( + com.fasterxml.jackson.core.json.PackageVersion.VERSION, + com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jsr310.PackageVersion.VERSION, + com.fasterxml.jackson.module.kotlin.PackageVersion.VERSION, + ) 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 2e214a5..07ee264 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 @@ -14,22 +14,39 @@ class ClientOptions private constructor( private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, + @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, + @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, @get:JvmName("apiKey") val apiKey: String, ) { + init { + if (checkJacksonVersionCompatibility) { + checkJacksonVersionCompatibility() + } + } + fun toBuilder() = Builder().from(this) companion object { const val PRODUCTION_URL = "https://api.pugetsound.onebusaway.org" + /** + * Returns a mutable builder for constructing an instance of [ClientOptions]. + * + * The following fields are required: + * ```java + * .httpClient() + * .apiKey() + * ``` + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() @@ -39,30 +56,38 @@ private constructor( class Builder internal constructor() { private var httpClient: HttpClient? = null + private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() private var clock: Clock = Clock.systemUTC() private var baseUrl: String = PRODUCTION_URL private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false + private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 private var apiKey: String? = null @JvmSynthetic internal fun from(clientOptions: ClientOptions) = apply { httpClient = clientOptions.originalHttpClient + checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper clock = clientOptions.clock baseUrl = clientOptions.baseUrl headers = clientOptions.headers.toBuilder() queryParams = clientOptions.queryParams.toBuilder() responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries apiKey = clientOptions.apiKey } fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility + } + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } fun clock(clock: Clock) = apply { this.clock = clock } @@ -73,6 +98,8 @@ private constructor( this.responseValidation = responseValidation } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } @@ -157,8 +184,26 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun fromEnv() = apply { System.getenv("ONEBUSAWAY_API_KEY")?.let { apiKey(it) } } - + fun baseUrl(): String = baseUrl + + fun fromEnv() = apply { + System.getenv("ONEBUSAWAY_SDK_BASE_URL")?.let { baseUrl(it) } + System.getenv("ONEBUSAWAY_API_KEY")?.let { apiKey(it) } + } + + /** + * Returns an immutable instance of [ClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * .apiKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) val apiKey = checkRequired("apiKey", apiKey) @@ -174,7 +219,7 @@ private constructor( headers.put("X-Stainless-Runtime-Version", getJavaVersion()) apiKey.let { if (!it.isEmpty()) { - headers.put("key", it) + queryParams.put("key", it) } } headers.replaceAll(this.headers.build()) @@ -189,12 +234,14 @@ private constructor( .maxRetries(maxRetries) .build() ), + checkJacksonVersionCompatibility, jsonMapper, clock, baseUrl, headers.build(), queryParams.build(), responseValidation, + timeout, maxRetries, apiKey, ) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/HttpRequestBodies.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/HttpRequestBodies.kt deleted file mode 100644 index 6794cf7..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/HttpRequestBodies.kt +++ /dev/null @@ -1,111 +0,0 @@ -@file:JvmName("HttpRequestBodies") - -package org.onebusaway.core - -import com.fasterxml.jackson.databind.json.JsonMapper -import java.io.ByteArrayOutputStream -import java.io.OutputStream -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder -import org.onebusaway.core.http.HttpRequestBody -import org.onebusaway.errors.OnebusawaySdkException - -@JvmSynthetic -internal inline fun json( - jsonMapper: JsonMapper, - value: T, -): HttpRequestBody { - return object : HttpRequestBody { - private var cachedBytes: ByteArray? = null - - private fun serialize(): ByteArray { - if (cachedBytes != null) return cachedBytes!! - - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, value) - cachedBytes = buffer.toByteArray() - return cachedBytes!! - } catch (e: Exception) { - throw OnebusawaySdkException("Error writing request", e) - } - } - - override fun writeTo(outputStream: OutputStream) { - outputStream.write(serialize()) - } - - override fun contentType(): String = "application/json" - - override fun contentLength(): Long { - return serialize().size.toLong() - } - - override fun repeatable(): Boolean = true - - override fun close() {} - } -} - -@JvmSynthetic -internal fun multipartFormData( - jsonMapper: JsonMapper, - parts: Array?> -): HttpRequestBody { - val builder = MultipartEntityBuilder.create() - parts.forEach { part -> - if (part?.value != null) { - when (part.value) { - is JsonValue -> { - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, part.value) - } catch (e: Exception) { - throw OnebusawaySdkException("Error serializing value to json", e) - } - builder.addBinaryBody( - part.name, - buffer.toByteArray(), - part.contentType, - part.filename - ) - } - is Boolean -> - builder.addTextBody( - part.name, - if (part.value) "true" else "false", - part.contentType - ) - is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is ByteArray -> - builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) - is String -> builder.addTextBody(part.name, part.value, part.contentType) - is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - else -> - throw IllegalArgumentException( - "Unsupported content type: ${part.value::class.java.simpleName}" - ) - } - } - } - val entity = builder.build() - - return object : HttpRequestBody { - override fun writeTo(outputStream: OutputStream) { - try { - return entity.writeTo(outputStream) - } catch (e: Exception) { - throw OnebusawaySdkException("Error writing request", e) - } - } - - override fun contentType(): String = entity.contentType - - override fun contentLength(): Long = -1 - - override fun repeatable(): Boolean = entity.isRepeatable - - override fun close() = entity.close() - } -} 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 7a4b2f8..d00e718 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 @@ -3,23 +3,165 @@ package org.onebusaway.core import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.MapperFeature import com.fasterxml.jackson.databind.SerializationFeature -import com.fasterxml.jackson.databind.cfg.CoercionAction.Fail -import com.fasterxml.jackson.databind.cfg.CoercionInputShape.Integer +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.cfg.CoercionAction +import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.type.LogicalType import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder +import com.fasterxml.jackson.module.kotlin.kotlinModule +import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField fun jsonMapper(): JsonMapper = - jacksonMapperBuilder() + JsonMapper.builder() + .addModule(kotlinModule()) .addModule(Jdk8Module()) .addModule(JavaTimeModule()) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) + .withCoercionConfig(LogicalType.Boolean) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Integer) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Float) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Textual) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Array) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Collection) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Map) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.POJO) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + } .serializationInclusion(JsonInclude.Include.NON_ABSENT) .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) - .withCoercionConfig(String::class.java) { it.setCoercion(Integer, Fail) } + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(MapperFeature.AUTO_DETECT_CREATORS) + .disable(MapperFeature.AUTO_DETECT_FIELDS) + .disable(MapperFeature.AUTO_DETECT_GETTERS) + .disable(MapperFeature.AUTO_DETECT_IS_GETTERS) + .disable(MapperFeature.AUTO_DETECT_SETTERS) .build() + +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer + + override fun serialize( + value: InputStream?, + gen: JsonGenerator?, + serializers: SerializerProvider?, + ) { + if (value == null) { + gen?.writeNull() + } else { + value.use { gen?.writeBinary(it.readBytes()) } + } + } +} + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PrepareRequest.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PrepareRequest.kt index b78d6b6..5367d62 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PrepareRequest.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PrepareRequest.kt @@ -17,7 +17,7 @@ internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): @JvmSynthetic internal fun HttpRequest.prepareAsync( clientOptions: ClientOptions, - params: Params + params: Params, ): CompletableFuture = // This async version exists to make it easier to add async specific preparation logic in the // future. 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 653da53..0967032 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 @@ -2,17 +2,7 @@ package org.onebusaway.core import java.time.Duration -class RequestOptions -private constructor( - val responseValidation: Boolean?, - val timeout: Duration?, -) { - fun applyDefaults(options: RequestOptions): RequestOptions { - return RequestOptions( - responseValidation = this.responseValidation ?: options.responseValidation, - timeout = this.timeout ?: options.timeout, - ) - } +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { companion object { @@ -20,22 +10,37 @@ private constructor( @JvmStatic fun none() = NONE + @JvmSynthetic + internal fun from(clientOptions: ClientOptions): RequestOptions = + builder() + .responseValidation(clientOptions.responseValidation) + .timeout(clientOptions.timeout) + .build() + @JvmStatic fun builder() = Builder() } + fun applyDefaults(options: RequestOptions): RequestOptions = + RequestOptions( + responseValidation = responseValidation ?: options.responseValidation, + timeout = + if (options.timeout != null && timeout != null) timeout.assign(options.timeout) + else timeout ?: options.timeout, + ) + class Builder internal constructor() { private var responseValidation: Boolean? = null - private var timeout: Duration? = null + private var timeout: Timeout? = null fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } - fun build(): RequestOptions { - return RequestOptions(responseValidation, timeout) - } + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun build(): RequestOptions = RequestOptions(responseValidation, timeout) } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt new file mode 100644 index 0000000..db8d478 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core + +import java.time.Duration +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class containing timeouts for various processing phases of a request. */ +class Timeout +private constructor( + private val connect: Duration?, + private val read: Duration?, + private val write: Duration?, + private val request: Duration?, +) { + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(): Duration = connect ?: Duration.ofMinutes(1) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(): Duration = read ?: request() + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(): Duration = write ?: request() + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(): Duration = request ?: Duration.ofMinutes(1) + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun default() = builder().build() + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var connect: Duration? = null + private var read: Duration? = null + private var write: Duration? = null + private var request: Duration? = null + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Duration?) = apply { this.connect = connect } + + /** Alias for calling [Builder.connect] with `connect.orElse(null)`. */ + fun connect(connect: Optional) = connect(connect.getOrNull()) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Duration?) = apply { this.read = read } + + /** Alias for calling [Builder.read] with `read.orElse(null)`. */ + fun read(read: Optional) = read(read.getOrNull()) + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Duration?) = apply { this.write = write } + + /** Alias for calling [Builder.write] with `write.orElse(null)`. */ + fun write(write: Optional) = write(write.getOrNull()) + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Duration?) = apply { this.request = request } + + /** Alias for calling [Builder.request] with `request.orElse(null)`. */ + fun request(request: Optional) = request(request.getOrNull()) + + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timeout = Timeout(connect, read, write, request) + } + + @JvmSynthetic + internal fun assign(target: Timeout): Timeout = + target + .toBuilder() + .apply { + connect?.let(this::connect) + read?.let(this::read) + write?.let(this::write) + request?.let(this::request) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ + + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" +} 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 31e1d87..f887344 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 @@ -25,4 +25,68 @@ internal fun , V> SortedMap.toImmutable(): SortedMap> Sequence.allMaxBy(selector: (T) -> R): List { + var maxValue: R? = null + val maxElements = mutableListOf() + + val iterator = iterator() + while (iterator.hasNext()) { + val element = iterator.next() + val value = selector(element) + if (maxValue == null || value > maxValue) { + maxValue = value + maxElements.clear() + maxElements.add(element) + } else if (value == maxValue) { + maxElements.add(element) + } + } + + return maxElements +} + +/** + * Returns whether [this] is equal to [other]. + * + * This differs from [Object.equals] because it also deeply equates arrays based on their contents, + * even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal infix fun Any?.contentEquals(other: Any?): Boolean = + arrayOf(this).contentDeepEquals(arrayOf(other)) + +/** + * Returns a hash of the given sequence of [values]. + * + * This differs from [java.util.Objects.hash] because it also deeply hashes arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic internal fun contentHash(vararg values: Any?): Int = values.contentDeepHashCode() + +/** + * Returns a [String] representation of [this]. + * + * This differs from [Object.toString] because it also deeply stringifies arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal fun Any?.contentToString(): String { + var string = arrayOf(this).contentDeepToString() + if (string.startsWith('[')) { + string = string.substring(1) + } + if (string.endsWith(']')) { + string = string.substring(0, string.length - 1) + } + return string +} + internal interface Enum diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt index 387b30b..a630d24 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt @@ -1,8 +1,6 @@ package org.onebusaway.core import com.fasterxml.jackson.annotation.JacksonAnnotationsInside -import com.fasterxml.jackson.annotation.JsonAutoDetect -import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator @@ -26,69 +24,146 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer -import java.nio.charset.Charset +import java.io.InputStream import java.util.Objects import java.util.Optional -import org.apache.hc.core5.http.ContentType import org.onebusaway.errors.OnebusawaySdkInvalidDataException +/** + * A class representing a serializable JSON field. + * + * It can either be a [KnownValue] value of type [T], matching the type the SDK expects, or an + * arbitrary JSON value that bypasses the type system (via [JsonValue]). + */ @JsonDeserialize(using = JsonField.Deserializer::class) sealed class JsonField { + /** + * Returns whether this field is missing, which means it will be omitted from the serialized + * JSON entirely. + */ fun isMissing(): Boolean = this is JsonMissing + /** Whether this field is explicitly set to `null`. */ fun isNull(): Boolean = this is JsonNull - fun asKnown(): Optional = - when (this) { - is KnownValue -> Optional.of(value) - else -> Optional.empty() - } + /** + * Returns an [Optional] containing this field's "known" value, meaning it matches the type the + * SDK expects, or an empty [Optional] if this field contains an arbitrary [JsonValue]. + * + * This is the opposite of [asUnknown]. + */ + fun asKnown(): + Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = Optional.ofNullable((this as? KnownValue)?.value) /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API - * then this method will return an empty `Optional`, otherwise the returned `Optional` is given - * a `JsonValue`. + * Returns an [Optional] containing this field's arbitrary [JsonValue], meaning it mismatches + * the type the SDK expects, or an empty [Optional] if this field contains a "known" value. + * + * This is the opposite of [asKnown]. */ - fun asUnknown(): Optional = - when (this) { - is JsonValue -> Optional.of(this) - else -> Optional.empty() - } + fun asUnknown(): Optional = Optional.ofNullable(this as? JsonValue) + /** + * Returns an [Optional] containing this field's boolean value, or an empty [Optional] if it + * doesn't contain a boolean. + * + * This method checks for both a [KnownValue] containing a boolean and for [JsonBoolean]. + */ fun asBoolean(): Optional = when (this) { is JsonBoolean -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Boolean) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's numerical value, or an empty [Optional] if it + * doesn't contain a number. + * + * This method checks for both a [KnownValue] containing a number and for [JsonNumber]. + */ fun asNumber(): Optional = when (this) { is JsonNumber -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Number) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's string value, or an empty [Optional] if it + * doesn't contain a string. + * + * This method checks for both a [KnownValue] containing a string and for [JsonString]. + */ fun asString(): Optional = when (this) { is JsonString -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? String) else -> Optional.empty() } fun asStringOrThrow(): String = - when (this) { - is JsonString -> value - else -> throw OnebusawaySdkInvalidDataException("Value is not a string") - } + asString().orElseThrow { OnebusawaySdkInvalidDataException("Value is not a string") } + /** + * Returns an [Optional] containing this field's list value, or an empty [Optional] if it + * doesn't contain a list. + * + * This method checks for both a [KnownValue] containing a list and for [JsonArray]. + */ fun asArray(): Optional> = when (this) { is JsonArray -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? List<*>)?.map { + try { + JsonValue.from(it) + } catch (e: IllegalArgumentException) { + // The known value is a list, but not all values are convertible to + // `JsonValue`. + return Optional.empty() + } + } + ) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's map value, or an empty [Optional] if it doesn't + * contain a map. + * + * This method checks for both a [KnownValue] containing a map and for [JsonObject]. + */ fun asObject(): Optional> = when (this) { is JsonObject -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? Map<*, *>) + ?.map { (key, value) -> + if (key !is String) { + return Optional.empty() + } + + val jsonValue = + try { + JsonValue.from(value) + } catch (e: IllegalArgumentException) { + // The known value is a map, but not all items are convertible + // to `JsonValue`. + return Optional.empty() + } + + key to jsonValue + } + ?.toMap() + ) else -> Optional.empty() } @@ -96,20 +171,24 @@ sealed class JsonField { internal fun getRequired(name: String): T = when (this) { is KnownValue -> value - is JsonMissing -> throw OnebusawaySdkInvalidDataException("'${name}' is not set") - is JsonNull -> throw OnebusawaySdkInvalidDataException("'${name}' is null") - else -> - throw OnebusawaySdkInvalidDataException("'${name}' is invalid, received ${this}") + is JsonMissing -> throw OnebusawaySdkInvalidDataException("`$name` is not set") + is JsonNull -> throw OnebusawaySdkInvalidDataException("`$name` is null") + else -> throw OnebusawaySdkInvalidDataException("`$name` is invalid, received $this") } @JvmSynthetic - internal fun getNullable(name: String): T? = + internal fun getOptional( + name: String + ): Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = when (this) { - is KnownValue -> value - is JsonMissing -> null - is JsonNull -> null - else -> - throw OnebusawaySdkInvalidDataException("'${name}' is invalid, received ${this}") + is KnownValue -> Optional.of(value) + is JsonMissing, + is JsonNull -> Optional.empty() + else -> throw OnebusawaySdkInvalidDataException("`$name` is invalid, received $this") } @JvmSynthetic @@ -119,21 +198,33 @@ sealed class JsonField { is JsonValue -> this } - @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + @JvmSynthetic internal fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + /** Returns the result of calling the [visitor] method corresponding to this field's state. */ fun accept(visitor: Visitor): R = when (this) { is KnownValue -> visitor.visitKnown(value) is JsonValue -> accept(visitor as JsonValue.Visitor) } + /** + * An interface that defines how to map each possible state of a `JsonField` to a value of + * type [R]. + */ interface Visitor : JsonValue.Visitor { + fun visitKnown(value: T): R = visitDefault() } companion object { + + /** Returns a [JsonField] containing the given "known" [value]. */ @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + /** + * Returns a [JsonField] containing the given "known" [value], or [JsonNull] if [value] is + * null. + */ @JvmStatic fun ofNullable(value: T?): JsonField = when (value) { @@ -142,9 +233,13 @@ sealed class JsonField { } } - // This class is a Jackson filter that can be used to exclude missing properties from objects - // This filter should not be used directly and should instead use the @ExcludeMissing annotation + /** + * This class is a Jackson filter that can be used to exclude missing properties from objects. + * This filter should not be used directly and should instead use the @ExcludeMissing + * annotation. + */ class IsMissing { + override fun equals(other: Any?): Boolean = other is JsonMissing override fun hashCode(): Int = Objects.hash() @@ -156,21 +251,22 @@ sealed class JsonField { override fun createContextual( context: DeserializationContext, property: BeanProperty?, - ): JsonDeserializer> { - return Deserializer(context.contextualType?.containedType(0)) - } + ): JsonDeserializer> = Deserializer(context.contextualType?.containedType(0)) - override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> { - return type?.let { tryDeserialize(node, type) }?.let { of(it) } + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> = + type?.let { tryDeserialize(node, type) }?.let { of(it) } ?: JsonValue.fromJsonNode(node) - } - override fun getNullValue(context: DeserializationContext): JsonField<*> { - return JsonNull.of() - } + override fun getNullValue(context: DeserializationContext): JsonField<*> = JsonNull.of() } } +/** + * A class representing an arbitrary JSON value. + * + * It is immutable and assignable to any [JsonField], regardless of its expected type (i.e. its + * generic type argument). + */ @JsonDeserialize(using = JsonValue.Deserializer::class) sealed class JsonValue : JsonField() { @@ -178,6 +274,7 @@ sealed class JsonValue : JsonField() { fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + /** Returns the result of calling the [visitor] method corresponding to this value's variant. */ fun accept(visitor: Visitor): R = when (this) { is JsonMissing -> visitor.visitMissing() @@ -189,7 +286,12 @@ sealed class JsonValue : JsonField() { is JsonObject -> visitor.visitObject(values) } + /** + * An interface that defines how to map each variant state of a [JsonValue] to a value of type + * [R]. + */ interface Visitor { + fun visitNull(): R = visitDefault() fun visitMissing(): R = visitDefault() @@ -204,15 +306,52 @@ sealed class JsonValue : JsonField() { fun visitObject(values: Map): R = visitDefault() - fun visitDefault(): R { - throw RuntimeException("Unexpected value") - } + /** + * The default implementation for unimplemented visitor methods. + * + * @throws IllegalArgumentException in the default implementation. + */ + fun visitDefault(): R = throw IllegalArgumentException("Unexpected value") } companion object { private val JSON_MAPPER = jsonMapper() + /** + * Converts the given [value] to a [JsonValue]. + * + * This method works best on primitive types, [List] values, [Map] values, and nested + * combinations of these. For example: + * ```java + * // Create primitive JSON values + * JsonValue nullValue = JsonValue.from(null); + * JsonValue booleanValue = JsonValue.from(true); + * JsonValue numberValue = JsonValue.from(42); + * JsonValue stringValue = JsonValue.from("Hello World!"); + * + * // Create a JSON array value equivalent to `["Hello", "World"]` + * JsonValue arrayValue = JsonValue.from(List.of("Hello", "World")); + * + * // Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` + * JsonValue objectValue = JsonValue.from(Map.of( + * "a", 1, + * "b", 2 + * )); + * + * // Create an arbitrarily nested JSON equivalent to: + * // { + * // "a": [1, 2], + * // "b": [3, 4] + * // } + * JsonValue complexValue = JsonValue.from(Map.of( + * "a", List.of(1, 2), + * "b", List.of(3, 4) + * )); + * ``` + * + * @throws IllegalArgumentException if [value] is not JSON serializable. + */ @JvmStatic fun from(value: Any?): JsonValue = when (value) { @@ -221,6 +360,11 @@ sealed class JsonValue : JsonField() { else -> JSON_MAPPER.convertValue(value, JsonValue::class.java) } + /** + * Returns a [JsonValue] converted from the given Jackson [JsonNode]. + * + * @throws IllegalStateException for unsupported node types. + */ @JvmStatic fun fromJsonNode(node: JsonNode): JsonValue = when (node.nodeType) { @@ -242,16 +386,19 @@ sealed class JsonValue : JsonField() { } class Deserializer : BaseDeserializer(JsonValue::class) { - override fun ObjectCodec.deserialize(node: JsonNode): JsonValue { - return fromJsonNode(node) - } - override fun getNullValue(context: DeserializationContext?): JsonValue { - return JsonNull.of() - } + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue = fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext?): JsonValue = JsonNull.of() } } +/** + * A class representing a "known" JSON serializable value of type [T], matching the type the SDK + * expects. + * + * It is assignable to `JsonField`. + */ class KnownValue private constructor( @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T @@ -262,52 +409,67 @@ private constructor( return true } - return other is KnownValue<*> && value == other.value + return other is KnownValue<*> && value contentEquals other.value } - override fun hashCode() = value.hashCode() + override fun hashCode() = contentHash(value) - override fun toString() = value.toString() + override fun toString() = value.contentToString() companion object { + + /** Returns a [KnownValue] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) } } +/** + * A [JsonValue] representing an omitted JSON field. + * + * An instance of this class will cause a JSON field to be omitted from the serialized JSON + * entirely. + */ @JsonSerialize(using = JsonMissing.Serializer::class) class JsonMissing : JsonValue() { override fun toString() = "" companion object { + private val INSTANCE: JsonMissing = JsonMissing() + /** Returns the singleton instance of [JsonMissing]. */ @JvmStatic fun of() = INSTANCE } class Serializer : BaseSerializer(JsonMissing::class) { + override fun serialize( value: JsonMissing, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { - throw RuntimeException("JsonMissing cannot be serialized") + throw IllegalStateException("JsonMissing cannot be serialized") } } } +/** A [JsonValue] representing a JSON `null` value. */ @JsonSerialize(using = NullSerializer::class) class JsonNull : JsonValue() { override fun toString() = "null" companion object { + private val INSTANCE: JsonNull = JsonNull() + /** Returns the singleton instance of [JsonMissing]. */ @JsonCreator @JvmStatic fun of() = INSTANCE } } +/** A [JsonValue] representing a JSON boolean value. */ class JsonBoolean private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Boolean @@ -326,14 +488,18 @@ private constructor( override fun toString() = value.toString() companion object { + + /** Returns a [JsonBoolean] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: Boolean) = JsonBoolean(value) } } +/** A [JsonValue] representing a JSON number value. */ class JsonNumber private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Number ) : JsonValue() { + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -347,10 +513,13 @@ private constructor( override fun toString() = value.toString() companion object { + + /** Returns a [JsonNumber] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: Number) = JsonNumber(value) } } +/** A [JsonValue] representing a JSON string value. */ class JsonString private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: String @@ -369,10 +538,13 @@ private constructor( override fun toString() = value companion object { + + /** Returns a [JsonString] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: String) = JsonString(value) } } +/** A [JsonValue] representing a JSON array value. */ class JsonArray private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @@ -393,10 +565,13 @@ private constructor( override fun toString() = values.toString() companion object { + + /** Returns a [JsonArray] containing the given [values]. */ @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) } } +/** A [JsonValue] representing a JSON object value. */ class JsonObject private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @@ -417,124 +592,132 @@ private constructor( override fun toString() = values.toString() companion object { + + /** Returns a [JsonObject] containing the given [values]. */ @JsonCreator @JvmStatic fun of(values: Map) = JsonObject(values.toImmutable()) } } +/** A Jackson annotation for excluding fields set to [JsonMissing] from the serialized JSON. */ @JacksonAnnotationsInside -@JsonInclude( - JsonInclude.Include.CUSTOM, - valueFilter = JsonField.IsMissing::class, -) +@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) annotation class ExcludeMissing -@JacksonAnnotationsInside -@JsonAutoDetect( - getterVisibility = Visibility.NONE, - isGetterVisibility = Visibility.NONE, - setterVisibility = Visibility.NONE, - creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE -) -annotation class NoAutoDetect - -class MultipartFormValue -internal constructor( - val name: String, - val value: T, - val contentType: ContentType, - val filename: String? = null +/** A class representing a field in a `multipart/form-data` request. */ +class MultipartField +private constructor( + /** A [JsonField] value, which will be serialized to zero or more parts. */ + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: JsonField, + /** A content type for the serialized parts. */ + @get:JvmName("contentType") val contentType: String, + private val filename: String?, ) { - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - contentType, - filename, - when (value) { - is ByteArray -> value.contentHashCode() - is String -> value - is Boolean -> value - is Long -> value - is Double -> value - else -> value?.hashCode() - } - ) - } - return hashCode - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || this.javaClass != other.javaClass) return false + companion object { - other as MultipartFormValue<*> + /** + * Returns a [MultipartField] containing the given [value] as a [KnownValue]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: T?) = builder().value(value).build() + + /** + * Returns a [MultipartField] containing the given [value]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: JsonField) = builder().value(value).build() + + /** + * Returns a mutable builder for constructing an instance of [MultipartField]. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun builder() = Builder() + } - if (name != other.name || contentType != other.contentType || filename != other.filename) - return false + /** Returns the filename directive that will be included in the serialized field. */ + fun filename(): Optional = Optional.ofNullable(filename) - return when { - value is ByteArray && other.value is ByteArray -> value contentEquals other.value - else -> value?.equals(other.value) ?: (other.value == null) + @JvmSynthetic + internal fun map(transform: (T) -> R): MultipartField = + builder().value(value.map(transform)).contentType(contentType).filename(filename).build() + + /** A builder for [MultipartField]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var contentType: String? = null + private var filename: String? = null + + fun value(value: JsonField) = apply { this.value = value } + + fun value(value: T?) = value(JsonField.ofNullable(value)) + + fun contentType(contentType: String) = apply { this.contentType = contentType } + + fun filename(filename: String?) = apply { this.filename = filename } + + /** Alias for calling [Builder.filename] with `filename.orElse(null)`. */ + fun filename(filename: Optional) = filename(filename.orElse(null)) + + /** + * Returns an immutable instance of [MultipartField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MultipartField { + val value = checkRequired("value", value) + return MultipartField( + value, + contentType + ?: if ( + value is KnownValue && + (value.value is InputStream || value.value is ByteArray) + ) + "application/octet-stream" + else "text/plain; charset=utf-8", + filename, + ) } } - override fun toString(): String = - "MultipartFormValue{name=$name, contentType=$contentType, filename=$filename, value=${valueToString()}}" + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } + + override fun hashCode(): Int = hashCode - private fun valueToString(): String = - when (value) { - is ByteArray -> "ByteArray of size ${value.size}" - else -> value.toString() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - companion object { - internal fun fromString( - name: String, - value: String, - contentType: ContentType - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromBoolean( - name: String, - value: Boolean, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromLong( - name: String, - value: Long, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromDouble( - name: String, - value: Double, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromEnum( - name: String, - value: T, - contentType: ContentType - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromByteArray( - name: String, - value: ByteArray, - contentType: ContentType, - filename: String? = null - ): MultipartFormValue = MultipartFormValue(name, value, contentType, filename) + return other is MultipartField<*> && + value == other.value && + contentType == other.contentType && + filename == other.filename } -} -internal object ContentTypes { - val DefaultText = ContentType.create(ContentType.TEXT_PLAIN.mimeType, Charset.forName("UTF-8")) - val DefaultBinary = ContentType.DEFAULT_BINARY + override fun toString(): String = + "MultipartField{value=$value, contentType=$contentType, filename=$filename}" } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt index 621d820..2d6cd63 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt @@ -1,17 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + @file:JvmName("ErrorHandler") package org.onebusaway.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper -import java.io.ByteArrayInputStream -import java.io.InputStream -import org.onebusaway.core.http.Headers +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonValue import org.onebusaway.core.http.HttpResponse import org.onebusaway.core.http.HttpResponse.Handler import org.onebusaway.errors.BadRequestException import org.onebusaway.errors.InternalServerException import org.onebusaway.errors.NotFoundException -import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.errors.PermissionDeniedException import org.onebusaway.errors.RateLimitException import org.onebusaway.errors.UnauthorizedException @@ -19,109 +19,66 @@ import org.onebusaway.errors.UnexpectedStatusCodeException import org.onebusaway.errors.UnprocessableEntityException @JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { - val handler = jsonHandler(jsonMapper) +internal fun errorHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) - return object : Handler { - override fun handle(response: HttpResponse): OnebusawaySdkError = + return object : Handler { + override fun handle(response: HttpResponse): JsonValue = try { handler.handle(response) } catch (e: Exception) { - OnebusawaySdkError.builder().build() + JsonMissing.of() } } } @JvmSynthetic -internal fun Handler.withErrorHandler( - errorHandler: Handler -): Handler = +internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = object : Handler { - override fun handle(response: HttpResponse): T { + override fun handle(response: HttpResponse): T = when (val statusCode = response.statusCode()) { - in 200..299 -> { - return this@withErrorHandler.handle(response) - } - 400 -> { - val buffered = response.buffered() - throw BadRequestException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 401 -> { - val buffered = response.buffered() - throw UnauthorizedException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 403 -> { - val buffered = response.buffered() - throw PermissionDeniedException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 404 -> { - val buffered = response.buffered() - throw NotFoundException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 422 -> { - val buffered = response.buffered() - throw UnprocessableEntityException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 429 -> { - val buffered = response.buffered() - throw RateLimitException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - in 500..599 -> { - val buffered = response.buffered() - throw InternalServerException( - statusCode, - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - else -> { - val buffered = response.buffered() - throw UnexpectedStatusCodeException( - statusCode, - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } + in 200..299 -> this@withErrorHandler.handle(response) + 400 -> + throw BadRequestException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 401 -> + throw UnauthorizedException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 403 -> + throw PermissionDeniedException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 404 -> + throw NotFoundException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 422 -> + throw UnprocessableEntityException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 429 -> + throw RateLimitException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + in 500..599 -> + throw InternalServerException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + else -> + throw UnexpectedStatusCodeException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() } - } - } - -private fun HttpResponse.buffered(): HttpResponse { - val body = body().readBytes() - - return object : HttpResponse { - override fun statusCode(): Int = this@buffered.statusCode() - - override fun headers(): Headers = this@buffered.headers() - - override fun body(): InputStream = ByteArrayInputStream(body) - - override fun close() = this@buffered.close() } -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt index 6ae84af..18b8ac9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt @@ -6,16 +6,15 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.onebusaway.core.http.HttpResponse import org.onebusaway.core.http.HttpResponse.Handler -import org.onebusaway.errors.OnebusawaySdkException +import org.onebusaway.errors.OnebusawaySdkInvalidDataException @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = object : Handler { - override fun handle(response: HttpResponse): T { + override fun handle(response: HttpResponse): T = try { - return jsonMapper.readValue(response.body(), jacksonTypeRef()) + jsonMapper.readValue(response.body(), jacksonTypeRef()) } catch (e: Exception) { - throw OnebusawaySdkException("Error reading response", e) + throw OnebusawaySdkInvalidDataException("Error reading response", e) } - } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/AsyncStreamResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/AsyncStreamResponse.kt new file mode 100644 index 0000000..2f97f46 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/AsyncStreamResponse.kt @@ -0,0 +1,157 @@ +package org.onebusaway.core.http + +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference +import org.onebusaway.core.http.AsyncStreamResponse.Handler + +/** + * A class providing access to an API response as an asynchronous stream of chunks of type [T], + * where each chunk can be individually processed as soon as it arrives instead of waiting on the + * full response. + */ +interface AsyncStreamResponse { + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the client's configured or default thread pool. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler): AsyncStreamResponse + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the given [executor]. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse + + /** + * Returns a future that completes when a stream is fully consumed, errors, or gets closed + * early. + */ + fun onCompleteFuture(): CompletableFuture + + /** + * Closes this resource, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because this response should not be + * synchronously closed via try-with-resources. + */ + fun close() + + /** A class for handling streaming events. */ + fun interface Handler { + + /** Called whenever a chunk is received. */ + fun onNext(value: T) + + /** + * Called when a stream is fully consumed, errors, or gets closed early. + * + * [onNext] will not be called once this method is called. + * + * @param error Non-empty if the stream completed due to an error. + */ + fun onComplete(error: Optional) {} + } +} + +@JvmSynthetic +internal fun CompletableFuture>.toAsync(streamHandlerExecutor: Executor) = + PhantomReachableClosingAsyncStreamResponse( + object : AsyncStreamResponse { + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + init { + this@toAsync.whenComplete { _, error -> + // If an error occurs from the original future, then we should resolve the + // `onCompleteFuture` even if `subscribe` has not been called. + error?.let(onCompleteFuture::completeExceptionally) + } + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = + subscribe(handler, streamHandlerExecutor) + + override fun subscribe( + handler: Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + this@toAsync.whenCompleteAsync( + { streamResponse, futureError -> + if (state.get() == State.CLOSED) { + // Avoid doing any work if `close` was called before the future + // completed. + return@whenCompleteAsync + } + + if (futureError != null) { + // An error occurred before we started passing chunks to the handler. + handler.onComplete(Optional.of(futureError)) + return@whenCompleteAsync + } + + var streamError: Throwable? = null + try { + streamResponse.stream().forEach(handler::onNext) + } catch (e: Throwable) { + streamError = e + } + + try { + handler.onComplete(Optional.ofNullable(streamError)) + } finally { + try { + // Notify completion via the `onCompleteFuture` as well. This is in + // a separate `try-finally` block so that we still complete the + // future if `handler.onComplete` throws. + if (streamError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(streamError) + } + } finally { + close() + } + } + }, + executor, + ) + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + this@toAsync.whenComplete { streamResponse, error -> streamResponse?.close() } + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } + } + ) + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt index e6f6448..c3820c3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt @@ -6,7 +6,7 @@ import org.onebusaway.core.toImmutable class Headers private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() @@ -74,7 +74,7 @@ private constructor( values.toImmutable() } .toImmutable(), - size + size, ) } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt index bb0f294..aa57cf6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt @@ -1,5 +1,3 @@ -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.core.http import java.lang.AutoCloseable @@ -8,15 +6,21 @@ import org.onebusaway.core.RequestOptions interface HttpClient : AutoCloseable { - @JvmOverloads fun execute( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - @JvmOverloads + fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + fun executeAsync( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + fun executeAsync(request: HttpRequest): CompletableFuture = + executeAsync(request, RequestOptions.none()) + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBodies.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBodies.kt new file mode 100644 index 0000000..0822ec1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBodies.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("HttpRequestBodies") + +package org.onebusaway.core.http + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.node.JsonNodeType +import java.io.InputStream +import java.io.OutputStream +import kotlin.jvm.optionals.getOrNull +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.apache.hc.core5.http.ContentType +import org.apache.hc.core5.http.HttpEntity +import org.onebusaway.core.MultipartField +import org.onebusaway.errors.OnebusawaySdkInvalidDataException + +@JvmSynthetic +internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = + object : HttpRequestBody { + private val bytes: ByteArray by lazy { jsonMapper.writeValueAsBytes(value) } + + override fun writeTo(outputStream: OutputStream) = outputStream.write(bytes) + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long = bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + fields: Map>, +): HttpRequestBody = + object : HttpRequestBody { + private val entity: HttpEntity by lazy { + MultipartEntityBuilder.create() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + addBinaryBody( + name, + bytes, + ContentType.parseLenient(field.contentType), + field.filename().getOrNull(), + ) + } + } + } + .build() + } + + private fun serializePart( + name: String, + node: JsonNode, + ): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) + JsonNodeType.BOOLEAN -> + sequenceOf(name to node.booleanValue().toString().inputStream()) + JsonNodeType.NUMBER -> + sequenceOf(name to node.numberValue().toString().inputStream()) + JsonNodeType.ARRAY -> + node.elements().asSequence().flatMap { element -> serializePart(name, element) } + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> + throw OnebusawaySdkInvalidDataException( + "Unexpected JsonNode type: ${node.nodeType}" + ) + } + + private fun String.inputStream(): InputStream = toByteArray().inputStream() + + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = entity.contentLength + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt index b9617f4..4086d94 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt @@ -1,12 +1,11 @@ package org.onebusaway.core.http -import java.io.IOException import java.io.OutputStream import java.lang.AutoCloseable interface HttpRequestBody : AutoCloseable { - @Throws(IOException::class) fun writeTo(outputStream: OutputStream) + fun writeTo(outputStream: OutputStream) fun contentType(): String? @@ -21,5 +20,6 @@ interface HttpRequestBody : AutoCloseable { */ fun repeatable(): Boolean + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ override fun close() } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt index 1a3f27d..275cbd4 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt @@ -1,7 +1,8 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.core.http import java.io.InputStream -import java.lang.AutoCloseable interface HttpResponse : AutoCloseable { @@ -11,6 +12,9 @@ interface HttpResponse : AutoCloseable { fun body(): InputStream + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() + interface Handler { fun handle(response: HttpResponse): T diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponseFor.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponseFor.kt new file mode 100644 index 0000000..e63df9d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponseFor.kt @@ -0,0 +1,25 @@ +package org.onebusaway.core.http + +import java.io.InputStream + +interface HttpResponseFor : HttpResponse { + + fun parse(): T +} + +@JvmSynthetic +internal fun HttpResponse.parseable(parse: () -> T): HttpResponseFor = + object : HttpResponseFor { + + private val parsed: T by lazy { parse() } + + override fun parse(): T = parsed + + override fun statusCode(): Int = this@parseable.statusCode() + + override fun headers(): Headers = this@parseable.headers() + + override fun body(): InputStream = this@parseable.body() + + override fun close() = this@parseable.close() + } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingAsyncStreamResponse.kt new file mode 100644 index 0000000..ae64979 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -0,0 +1,56 @@ +package org.onebusaway.core.http + +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import org.onebusaway.core.closeWhenPhantomReachable +import org.onebusaway.core.http.AsyncStreamResponse.Handler + +/** + * A delegating wrapper around an `AsyncStreamResponse` that closes it once it's only phantom + * reachable. + * + * This class ensures the `AsyncStreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingAsyncStreamResponse( + private val asyncStreamResponse: AsyncStreamResponse +) : AsyncStreamResponse { + + /** + * An object used for keeping `asyncStreamResponse` open while the object is still reachable. + */ + private val reachabilityTracker = Object() + + init { + closeWhenPhantomReachable(reachabilityTracker, asyncStreamResponse::close) + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker)) + } + + override fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse = + apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker), executor) + } + + override fun onCompleteFuture(): CompletableFuture = + asyncStreamResponse.onCompleteFuture() + + override fun close() = asyncStreamResponse.close() +} + +/** + * A wrapper around a `Handler` that also references a `reachabilityTracker` object. + * + * Referencing the `reachabilityTracker` object prevents it from getting reclaimed while the handler + * is still reachable. + */ +private class TrackedHandler( + private val handler: Handler, + private val reachabilityTracker: Any, +) : Handler { + override fun onNext(value: T) = handler.onNext(value) + + override fun onComplete(error: Optional) = handler.onComplete(error) +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt index 756f8a2..cec4a4b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt @@ -19,7 +19,7 @@ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpCli override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture = httpClient.executeAsync(request, requestOptions) override fun close() = httpClient.close() diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingStreamResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingStreamResponse.kt new file mode 100644 index 0000000..2a7c4f1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingStreamResponse.kt @@ -0,0 +1,21 @@ +package org.onebusaway.core.http + +import java.util.stream.Stream +import org.onebusaway.core.closeWhenPhantomReachable + +/** + * A delegating wrapper around a `StreamResponse` that closes it once it's only phantom reachable. + * + * This class ensures the `StreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingStreamResponse( + private val streamResponse: StreamResponse +) : StreamResponse { + init { + closeWhenPhantomReachable(this, streamResponse) + } + + override fun stream(): Stream = streamResponse.stream() + + override fun close() = streamResponse.close() +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt index 1e9bbb7..e88dc5d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.core.http import org.onebusaway.core.toImmutable @@ -5,7 +7,7 @@ import org.onebusaway.core.toImmutable class QueryParams private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() 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 eb4f5ed..5aec683 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 @@ -23,15 +23,13 @@ import org.onebusaway.errors.OnebusawaySdkIoException class RetryingHttpClient private constructor( private val httpClient: HttpClient, + private val sleeper: Sleeper, private val clock: Clock, private val maxRetries: Int, private val idempotencyHeader: String?, ) : HttpClient { - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) } @@ -65,10 +63,10 @@ private constructor( null } - val backoffMillis = getRetryBackoffMillis(retries, response) + val backoffDuration = getRetryBackoffDuration(retries, response) // All responses must be closed, so close the failed one before retrying. response?.close() - Thread.sleep(backoffMillis.toMillis()) + sleeper.sleep(backoffDuration) } } @@ -100,7 +98,7 @@ private constructor( .handleAsync( fun( response: HttpResponse?, - throwable: Throwable? + throwable: Throwable?, ): CompletableFuture { if (response != null) { if (++retries > maxRetries || !shouldRetry(response)) { @@ -114,13 +112,13 @@ private constructor( } } - val backoffMillis = getRetryBackoffMillis(retries, response) + val backoffDuration = getRetryBackoffDuration(retries, response) // All responses must be closed, so close the failed one before retrying. response?.close() - return sleepAsync(backoffMillis.toMillis()).thenCompose { + return sleeper.sleepAsync(backoffDuration).thenCompose { executeWithRetries(requestWithRetryCount, requestOptions) } - }, + } ) { // Run in the same thread. it.run() @@ -183,7 +181,7 @@ private constructor( // retried. throwable is IOException || throwable is OnebusawaySdkIoException - private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { + private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After response @@ -201,8 +199,8 @@ private constructor( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, - DateTimeFormatter.RFC_1123_DATE_TIME - ) + DateTimeFormatter.RFC_1123_DATE_TIME, + ), ) } catch (e: DateTimeParseException) { null @@ -230,33 +228,40 @@ private constructor( companion object { - private val TIMER = Timer("RetryingHttpClient", true) - - private fun sleepAsync(millis: Long): CompletableFuture { - val future = CompletableFuture() - TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis - ) - return future - } - @JvmStatic fun builder() = Builder() } class Builder internal constructor() { private var httpClient: HttpClient? = null + private var sleeper: Sleeper = + object : Sleeper { + + private val timer = Timer("RetryingHttpClient", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + } private var clock: Clock = Clock.systemUTC() private var maxRetries: Int = 2 private var idempotencyHeader: String? = null fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + @JvmSynthetic internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + fun clock(clock: Clock) = apply { this.clock = clock } fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } @@ -266,9 +271,17 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( checkRequired("httpClient", httpClient), + sleeper, clock, maxRetries, idempotencyHeader, ) } + + internal interface Sleeper { + + fun sleep(duration: Duration) + + fun sleepAsync(duration: Duration): CompletableFuture + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/StreamResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/StreamResponse.kt new file mode 100644 index 0000000..08470f9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/StreamResponse.kt @@ -0,0 +1,19 @@ +package org.onebusaway.core.http + +import java.util.stream.Stream + +interface StreamResponse : AutoCloseable { + + fun stream(): Stream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} + +@JvmSynthetic +internal fun StreamResponse.map(transform: (T) -> R): StreamResponse = + object : StreamResponse { + override fun stream(): Stream = this@map.stream().map(transform) + + override fun close() = this@map.close() + } 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 036562b..2ed561f 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 @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers -class BadRequestException( - headers: Headers, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(400, headers, body, error) +class BadRequestException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OnebusawaySdkServiceException("400: $body", cause) { + + override fun statusCode(): Int = 400 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BadRequestException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BadRequestException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(badRequestException: BadRequestException) = apply { + headers = badRequestException.headers + body = badRequestException.body + cause = badRequestException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [BadRequestException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BadRequestException = + BadRequestException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} 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 b99d5f0..feb6ec9 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 @@ -1,10 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers -class InternalServerException( - statusCode: Int, - headers: Headers, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(statusCode, headers, body, error) +class InternalServerException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : OnebusawaySdkServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InternalServerException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalServerException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(internalServerException: InternalServerException) = apply { + statusCode = internalServerException.statusCode + headers = internalServerException.headers + body = internalServerException.body + cause = internalServerException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [InternalServerException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalServerException = + InternalServerException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} 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 d7215fd..d6aef12 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 @@ -1,9 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers -class NotFoundException( - headers: Headers, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(404, headers, body, error) +class NotFoundException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OnebusawaySdkServiceException("404: $body", cause) { + + override fun statusCode(): Int = 404 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NotFoundException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotFoundException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(notFoundException: NotFoundException) = apply { + headers = notFoundException.headers + body = notFoundException.body + cause = notFoundException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [NotFoundException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotFoundException = + NotFoundException(checkRequired("headers", headers), checkRequired("body", body), cause) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt deleted file mode 100644 index bf85359..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkError.kt +++ /dev/null @@ -1,76 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.errors - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import java.util.Objects -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class OnebusawaySdkError -@JsonCreator -private constructor( - @JsonAnyGetter - @ExcludeMissing - @JsonAnySetter - @get:JvmName("additionalProperties") - val additionalProperties: Map = immutableEmptyMap(), -) { - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnebusawaySdkError]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(onebusawaySdkError: OnebusawaySdkError) = apply { - additionalProperties = onebusawaySdkError.additionalProperties.toMutableMap() - } - - 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) - } - - fun build(): OnebusawaySdkError = OnebusawaySdkError(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OnebusawaySdkError && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - - override fun toString() = "OnebusawaySdkError{additionalProperties=$additionalProperties}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt index e65331d..9e14f04 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt @@ -1,23 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import org.onebusaway.core.JsonValue import org.onebusaway.core.http.Headers abstract class OnebusawaySdkServiceException -@JvmOverloads -constructor( - private val statusCode: Int, - private val headers: Headers, - private val body: String, - private val error: OnebusawaySdkError, - message: String = "$statusCode: $error", - cause: Throwable? = null -) : OnebusawaySdkException(message, cause) { - - fun statusCode(): Int = statusCode +protected constructor(message: String, cause: Throwable? = null) : + OnebusawaySdkException(message, cause) { - fun headers(): Headers = headers + abstract fun statusCode(): Int - fun body(): String = body + abstract fun headers(): Headers - fun error(): OnebusawaySdkError = error + abstract fun body(): JsonValue } 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 7c70b0b..28a3b5a 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 @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers -class PermissionDeniedException( - headers: Headers, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(403, headers, body, error) +class PermissionDeniedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OnebusawaySdkServiceException("403: $body", cause) { + + override fun statusCode(): Int = 403 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PermissionDeniedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PermissionDeniedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(permissionDeniedException: PermissionDeniedException) = apply { + headers = permissionDeniedException.headers + body = permissionDeniedException.body + cause = permissionDeniedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [PermissionDeniedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PermissionDeniedException = + PermissionDeniedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} 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 314ad3b..8e68c49 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 @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers -class RateLimitException( - headers: Headers, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(429, headers, body, error) +class RateLimitException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OnebusawaySdkServiceException("429: $body", cause) { + + override fun statusCode(): Int = 429 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RateLimitException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RateLimitException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(rateLimitException: RateLimitException) = apply { + headers = rateLimitException.headers + body = rateLimitException.body + cause = rateLimitException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [RateLimitException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RateLimitException = + RateLimitException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} 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 7b6a7a3..79e2116 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 @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers -class UnauthorizedException( - headers: Headers, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(401, headers, body, error) +class UnauthorizedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OnebusawaySdkServiceException("401: $body", cause) { + + override fun statusCode(): Int = 401 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnauthorizedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnauthorizedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unauthorizedException: UnauthorizedException) = apply { + headers = unauthorizedException.headers + body = unauthorizedException.body + cause = unauthorizedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnauthorizedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnauthorizedException = + UnauthorizedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} 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 192fed6..f4aaa51 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 @@ -1,10 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers -class UnexpectedStatusCodeException( - statusCode: Int, - headers: Headers, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(statusCode, headers, body, error) +class UnexpectedStatusCodeException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : OnebusawaySdkServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnexpectedStatusCodeException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnexpectedStatusCodeException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unexpectedStatusCodeException: UnexpectedStatusCodeException) = apply { + statusCode = unexpectedStatusCodeException.statusCode + headers = unexpectedStatusCodeException.headers + body = unexpectedStatusCodeException.body + cause = unexpectedStatusCodeException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnexpectedStatusCodeException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnexpectedStatusCodeException = + UnexpectedStatusCodeException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} 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 bc0e0a7..be66612 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 @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.errors +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.JsonValue +import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers -class UnprocessableEntityException( - headers: Headers, - body: String, - error: OnebusawaySdkError, -) : OnebusawaySdkServiceException(422, headers, body, error) +class UnprocessableEntityException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OnebusawaySdkServiceException("422: $body", cause) { + + override fun statusCode(): Int = 422 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnprocessableEntityException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnprocessableEntityException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unprocessableEntityException: UnprocessableEntityException) = apply { + headers = unprocessableEntityException.headers + body = unprocessableEntityException.body + cause = unprocessableEntityException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnprocessableEntityException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnprocessableEntityException = + UnprocessableEntityException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt deleted file mode 100644 index b2224d0..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListResponse.kt +++ /dev/null @@ -1,489 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class AgenciesWithCoverageListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): AgenciesWithCoverageListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AgenciesWithCoverageListResponse]. */ - 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(agenciesWithCoverageListResponse: AgenciesWithCoverageListResponse) = - apply { - code = agenciesWithCoverageListResponse.code - currentTime = agenciesWithCoverageListResponse.currentTime - text = agenciesWithCoverageListResponse.text - version = agenciesWithCoverageListResponse.version - data = agenciesWithCoverageListResponse.data - additionalProperties = - agenciesWithCoverageListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): AgenciesWithCoverageListResponse = - AgenciesWithCoverageListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded - list = data.list.map { it.toMutableList() } - references = data.references - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("agencyId") - @ExcludeMissing - private val agencyId: JsonField = JsonMissing.of(), - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("latSpan") - @ExcludeMissing - private val latSpan: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonProperty("lonSpan") - @ExcludeMissing - private val lonSpan: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun lat(): Double = lat.getRequired("lat") - - fun latSpan(): Double = latSpan.getRequired("latSpan") - - fun lon(): Double = lon.getRequired("lon") - - fun lonSpan(): Double = lonSpan.getRequired("lonSpan") - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - @JsonProperty("latSpan") @ExcludeMissing fun _latSpan(): JsonField = latSpan - - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonProperty("lonSpan") @ExcludeMissing fun _lonSpan(): JsonField = lonSpan - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - agencyId() - lat() - latSpan() - lon() - lonSpan() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal constructor() { - - private var agencyId: JsonField? = null - private var lat: JsonField? = null - private var latSpan: JsonField? = null - private var lon: JsonField? = null - private var lonSpan: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - agencyId = list.agencyId - lat = list.lat - latSpan = list.latSpan - lon = list.lon - lonSpan = list.lonSpan - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun latSpan(latSpan: Double) = latSpan(JsonField.of(latSpan)) - - fun latSpan(latSpan: JsonField) = apply { this.latSpan = latSpan } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun lonSpan(lonSpan: Double) = lonSpan(JsonField.of(lonSpan)) - - fun lonSpan(lonSpan: JsonField) = apply { this.lonSpan = lonSpan } - - 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) - } - - fun build(): List = - List( - checkRequired("agencyId", agencyId), - checkRequired("lat", lat), - checkRequired("latSpan", latSpan), - checkRequired("lon", lon), - checkRequired("lonSpan", lonSpan), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && agencyId == other.agencyId && lat == other.lat && latSpan == other.latSpan && lon == other.lon && lonSpan == other.lonSpan && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(agencyId, lat, latSpan, lon, lonSpan, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "List{agencyId=$agencyId, lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AgenciesWithCoverageListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AgenciesWithCoverageListResponse{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/AgencyRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt deleted file mode 100644 index 15b8791..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveResponse.kt +++ /dev/null @@ -1,557 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class AgencyRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): AgencyRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AgencyRetrieveResponse]. */ - 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(agencyRetrieveResponse: AgencyRetrieveResponse) = apply { - code = agencyRetrieveResponse.code - currentTime = agencyRetrieveResponse.currentTime - text = agencyRetrieveResponse.text - version = agencyRetrieveResponse.version - data = agencyRetrieveResponse.data - additionalProperties = agencyRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): AgencyRetrieveResponse = - AgencyRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - limitExceeded() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - 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() - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("limitExceeded", limitExceeded), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("timezone") - @ExcludeMissing - private val timezone: JsonField = JsonMissing.of(), - @JsonProperty("url") - @ExcludeMissing - private val url: JsonField = JsonMissing.of(), - @JsonProperty("disclaimer") - @ExcludeMissing - private val disclaimer: JsonField = JsonMissing.of(), - @JsonProperty("email") - @ExcludeMissing - private val email: JsonField = JsonMissing.of(), - @JsonProperty("fareUrl") - @ExcludeMissing - private val fareUrl: JsonField = JsonMissing.of(), - @JsonProperty("lang") - @ExcludeMissing - private val lang: JsonField = JsonMissing.of(), - @JsonProperty("phone") - @ExcludeMissing - private val phone: JsonField = JsonMissing.of(), - @JsonProperty("privateService") - @ExcludeMissing - private val privateService: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - fun timezone(): String = timezone.getRequired("timezone") - - fun url(): String = url.getRequired("url") - - fun disclaimer(): Optional = - Optional.ofNullable(disclaimer.getNullable("disclaimer")) - - fun email(): Optional = Optional.ofNullable(email.getNullable("email")) - - fun fareUrl(): Optional = Optional.ofNullable(fareUrl.getNullable("fareUrl")) - - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - - fun phone(): Optional = Optional.ofNullable(phone.getNullable("phone")) - - fun privateService(): Optional = - Optional.ofNullable(privateService.getNullable("privateService")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone - - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - @JsonProperty("disclaimer") - @ExcludeMissing - fun _disclaimer(): JsonField = disclaimer - - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl(): JsonField = fareUrl - - @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang - - @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone - - @JsonProperty("privateService") - @ExcludeMissing - fun _privateService(): JsonField = privateService - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - id() - name() - timezone() - url() - disclaimer() - email() - fareUrl() - lang() - phone() - privateService() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var timezone: JsonField? = null - private var url: JsonField? = null - private var disclaimer: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var fareUrl: JsonField = JsonMissing.of() - private var lang: JsonField = JsonMissing.of() - private var phone: JsonField = JsonMissing.of() - private var privateService: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - id = entry.id - name = entry.name - timezone = entry.timezone - url = entry.url - disclaimer = entry.disclaimer - email = entry.email - fareUrl = entry.fareUrl - lang = entry.lang - phone = entry.phone - privateService = entry.privateService - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun timezone(timezone: String) = timezone(JsonField.of(timezone)) - - fun timezone(timezone: JsonField) = apply { this.timezone = timezone } - - fun url(url: String) = url(JsonField.of(url)) - - fun url(url: JsonField) = apply { this.url = url } - - fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) - - fun disclaimer(disclaimer: JsonField) = apply { - this.disclaimer = disclaimer - } - - fun email(email: String) = email(JsonField.of(email)) - - fun email(email: JsonField) = apply { this.email = email } - - fun fareUrl(fareUrl: String) = fareUrl(JsonField.of(fareUrl)) - - fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } - - fun lang(lang: String) = lang(JsonField.of(lang)) - - fun lang(lang: JsonField) = apply { this.lang = lang } - - fun phone(phone: String) = phone(JsonField.of(phone)) - - fun phone(phone: JsonField) = apply { this.phone = phone } - - fun privateService(privateService: Boolean) = - privateService(JsonField.of(privateService)) - - fun privateService(privateService: JsonField) = apply { - this.privateService = privateService - } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("timezone", timezone), - checkRequired("url", url), - disclaimer, - email, - fareUrl, - lang, - phone, - privateService, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && id == other.id && name == other.name && timezone == other.timezone && url == other.url && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && lang == other.lang && phone == other.phone && privateService == other.privateService && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, timezone, url, disclaimer, email, fareUrl, lang, phone, privateService, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{id=$id, name=$name, timezone=$timezone, url=$url, disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, lang=$lang, phone=$phone, privateService=$privateService, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && limitExceeded == other.limitExceeded && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, limitExceeded, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{entry=$entry, limitExceeded=$limitExceeded, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AgencyRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AgencyRetrieveResponse{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/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt deleted file mode 100644 index a5dff47..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListResponse.kt +++ /dev/null @@ -1,2589 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class ArrivalAndDepartureListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): ArrivalAndDepartureListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ArrivalAndDepartureListResponse]. */ - 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(arrivalAndDepartureListResponse: ArrivalAndDepartureListResponse) = - apply { - code = arrivalAndDepartureListResponse.code - currentTime = arrivalAndDepartureListResponse.currentTime - text = arrivalAndDepartureListResponse.text - version = arrivalAndDepartureListResponse.version - data = arrivalAndDepartureListResponse.data - additionalProperties = - arrivalAndDepartureListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): ArrivalAndDepartureListResponse = - ArrivalAndDepartureListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("arrivalsAndDepartures") - @ExcludeMissing - private val arrivalsAndDepartures: JsonField> = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun arrivalsAndDepartures(): List = - arrivalsAndDepartures.getRequired("arrivalsAndDepartures") - - @JsonProperty("arrivalsAndDepartures") - @ExcludeMissing - fun _arrivalsAndDepartures(): JsonField> = - arrivalsAndDepartures - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - arrivalsAndDepartures().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var arrivalsAndDepartures: JsonField>? = - null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - arrivalsAndDepartures = entry.arrivalsAndDepartures.map { it.toMutableList() } - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun arrivalsAndDepartures(arrivalsAndDepartures: List) = - arrivalsAndDepartures(JsonField.of(arrivalsAndDepartures)) - - fun arrivalsAndDepartures( - arrivalsAndDepartures: JsonField> - ) = apply { - this.arrivalsAndDepartures = arrivalsAndDepartures.map { it.toMutableList() } - } - - fun addArrivalsAndDeparture(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { - arrivalsAndDepartures = - (arrivalsAndDepartures ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(arrivalsAndDeparture) - } - } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("arrivalsAndDepartures", arrivalsAndDepartures).map { - it.toImmutable() - }, - additionalProperties.toImmutable() - ) - } - - @NoAutoDetect - class ArrivalsAndDeparture - @JsonCreator - private constructor( - @JsonProperty("arrivalEnabled") - @ExcludeMissing - private val arrivalEnabled: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("departureEnabled") - @ExcludeMissing - private val departureEnabled: JsonField = JsonMissing.of(), - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - private val numberOfStopsAway: JsonField = JsonMissing.of(), - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - private val predictedArrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - private val predictedDepartureTime: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - private val scheduledArrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - private val scheduledDepartureTime: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonProperty("stopSequence") - @ExcludeMissing - private val stopSequence: JsonField = JsonMissing.of(), - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - private val totalStopsInTrip: JsonField = JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - private val tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonProperty("actualTrack") - @ExcludeMissing - private val actualTrack: JsonField = JsonMissing.of(), - @JsonProperty("distanceFromStop") - @ExcludeMissing - private val distanceFromStop: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("historicalOccupancy") - @ExcludeMissing - private val historicalOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - private val predictedArrivalInterval: JsonField = JsonMissing.of(), - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - private val predictedDepartureInterval: JsonField = JsonMissing.of(), - @JsonProperty("predictedOccupancy") - @ExcludeMissing - private val predictedOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("routeLongName") - @ExcludeMissing - private val routeLongName: JsonField = JsonMissing.of(), - @JsonProperty("routeShortName") - @ExcludeMissing - private val routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - private val scheduledArrivalInterval: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - private val scheduledDepartureInterval: JsonField = JsonMissing.of(), - @JsonProperty("scheduledTrack") - @ExcludeMissing - private val scheduledTrack: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("tripStatus") - @ExcludeMissing - private val tripStatus: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** Indicates if riders can depart from this transit vehicle. */ - fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(): Long = - predictedArrivalTime.getRequired("predictedArrivalTime") - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(): Long = - predictedDepartureTime.getRequired("predictedDepartureTime") - - /** The ID of the route for the arriving vehicle. */ - fun routeId(): String = routeId.getRequired("routeId") - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(): Long = - scheduledArrivalTime.getRequired("scheduledArrivalTime") - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(): String = stopId.getRequired("stopId") - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - fun stopSequence(): Long = stopSequence.getRequired("stopSequence") - - /** Total number of stops visited on the trip for this arrival. */ - fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(): String = tripId.getRequired("tripId") - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(): Optional = - Optional.ofNullable(actualTrack.getNullable("actualTrack")) - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - fun distanceFromStop(): Optional = - Optional.ofNullable(distanceFromStop.getNullable("distanceFromStop")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Historical occupancy information of the transit vehicle. */ - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - /** Timestamp of the last update time for this arrival. */ - fun lastUpdateTime(): Optional = - Optional.ofNullable(lastUpdateTime.getNullable("lastUpdateTime")) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): Optional = - Optional.ofNullable(occupancyStatus.getNullable("occupancyStatus")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Optional = - Optional.ofNullable(predicted.getNullable("predicted")) - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(): Optional = - Optional.ofNullable( - predictedArrivalInterval.getNullable("predictedArrivalInterval") - ) - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(): Optional = - Optional.ofNullable( - predictedDepartureInterval.getNullable("predictedDepartureInterval") - ) - - /** Predicted occupancy status of the transit vehicle. */ - fun predictedOccupancy(): Optional = - Optional.ofNullable(predictedOccupancy.getNullable("predictedOccupancy")) - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - fun routeLongName(): Optional = - Optional.ofNullable(routeLongName.getNullable("routeLongName")) - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(): Optional = - Optional.ofNullable( - scheduledArrivalInterval.getNullable("scheduledArrivalInterval") - ) - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(): Optional = - Optional.ofNullable( - scheduledDepartureInterval.getNullable("scheduledDepartureInterval") - ) - - /** Scheduled track information of the arriving transit vehicle. */ - fun scheduledTrack(): Optional = - Optional.ofNullable(scheduledTrack.getNullable("scheduledTrack")) - - /** References to situation elements (if any) applicable to this arrival. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status of the arrival. */ - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(): Optional = - Optional.ofNullable(tripStatus.getNullable("tripStatus")) - - /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun _arrivalEnabled(): JsonField = arrivalEnabled - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** Indicates if riders can depart from this transit vehicle. */ - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled(): JsonField = departureEnabled - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - fun _numberOfStopsAway(): JsonField = numberOfStopsAway - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - fun _predictedArrivalTime(): JsonField = predictedArrivalTime - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - fun _predictedDepartureTime(): JsonField = predictedDepartureTime - - /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - fun _scheduledArrivalTime(): JsonField = scheduledArrivalTime - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - fun _scheduledDepartureTime(): JsonField = scheduledDepartureTime - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - @JsonProperty("stopSequence") - @ExcludeMissing - fun _stopSequence(): JsonField = stopSequence - - /** Total number of stops visited on the trip for this arrival. */ - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - fun _totalStopsInTrip(): JsonField = totalStopsInTrip - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun _tripHeadsign(): JsonField = tripHeadsign - - /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - - /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") - @ExcludeMissing - fun _actualTrack(): JsonField = actualTrack - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing - fun _distanceFromStop(): JsonField = distanceFromStop - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy(): JsonField = historicalOccupancy - - /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - fun _predictedArrivalInterval(): JsonField = predictedArrivalInterval - - /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - fun _predictedDepartureInterval(): JsonField = predictedDepartureInterval - - /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing - fun _predictedOccupancy(): JsonField = predictedOccupancy - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - @JsonProperty("routeLongName") - @ExcludeMissing - fun _routeLongName(): JsonField = routeLongName - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - @JsonProperty("routeShortName") - @ExcludeMissing - fun _routeShortName(): JsonField = routeShortName - - /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - fun _scheduledArrivalInterval(): JsonField = scheduledArrivalInterval - - /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - fun _scheduledDepartureInterval(): JsonField = scheduledDepartureInterval - - /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") - @ExcludeMissing - fun _scheduledTrack(): JsonField = scheduledTrack - - /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** Current status of the arrival. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") - @ExcludeMissing - fun _tripStatus(): JsonField = tripStatus - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Indicates if riders can arrive on this transit vehicle. */ - 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)) - - /** - * Index of this arrival’s trip into the sequence of trips for the active block. - */ - 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)) - - /** Indicates if riders can depart from this transit vehicle. */ - 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)) - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - 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)) - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - 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)) - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no - * real-time available). - */ - 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)) - - /** The ID of the route for the arriving vehicle. */ - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: Long) = - scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { - this.scheduledArrivalTime = scheduledArrivalTime - } - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(scheduledDepartureTime: Long) = - scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - 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)) - - /** The ID of the stop the vehicle is arriving at. */ - 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)) - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - 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)) - - /** Total number of stops visited on the trip for this arrival. */ - 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)) - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - 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)) - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle serving this trip. */ - 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)) - - /** The actual track information of the arriving transit vehicle. */ - 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)) - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - 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)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** Historical occupancy information of the transit vehicle. */ - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - /** Historical occupancy information of the transit vehicle. */ - 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)) - - /** Timestamp of the last update time for this arrival. */ - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: JsonField) = apply { - this.predicted = predicted - } - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: String) = - predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = - apply { - this.predictedArrivalInterval = predictedArrivalInterval - } - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: String) = - predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = - apply { - this.predictedDepartureInterval = predictedDepartureInterval - } - - /** Predicted occupancy status of the transit vehicle. */ - fun predictedOccupancy(predictedOccupancy: String) = - predictedOccupancy(JsonField.of(predictedOccupancy)) - - /** Predicted occupancy status of the transit vehicle. */ - 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)) - - /** - * Optional route long name that potentially overrides the route long name in - * the referenced route element. - */ - 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)) - - /** - * Optional route short name that potentially overrides the route short name in - * the referenced route element. - */ - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: String) = - scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = - apply { - this.scheduledArrivalInterval = scheduledArrivalInterval - } - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: String) = - scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = - apply { - this.scheduledDepartureInterval = scheduledDepartureInterval - } - - /** Scheduled track information of the arriving transit vehicle. */ - fun scheduledTrack(scheduledTrack: String) = - scheduledTrack(JsonField.of(scheduledTrack)) - - /** Scheduled track information of the arriving transit vehicle. */ - 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)) - - /** References to situation elements (if any) applicable to this arrival. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** References to situation elements (if any) applicable to this arrival. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** Current status of the arrival. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status of the arrival. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) - - /** Trip-specific status for the arriving transit vehicle. */ - 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) - } - - 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.toImmutable(), - ) - } - - /** Trip-specific status for the arriving transit vehicle. */ - @NoAutoDetect - class TripStatus - @JsonCreator - private constructor( - @JsonProperty("activeTripId") - @ExcludeMissing - private val activeTripId: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("closestStop") - @ExcludeMissing - private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCapacity") - @ExcludeMissing - private val occupancyCapacity: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCount") - @ExcludeMissing - private val occupancyCount: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDeviation") - @ExcludeMissing - private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = - blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - fun distanceAlongTrip(): Double = - distanceAlongTrip.getRequired("distanceAlongTrip") - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = - occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable( - closestStopTimeOffset.getNullable("closestStopTimeOffset") - ) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable( - lastKnownOrientation.getNullable("lastKnownOrientation") - ) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun _activeTripId(): JsonField = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun _closestStop(): JsonField = closestStop - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip(): JsonField = - lastKnownDistanceAlongTrip - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity(): JsonField = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount(): JsonField = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation(): JsonField = scheduleDeviation - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** Current status modifiers for the trip. */ - @JsonProperty("status") - @ExcludeMissing - fun _status(): JsonField = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation(): JsonField = lastKnownLocation - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation(): JsonField = lastKnownOrientation - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun _nextStop(): JsonField = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun _orientation(): JsonField = orientation - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip(): JsonField = - scheduledDistanceAlongTrip - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Trip ID of the trip the vehicle is actively serving. */ - 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)) - - /** - * Index of the active trip into the sequence of trips for the active block. - */ - 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)) - - /** - * ID of the closest stop to the current location of the transit vehicle. - */ - 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)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - 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)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - 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)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - 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)) - - /** - * Timestamp of the last known real-time update from the transit vehicle. - */ - 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)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - 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)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of - * the service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - 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)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - 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)) - - /** - * Information about frequency-based scheduling, if applicable to the trip. - */ - fun frequency(frequency: JsonField) = apply { - 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. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit - * vehicle. - */ - 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)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit - * vehicle (in seconds). - */ - 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)) - - /** - * Orientation of the transit vehicle, represented as an angle in degrees. - */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - 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)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** References to situation elements (if any) applicable to this trip. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - 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) - } - - 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.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @NoAutoDetect - class LastKnownLocation - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LastKnownLocation = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the last known location of the transit vehicle. */ - 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)) - - /** Longitude of the last known location of the transit vehicle. */ - 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) - } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @NoAutoDetect - class Position - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Position = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the current position of the transit vehicle. */ - 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)) - - /** Longitude of the current position of the transit vehicle. */ - 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) - } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - 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 /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - 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}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && arrivalsAndDepartures == other.arrivalsAndDepartures && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalsAndDepartures, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{arrivalsAndDepartures=$arrivalsAndDepartures, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is ArrivalAndDepartureListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ArrivalAndDepartureListResponse{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/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt deleted file mode 100644 index cfc7751..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveResponse.kt +++ /dev/null @@ -1,2390 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class ArrivalAndDepartureRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): ArrivalAndDepartureRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ArrivalAndDepartureRetrieveResponse]. */ - 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( - arrivalAndDepartureRetrieveResponse: ArrivalAndDepartureRetrieveResponse - ) = apply { - code = arrivalAndDepartureRetrieveResponse.code - currentTime = arrivalAndDepartureRetrieveResponse.currentTime - text = arrivalAndDepartureRetrieveResponse.text - version = arrivalAndDepartureRetrieveResponse.version - data = arrivalAndDepartureRetrieveResponse.data - additionalProperties = - arrivalAndDepartureRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): ArrivalAndDepartureRetrieveResponse = - ArrivalAndDepartureRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("arrivalEnabled") - @ExcludeMissing - private val arrivalEnabled: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("departureEnabled") - @ExcludeMissing - private val departureEnabled: JsonField = JsonMissing.of(), - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - private val numberOfStopsAway: JsonField = JsonMissing.of(), - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - private val predictedArrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - private val predictedDepartureTime: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - private val scheduledArrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - private val scheduledDepartureTime: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonProperty("stopSequence") - @ExcludeMissing - private val stopSequence: JsonField = JsonMissing.of(), - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - private val totalStopsInTrip: JsonField = JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - private val tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonProperty("actualTrack") - @ExcludeMissing - private val actualTrack: JsonField = JsonMissing.of(), - @JsonProperty("distanceFromStop") - @ExcludeMissing - private val distanceFromStop: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("historicalOccupancy") - @ExcludeMissing - private val historicalOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - private val predictedArrivalInterval: JsonField = JsonMissing.of(), - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - private val predictedDepartureInterval: JsonField = JsonMissing.of(), - @JsonProperty("predictedOccupancy") - @ExcludeMissing - private val predictedOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("routeLongName") - @ExcludeMissing - private val routeLongName: JsonField = JsonMissing.of(), - @JsonProperty("routeShortName") - @ExcludeMissing - private val routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - private val scheduledArrivalInterval: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - private val scheduledDepartureInterval: JsonField = JsonMissing.of(), - @JsonProperty("scheduledTrack") - @ExcludeMissing - private val scheduledTrack: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("tripStatus") - @ExcludeMissing - private val tripStatus: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** Indicates if riders can depart from this transit vehicle. */ - fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") - - /** - * Number of stops between the arriving transit vehicle and the current stop (excluding - * the current stop). - */ - fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedArrivalTime(): Long = - predictedArrivalTime.getRequired("predictedArrivalTime") - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - fun predictedDepartureTime(): Long = - predictedDepartureTime.getRequired("predictedDepartureTime") - - /** The ID of the route for the arriving vehicle. */ - fun routeId(): String = routeId.getRequired("routeId") - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(): Long = - scheduledArrivalTime.getRequired("scheduledArrivalTime") - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** The ID of the stop the vehicle is arriving at. */ - fun stopId(): String = stopId.getRequired("stopId") - - /** - * Index of the stop into the sequence of stops that make up the trip for this arrival. - */ - fun stopSequence(): Long = stopSequence.getRequired("stopSequence") - - /** Total number of stops visited on the trip for this arrival. */ - fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") - - /** - * Optional trip headsign that potentially overrides the trip headsign in the referenced - * trip element. - */ - fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(): String = tripId.getRequired("tripId") - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - /** The actual track information of the arriving transit vehicle. */ - fun actualTrack(): Optional = - Optional.ofNullable(actualTrack.getNullable("actualTrack")) - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - fun distanceFromStop(): Optional = - Optional.ofNullable(distanceFromStop.getNullable("distanceFromStop")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Historical occupancy information of the transit vehicle. */ - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - /** Timestamp of the last update time for this arrival. */ - fun lastUpdateTime(): Optional = - Optional.ofNullable(lastUpdateTime.getNullable("lastUpdateTime")) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): Optional = - Optional.ofNullable(occupancyStatus.getNullable("occupancyStatus")) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Optional = - Optional.ofNullable(predicted.getNullable("predicted")) - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(): Optional = - Optional.ofNullable( - predictedArrivalInterval.getNullable("predictedArrivalInterval") - ) - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(): Optional = - Optional.ofNullable( - predictedDepartureInterval.getNullable("predictedDepartureInterval") - ) - - /** Predicted occupancy status of the transit vehicle. */ - fun predictedOccupancy(): Optional = - Optional.ofNullable(predictedOccupancy.getNullable("predictedOccupancy")) - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - fun routeLongName(): Optional = - Optional.ofNullable(routeLongName.getNullable("routeLongName")) - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(): Optional = - Optional.ofNullable( - scheduledArrivalInterval.getNullable("scheduledArrivalInterval") - ) - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(): Optional = - Optional.ofNullable( - scheduledDepartureInterval.getNullable("scheduledDepartureInterval") - ) - - /** Scheduled track information of the arriving transit vehicle. */ - fun scheduledTrack(): Optional = - Optional.ofNullable(scheduledTrack.getNullable("scheduledTrack")) - - /** References to situation elements (if any) applicable to this arrival. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status of the arrival. */ - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(): Optional = - Optional.ofNullable(tripStatus.getNullable("tripStatus")) - - /** Indicates if riders can arrive on this transit vehicle. */ - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun _arrivalEnabled(): JsonField = arrivalEnabled - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** Indicates if riders can depart from this transit vehicle. */ - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled(): JsonField = departureEnabled - - /** - * Number of stops between the arriving transit vehicle and the current stop (excluding - * the current stop). - */ - @JsonProperty("numberOfStopsAway") - @ExcludeMissing - fun _numberOfStopsAway(): JsonField = numberOfStopsAway - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedArrivalTime") - @ExcludeMissing - fun _predictedArrivalTime(): JsonField = predictedArrivalTime - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - @JsonProperty("predictedDepartureTime") - @ExcludeMissing - fun _predictedDepartureTime(): JsonField = predictedDepartureTime - - /** The ID of the route for the arriving vehicle. */ - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledArrivalTime") - @ExcludeMissing - fun _scheduledArrivalTime(): JsonField = scheduledArrivalTime - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - @JsonProperty("scheduledDepartureTime") - @ExcludeMissing - fun _scheduledDepartureTime(): JsonField = scheduledDepartureTime - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the service - * date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** The ID of the stop the vehicle is arriving at. */ - @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId - - /** - * Index of the stop into the sequence of stops that make up the trip for this arrival. - */ - @JsonProperty("stopSequence") - @ExcludeMissing - fun _stopSequence(): JsonField = stopSequence - - /** Total number of stops visited on the trip for this arrival. */ - @JsonProperty("totalStopsInTrip") - @ExcludeMissing - fun _totalStopsInTrip(): JsonField = totalStopsInTrip - - /** - * Optional trip headsign that potentially overrides the trip headsign in the referenced - * trip element. - */ - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun _tripHeadsign(): JsonField = tripHeadsign - - /** The ID of the trip for the arriving vehicle. */ - @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - - /** ID of the transit vehicle serving this trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - /** The actual track information of the arriving transit vehicle. */ - @JsonProperty("actualTrack") - @ExcludeMissing - fun _actualTrack(): JsonField = actualTrack - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - @JsonProperty("distanceFromStop") - @ExcludeMissing - fun _distanceFromStop(): JsonField = distanceFromStop - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Historical occupancy information of the transit vehicle. */ - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy(): JsonField = historicalOccupancy - - /** Timestamp of the last update time for this arrival. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** Interval for predicted arrival time, if available. */ - @JsonProperty("predictedArrivalInterval") - @ExcludeMissing - fun _predictedArrivalInterval(): JsonField = predictedArrivalInterval - - /** Interval for predicted departure time, if available. */ - @JsonProperty("predictedDepartureInterval") - @ExcludeMissing - fun _predictedDepartureInterval(): JsonField = predictedDepartureInterval - - /** Predicted occupancy status of the transit vehicle. */ - @JsonProperty("predictedOccupancy") - @ExcludeMissing - fun _predictedOccupancy(): JsonField = predictedOccupancy - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - @JsonProperty("routeLongName") - @ExcludeMissing - fun _routeLongName(): JsonField = routeLongName - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - @JsonProperty("routeShortName") - @ExcludeMissing - fun _routeShortName(): JsonField = routeShortName - - /** Interval for scheduled arrival time. */ - @JsonProperty("scheduledArrivalInterval") - @ExcludeMissing - fun _scheduledArrivalInterval(): JsonField = scheduledArrivalInterval - - /** Interval for scheduled departure time. */ - @JsonProperty("scheduledDepartureInterval") - @ExcludeMissing - fun _scheduledDepartureInterval(): JsonField = scheduledDepartureInterval - - /** Scheduled track information of the arriving transit vehicle. */ - @JsonProperty("scheduledTrack") - @ExcludeMissing - fun _scheduledTrack(): JsonField = scheduledTrack - - /** References to situation elements (if any) applicable to this arrival. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** Current status of the arrival. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** Trip-specific status for the arriving transit vehicle. */ - @JsonProperty("tripStatus") - @ExcludeMissing - fun _tripStatus(): JsonField = tripStatus - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = 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 toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - 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(entry: Entry) = apply { - arrivalEnabled = entry.arrivalEnabled - blockTripSequence = entry.blockTripSequence - departureEnabled = entry.departureEnabled - numberOfStopsAway = entry.numberOfStopsAway - predictedArrivalTime = entry.predictedArrivalTime - predictedDepartureTime = entry.predictedDepartureTime - routeId = entry.routeId - scheduledArrivalTime = entry.scheduledArrivalTime - scheduledDepartureTime = entry.scheduledDepartureTime - serviceDate = entry.serviceDate - stopId = entry.stopId - stopSequence = entry.stopSequence - totalStopsInTrip = entry.totalStopsInTrip - tripHeadsign = entry.tripHeadsign - tripId = entry.tripId - vehicleId = entry.vehicleId - actualTrack = entry.actualTrack - distanceFromStop = entry.distanceFromStop - frequency = entry.frequency - historicalOccupancy = entry.historicalOccupancy - lastUpdateTime = entry.lastUpdateTime - occupancyStatus = entry.occupancyStatus - predicted = entry.predicted - predictedArrivalInterval = entry.predictedArrivalInterval - predictedDepartureInterval = entry.predictedDepartureInterval - predictedOccupancy = entry.predictedOccupancy - routeLongName = entry.routeLongName - routeShortName = entry.routeShortName - scheduledArrivalInterval = entry.scheduledArrivalInterval - scheduledDepartureInterval = entry.scheduledDepartureInterval - scheduledTrack = entry.scheduledTrack - situationIds = entry.situationIds.map { it.toMutableList() } - status = entry.status - tripStatus = entry.tripStatus - additionalProperties = entry.additionalProperties.toMutableMap() - } - - /** Indicates if riders can arrive on this transit vehicle. */ - fun arrivalEnabled(arrivalEnabled: Boolean) = - arrivalEnabled(JsonField.of(arrivalEnabled)) - - /** Indicates if riders can arrive on this transit vehicle. */ - 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)) - - /** Index of this arrival’s trip into the sequence of trips for the active block. */ - 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)) - - /** Indicates if riders can depart from this transit vehicle. */ - 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)) - - /** - * Number of stops between the arriving transit vehicle and the current stop - * (excluding the current stop). - */ - 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)) - - /** - * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - 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)) - - /** - * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time - * available). - */ - 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)) - - /** The ID of the route for the arriving vehicle. */ - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: Long) = - scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) - - /** Scheduled arrival time, in milliseconds since Unix epoch. */ - fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { - this.scheduledArrivalTime = scheduledArrivalTime - } - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - fun scheduledDepartureTime(scheduledDepartureTime: Long) = - scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) - - /** Scheduled departure time, in milliseconds since Unix epoch. */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - 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)) - - /** The ID of the stop the vehicle is arriving at. */ - 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)) - - /** - * Index of the stop into the sequence of stops that make up the trip for this - * arrival. - */ - 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)) - - /** Total number of stops visited on the trip for this arrival. */ - 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)) - - /** - * Optional trip headsign that potentially overrides the trip headsign in the - * referenced trip element. - */ - 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)) - - /** The ID of the trip for the arriving vehicle. */ - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - /** ID of the transit vehicle serving this trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle serving this trip. */ - 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)) - - /** The actual track information of the arriving transit vehicle. */ - 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)) - - /** Distance of the arriving transit vehicle from the stop, in meters. */ - 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)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - /** Historical occupancy information of the transit vehicle. */ - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - /** Historical occupancy information of the transit vehicle. */ - 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)) - - /** Timestamp of the last update time for this arrival. */ - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(predicted: JsonField) = apply { this.predicted = predicted } - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: String) = - predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) - - /** Interval for predicted arrival time, if available. */ - fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = apply { - this.predictedArrivalInterval = predictedArrivalInterval - } - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: String) = - predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) - - /** Interval for predicted departure time, if available. */ - fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = - apply { - this.predictedDepartureInterval = predictedDepartureInterval - } - - /** Predicted occupancy status of the transit vehicle. */ - fun predictedOccupancy(predictedOccupancy: String) = - predictedOccupancy(JsonField.of(predictedOccupancy)) - - /** Predicted occupancy status of the transit vehicle. */ - 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)) - - /** - * Optional route long name that potentially overrides the route long name in the - * referenced route element. - */ - 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)) - - /** - * Optional route short name that potentially overrides the route short name in the - * referenced route element. - */ - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: String) = - scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) - - /** Interval for scheduled arrival time. */ - fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = apply { - this.scheduledArrivalInterval = scheduledArrivalInterval - } - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: String) = - scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) - - /** Interval for scheduled departure time. */ - fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = - apply { - this.scheduledDepartureInterval = scheduledDepartureInterval - } - - /** Scheduled track information of the arriving transit vehicle. */ - fun scheduledTrack(scheduledTrack: String) = - scheduledTrack(JsonField.of(scheduledTrack)) - - /** Scheduled track information of the arriving transit vehicle. */ - 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)) - - /** References to situation elements (if any) applicable to this arrival. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** References to situation elements (if any) applicable to this arrival. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** Current status of the arrival. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status of the arrival. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Trip-specific status for the arriving transit vehicle. */ - fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) - - /** Trip-specific status for the arriving transit vehicle. */ - 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) - } - - fun build(): Entry = - Entry( - 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.toImmutable(), - ) - } - - /** Trip-specific status for the arriving transit vehicle. */ - @NoAutoDetect - class TripStatus - @JsonCreator - private constructor( - @JsonProperty("activeTripId") - @ExcludeMissing - private val activeTripId: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("closestStop") - @ExcludeMissing - private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCapacity") - @ExcludeMissing - private val occupancyCapacity: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCount") - @ExcludeMissing - private val occupancyCount: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDeviation") - @ExcludeMissing - private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun _activeTripId(): JsonField = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun _closestStop(): JsonField = closestStop - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity(): JsonField = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount(): JsonField = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation(): JsonField = scheduleDeviation - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation(): JsonField = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation(): JsonField = lastKnownOrientation - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun _nextStop(): JsonField = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun _orientation(): JsonField = orientation - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Trip ID of the trip the vehicle is actively serving. */ - 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)) - - /** Index of the active trip into the sequence of trips for the active block. */ - 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)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - 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)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - 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)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - 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)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - 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)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - 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)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - 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)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - 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)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - 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. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - 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)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - 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)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - 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)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** References to situation elements (if any) applicable to this trip. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - 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) - } - - 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.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @NoAutoDetect - class LastKnownLocation - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LastKnownLocation = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the last known location of the transit vehicle. */ - 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)) - - /** Longitude of the last known location of the transit vehicle. */ - 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) - } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @NoAutoDetect - class Position - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Position = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the current position of the transit vehicle. */ - 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)) - - /** Longitude of the current position of the transit vehicle. */ - 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) - } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - 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 /* spotless:off */ other is Entry && 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{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}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is ArrivalAndDepartureRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ArrivalAndDepartureRetrieveResponse{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/BlockRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt deleted file mode 100644 index 1f04291..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveResponse.kt +++ /dev/null @@ -1,1153 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class BlockRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): BlockRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BlockRetrieveResponse]. */ - 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(blockRetrieveResponse: BlockRetrieveResponse) = apply { - code = blockRetrieveResponse.code - currentTime = blockRetrieveResponse.currentTime - text = blockRetrieveResponse.text - version = blockRetrieveResponse.version - data = blockRetrieveResponse.data - additionalProperties = blockRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): BlockRetrieveResponse = - BlockRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("configurations") - @ExcludeMissing - private val configurations: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun configurations(): List = configurations.getRequired("configurations") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("configurations") - @ExcludeMissing - fun _configurations(): JsonField> = configurations - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - id() - configurations().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var configurations: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - id = entry.id - configurations = entry.configurations.map { it.toMutableList() } - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun configurations(configurations: List) = - configurations(JsonField.of(configurations)) - - fun configurations(configurations: JsonField>) = apply { - this.configurations = configurations.map { it.toMutableList() } - } - - fun addConfiguration(configuration: Configuration) = apply { - configurations = - (configurations ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(configuration) - } - } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("id", id), - checkRequired("configurations", configurations).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Configuration - @JsonCreator - private constructor( - @JsonProperty("activeServiceIds") - @ExcludeMissing - private val activeServiceIds: JsonField> = JsonMissing.of(), - @JsonProperty("trips") - @ExcludeMissing - private val trips: JsonField> = JsonMissing.of(), - @JsonProperty("inactiveServiceIds") - @ExcludeMissing - private val inactiveServiceIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun activeServiceIds(): List = - activeServiceIds.getRequired("activeServiceIds") - - fun trips(): List = trips.getRequired("trips") - - fun inactiveServiceIds(): Optional> = - Optional.ofNullable(inactiveServiceIds.getNullable("inactiveServiceIds")) - - @JsonProperty("activeServiceIds") - @ExcludeMissing - fun _activeServiceIds(): JsonField> = activeServiceIds - - @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips - - @JsonProperty("inactiveServiceIds") - @ExcludeMissing - fun _inactiveServiceIds(): JsonField> = inactiveServiceIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Configuration = apply { - if (validated) { - return@apply - } - - activeServiceIds() - trips().forEach { it.validate() } - inactiveServiceIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Configuration]. */ - class Builder internal constructor() { - - private var activeServiceIds: JsonField>? = null - private var trips: JsonField>? = null - private var inactiveServiceIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(configuration: Configuration) = apply { - activeServiceIds = configuration.activeServiceIds.map { it.toMutableList() } - trips = configuration.trips.map { it.toMutableList() } - inactiveServiceIds = - configuration.inactiveServiceIds.map { it.toMutableList() } - additionalProperties = configuration.additionalProperties.toMutableMap() - } - - fun activeServiceIds(activeServiceIds: List) = - activeServiceIds(JsonField.of(activeServiceIds)) - - fun activeServiceIds(activeServiceIds: JsonField>) = apply { - this.activeServiceIds = activeServiceIds.map { it.toMutableList() } - } - - fun addActiveServiceId(activeServiceId: String) = apply { - activeServiceIds = - (activeServiceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(activeServiceId) - } - } - - fun trips(trips: List) = trips(JsonField.of(trips)) - - fun trips(trips: JsonField>) = apply { - this.trips = trips.map { it.toMutableList() } - } - - fun addTrip(trip: Trip) = apply { - trips = - (trips ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(trip) - } - } - - fun inactiveServiceIds(inactiveServiceIds: List) = - inactiveServiceIds(JsonField.of(inactiveServiceIds)) - - fun inactiveServiceIds(inactiveServiceIds: JsonField>) = apply { - this.inactiveServiceIds = inactiveServiceIds.map { it.toMutableList() } - } - - fun addInactiveServiceId(inactiveServiceId: String) = apply { - inactiveServiceIds = - (inactiveServiceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(inactiveServiceId) - } - } - - 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) - } - - fun build(): Configuration = - Configuration( - checkRequired("activeServiceIds", activeServiceIds).map { - it.toImmutable() - }, - checkRequired("trips", trips).map { it.toImmutable() }, - (inactiveServiceIds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Trip - @JsonCreator - private constructor( - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - private val accumulatedSlackTime: JsonField = JsonMissing.of(), - @JsonProperty("blockStopTimes") - @ExcludeMissing - private val blockStopTimes: JsonField> = JsonMissing.of(), - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - private val distanceAlongBlock: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun accumulatedSlackTime(): Double = - accumulatedSlackTime.getRequired("accumulatedSlackTime") - - fun blockStopTimes(): List = - blockStopTimes.getRequired("blockStopTimes") - - fun distanceAlongBlock(): Double = - distanceAlongBlock.getRequired("distanceAlongBlock") - - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - fun _accumulatedSlackTime(): JsonField = accumulatedSlackTime - - @JsonProperty("blockStopTimes") - @ExcludeMissing - fun _blockStopTimes(): JsonField> = blockStopTimes - - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - fun _distanceAlongBlock(): JsonField = distanceAlongBlock - - @JsonProperty("tripId") - @ExcludeMissing - fun _tripId(): JsonField = tripId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Trip = apply { - if (validated) { - return@apply - } - - accumulatedSlackTime() - blockStopTimes().forEach { it.validate() } - distanceAlongBlock() - tripId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Trip]. */ - class Builder internal constructor() { - - private var accumulatedSlackTime: JsonField? = null - private var blockStopTimes: JsonField>? = null - private var distanceAlongBlock: JsonField? = null - private var tripId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(trip: Trip) = apply { - accumulatedSlackTime = trip.accumulatedSlackTime - blockStopTimes = trip.blockStopTimes.map { it.toMutableList() } - distanceAlongBlock = trip.distanceAlongBlock - tripId = trip.tripId - additionalProperties = trip.additionalProperties.toMutableMap() - } - - fun accumulatedSlackTime(accumulatedSlackTime: Double) = - accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) - - fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = apply { - this.accumulatedSlackTime = accumulatedSlackTime - } - - fun blockStopTimes(blockStopTimes: List) = - blockStopTimes(JsonField.of(blockStopTimes)) - - fun blockStopTimes(blockStopTimes: JsonField>) = apply { - this.blockStopTimes = blockStopTimes.map { it.toMutableList() } - } - - fun addBlockStopTime(blockStopTime: BlockStopTime) = apply { - blockStopTimes = - (blockStopTimes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(blockStopTime) - } - } - - fun distanceAlongBlock(distanceAlongBlock: Double) = - distanceAlongBlock(JsonField.of(distanceAlongBlock)) - - fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { - this.distanceAlongBlock = distanceAlongBlock - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - 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) - } - - fun build(): Trip = - Trip( - checkRequired("accumulatedSlackTime", accumulatedSlackTime), - checkRequired("blockStopTimes", blockStopTimes).map { - it.toImmutable() - }, - checkRequired("distanceAlongBlock", distanceAlongBlock), - checkRequired("tripId", tripId), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BlockStopTime - @JsonCreator - private constructor( - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - private val accumulatedSlackTime: JsonField = JsonMissing.of(), - @JsonProperty("blockSequence") - @ExcludeMissing - private val blockSequence: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - private val distanceAlongBlock: JsonField = JsonMissing.of(), - @JsonProperty("stopTime") - @ExcludeMissing - private val stopTime: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - fun accumulatedSlackTime(): Double = - accumulatedSlackTime.getRequired("accumulatedSlackTime") - - fun blockSequence(): Long = blockSequence.getRequired("blockSequence") - - fun distanceAlongBlock(): Double = - distanceAlongBlock.getRequired("distanceAlongBlock") - - fun stopTime(): StopTime = stopTime.getRequired("stopTime") - - @JsonProperty("accumulatedSlackTime") - @ExcludeMissing - fun _accumulatedSlackTime(): JsonField = accumulatedSlackTime - - @JsonProperty("blockSequence") - @ExcludeMissing - fun _blockSequence(): JsonField = blockSequence - - @JsonProperty("distanceAlongBlock") - @ExcludeMissing - fun _distanceAlongBlock(): JsonField = distanceAlongBlock - - @JsonProperty("stopTime") - @ExcludeMissing - fun _stopTime(): JsonField = stopTime - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BlockStopTime = apply { - if (validated) { - return@apply - } - - accumulatedSlackTime() - blockSequence() - distanceAlongBlock() - stopTime().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BlockStopTime]. */ - class Builder internal constructor() { - - private var accumulatedSlackTime: JsonField? = null - private var blockSequence: JsonField? = null - private var distanceAlongBlock: JsonField? = null - private var stopTime: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(blockStopTime: BlockStopTime) = apply { - accumulatedSlackTime = blockStopTime.accumulatedSlackTime - blockSequence = blockStopTime.blockSequence - distanceAlongBlock = blockStopTime.distanceAlongBlock - stopTime = blockStopTime.stopTime - additionalProperties = - blockStopTime.additionalProperties.toMutableMap() - } - - fun accumulatedSlackTime(accumulatedSlackTime: Double) = - accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) - - fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = - apply { - this.accumulatedSlackTime = accumulatedSlackTime - } - - fun blockSequence(blockSequence: Long) = - blockSequence(JsonField.of(blockSequence)) - - fun blockSequence(blockSequence: JsonField) = apply { - this.blockSequence = blockSequence - } - - fun distanceAlongBlock(distanceAlongBlock: Double) = - distanceAlongBlock(JsonField.of(distanceAlongBlock)) - - fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { - this.distanceAlongBlock = distanceAlongBlock - } - - fun stopTime(stopTime: StopTime) = stopTime(JsonField.of(stopTime)) - - fun stopTime(stopTime: JsonField) = apply { - this.stopTime = stopTime - } - - 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) - } - - fun build(): BlockStopTime = - BlockStopTime( - checkRequired("accumulatedSlackTime", accumulatedSlackTime), - checkRequired("blockSequence", blockSequence), - checkRequired("distanceAlongBlock", distanceAlongBlock), - checkRequired("stopTime", stopTime), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class StopTime - @JsonCreator - private constructor( - @JsonProperty("arrivalTime") - @ExcludeMissing - private val arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonProperty("dropOffType") - @ExcludeMissing - private val dropOffType: JsonField = JsonMissing.of(), - @JsonProperty("pickupType") - @ExcludeMissing - private val pickupType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") - - fun departureTime(): Long = departureTime.getRequired("departureTime") - - fun stopId(): String = stopId.getRequired("stopId") - - fun dropOffType(): Optional = - Optional.ofNullable(dropOffType.getNullable("dropOffType")) - - fun pickupType(): Optional = - Optional.ofNullable(pickupType.getNullable("pickupType")) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime(): JsonField = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime(): JsonField = departureTime - - @JsonProperty("stopId") - @ExcludeMissing - fun _stopId(): JsonField = stopId - - @JsonProperty("dropOffType") - @ExcludeMissing - fun _dropOffType(): JsonField = dropOffType - - @JsonProperty("pickupType") - @ExcludeMissing - fun _pickupType(): JsonField = pickupType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - private var validated: Boolean = false - - fun validate(): StopTime = apply { - if (validated) { - return@apply - } - - arrivalTime() - departureTime() - stopId() - dropOffType() - pickupType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopTime]. */ - class Builder internal constructor() { - - private var arrivalTime: JsonField? = null - private var departureTime: JsonField? = null - private var stopId: JsonField? = null - private var dropOffType: JsonField = JsonMissing.of() - private var pickupType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopTime: StopTime) = apply { - arrivalTime = stopTime.arrivalTime - departureTime = stopTime.departureTime - stopId = stopTime.stopId - dropOffType = stopTime.dropOffType - pickupType = stopTime.pickupType - additionalProperties = - stopTime.additionalProperties.toMutableMap() - } - - fun arrivalTime(arrivalTime: Long) = - arrivalTime(JsonField.of(arrivalTime)) - - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - fun stopId(stopId: JsonField) = apply { - this.stopId = stopId - } - - fun dropOffType(dropOffType: Long) = - dropOffType(JsonField.of(dropOffType)) - - fun dropOffType(dropOffType: JsonField) = apply { - this.dropOffType = dropOffType - } - - fun pickupType(pickupType: Long) = - pickupType(JsonField.of(pickupType)) - - fun pickupType(pickupType: JsonField) = apply { - this.pickupType = pickupType - } - - 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) - } - - fun build(): StopTime = - StopTime( - checkRequired("arrivalTime", arrivalTime), - checkRequired("departureTime", departureTime), - checkRequired("stopId", stopId), - dropOffType, - pickupType, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && stopId == other.stopId && dropOffType == other.dropOffType && pickupType == other.pickupType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, stopId, dropOffType, pickupType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, stopId=$stopId, dropOffType=$dropOffType, pickupType=$pickupType, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BlockStopTime && accumulatedSlackTime == other.accumulatedSlackTime && blockSequence == other.blockSequence && distanceAlongBlock == other.distanceAlongBlock && stopTime == other.stopTime && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accumulatedSlackTime, blockSequence, distanceAlongBlock, stopTime, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BlockStopTime{accumulatedSlackTime=$accumulatedSlackTime, blockSequence=$blockSequence, distanceAlongBlock=$distanceAlongBlock, stopTime=$stopTime, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Trip && accumulatedSlackTime == other.accumulatedSlackTime && blockStopTimes == other.blockStopTimes && distanceAlongBlock == other.distanceAlongBlock && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accumulatedSlackTime, blockStopTimes, distanceAlongBlock, tripId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Trip{accumulatedSlackTime=$accumulatedSlackTime, blockStopTimes=$blockStopTimes, distanceAlongBlock=$distanceAlongBlock, tripId=$tripId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Configuration && activeServiceIds == other.activeServiceIds && trips == other.trips && inactiveServiceIds == other.inactiveServiceIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(activeServiceIds, trips, inactiveServiceIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Configuration{activeServiceIds=$activeServiceIds, trips=$trips, inactiveServiceIds=$inactiveServiceIds, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && id == other.id && configurations == other.configurations && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, configurations, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{id=$id, configurations=$configurations, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is BlockRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BlockRetrieveResponse{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/ConfigRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt deleted file mode 100644 index 36c0a69..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveResponse.kt +++ /dev/null @@ -1,975 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class ConfigRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): ConfigRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ConfigRetrieveResponse]. */ - 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(configRetrieveResponse: ConfigRetrieveResponse) = apply { - code = configRetrieveResponse.code - currentTime = configRetrieveResponse.currentTime - text = configRetrieveResponse.text - version = configRetrieveResponse.version - data = configRetrieveResponse.data - additionalProperties = configRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): ConfigRetrieveResponse = - ConfigRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("gitProperties") - @ExcludeMissing - private val gitProperties: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("serviceDateFrom") - @ExcludeMissing - private val serviceDateFrom: JsonField = JsonMissing.of(), - @JsonProperty("serviceDateTo") - @ExcludeMissing - private val serviceDateTo: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - fun gitProperties(): Optional = - Optional.ofNullable(gitProperties.getNullable("gitProperties")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun serviceDateFrom(): Optional = - Optional.ofNullable(serviceDateFrom.getNullable("serviceDateFrom")) - - fun serviceDateTo(): Optional = - Optional.ofNullable(serviceDateTo.getNullable("serviceDateTo")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("gitProperties") - @ExcludeMissing - fun _gitProperties(): JsonField = gitProperties - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("serviceDateFrom") - @ExcludeMissing - fun _serviceDateFrom(): JsonField = serviceDateFrom - - @JsonProperty("serviceDateTo") - @ExcludeMissing - fun _serviceDateTo(): JsonField = serviceDateTo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - id() - gitProperties().ifPresent { it.validate() } - name() - serviceDateFrom() - serviceDateTo() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var gitProperties: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var serviceDateFrom: JsonField = JsonMissing.of() - private var serviceDateTo: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - id = entry.id - gitProperties = entry.gitProperties - name = entry.name - serviceDateFrom = entry.serviceDateFrom - serviceDateTo = entry.serviceDateTo - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun gitProperties(gitProperties: GitProperties) = - gitProperties(JsonField.of(gitProperties)) - - fun gitProperties(gitProperties: JsonField) = apply { - this.gitProperties = gitProperties - } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun serviceDateFrom(serviceDateFrom: String) = - serviceDateFrom(JsonField.of(serviceDateFrom)) - - fun serviceDateFrom(serviceDateFrom: JsonField) = apply { - this.serviceDateFrom = serviceDateFrom - } - - fun serviceDateTo(serviceDateTo: String) = - serviceDateTo(JsonField.of(serviceDateTo)) - - fun serviceDateTo(serviceDateTo: JsonField) = apply { - this.serviceDateTo = serviceDateTo - } - - 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) - } - - fun build(): Entry = - Entry( - id, - gitProperties, - name, - serviceDateFrom, - serviceDateTo, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class GitProperties - @JsonCreator - private constructor( - @JsonProperty("git.branch") - @ExcludeMissing - private val gitBranch: JsonField = JsonMissing.of(), - @JsonProperty("git.build.host") - @ExcludeMissing - private val gitBuildHost: JsonField = JsonMissing.of(), - @JsonProperty("git.build.time") - @ExcludeMissing - private val gitBuildTime: JsonField = JsonMissing.of(), - @JsonProperty("git.build.user.email") - @ExcludeMissing - private val gitBuildUserEmail: JsonField = JsonMissing.of(), - @JsonProperty("git.build.user.name") - @ExcludeMissing - private val gitBuildUserName: JsonField = JsonMissing.of(), - @JsonProperty("git.build.version") - @ExcludeMissing - private val gitBuildVersion: JsonField = JsonMissing.of(), - @JsonProperty("git.closest.tag.commit.count") - @ExcludeMissing - private val gitClosestTagCommitCount: JsonField = JsonMissing.of(), - @JsonProperty("git.closest.tag.name") - @ExcludeMissing - private val gitClosestTagName: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.id") - @ExcludeMissing - private val gitCommitId: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.id.abbrev") - @ExcludeMissing - private val gitCommitIdAbbrev: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.id.describe") - @ExcludeMissing - private val gitCommitIdDescribe: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.id.describe-short") - @ExcludeMissing - private val gitCommitIdDescribeShort: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.message.full") - @ExcludeMissing - private val gitCommitMessageFull: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.message.short") - @ExcludeMissing - private val gitCommitMessageShort: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.time") - @ExcludeMissing - private val gitCommitTime: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.user.email") - @ExcludeMissing - private val gitCommitUserEmail: JsonField = JsonMissing.of(), - @JsonProperty("git.commit.user.name") - @ExcludeMissing - private val gitCommitUserName: JsonField = JsonMissing.of(), - @JsonProperty("git.dirty") - @ExcludeMissing - private val gitDirty: JsonField = JsonMissing.of(), - @JsonProperty("git.remote.origin.url") - @ExcludeMissing - private val gitRemoteOriginUrl: JsonField = JsonMissing.of(), - @JsonProperty("git.tags") - @ExcludeMissing - private val gitTags: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun gitBranch(): Optional = - Optional.ofNullable(gitBranch.getNullable("git.branch")) - - fun gitBuildHost(): Optional = - Optional.ofNullable(gitBuildHost.getNullable("git.build.host")) - - fun gitBuildTime(): Optional = - Optional.ofNullable(gitBuildTime.getNullable("git.build.time")) - - fun gitBuildUserEmail(): Optional = - Optional.ofNullable(gitBuildUserEmail.getNullable("git.build.user.email")) - - fun gitBuildUserName(): Optional = - Optional.ofNullable(gitBuildUserName.getNullable("git.build.user.name")) - - fun gitBuildVersion(): Optional = - Optional.ofNullable(gitBuildVersion.getNullable("git.build.version")) - - fun gitClosestTagCommitCount(): Optional = - Optional.ofNullable( - gitClosestTagCommitCount.getNullable("git.closest.tag.commit.count") - ) - - fun gitClosestTagName(): Optional = - Optional.ofNullable(gitClosestTagName.getNullable("git.closest.tag.name")) - - fun gitCommitId(): Optional = - Optional.ofNullable(gitCommitId.getNullable("git.commit.id")) - - fun gitCommitIdAbbrev(): Optional = - Optional.ofNullable(gitCommitIdAbbrev.getNullable("git.commit.id.abbrev")) - - fun gitCommitIdDescribe(): Optional = - Optional.ofNullable(gitCommitIdDescribe.getNullable("git.commit.id.describe")) - - fun gitCommitIdDescribeShort(): Optional = - Optional.ofNullable( - gitCommitIdDescribeShort.getNullable("git.commit.id.describe-short") - ) - - fun gitCommitMessageFull(): Optional = - Optional.ofNullable(gitCommitMessageFull.getNullable("git.commit.message.full")) - - fun gitCommitMessageShort(): Optional = - Optional.ofNullable( - gitCommitMessageShort.getNullable("git.commit.message.short") - ) - - fun gitCommitTime(): Optional = - Optional.ofNullable(gitCommitTime.getNullable("git.commit.time")) - - fun gitCommitUserEmail(): Optional = - Optional.ofNullable(gitCommitUserEmail.getNullable("git.commit.user.email")) - - fun gitCommitUserName(): Optional = - Optional.ofNullable(gitCommitUserName.getNullable("git.commit.user.name")) - - fun gitDirty(): Optional = - Optional.ofNullable(gitDirty.getNullable("git.dirty")) - - fun gitRemoteOriginUrl(): Optional = - Optional.ofNullable(gitRemoteOriginUrl.getNullable("git.remote.origin.url")) - - fun gitTags(): Optional = - Optional.ofNullable(gitTags.getNullable("git.tags")) - - @JsonProperty("git.branch") - @ExcludeMissing - fun _gitBranch(): JsonField = gitBranch - - @JsonProperty("git.build.host") - @ExcludeMissing - fun _gitBuildHost(): JsonField = gitBuildHost - - @JsonProperty("git.build.time") - @ExcludeMissing - fun _gitBuildTime(): JsonField = gitBuildTime - - @JsonProperty("git.build.user.email") - @ExcludeMissing - fun _gitBuildUserEmail(): JsonField = gitBuildUserEmail - - @JsonProperty("git.build.user.name") - @ExcludeMissing - fun _gitBuildUserName(): JsonField = gitBuildUserName - - @JsonProperty("git.build.version") - @ExcludeMissing - fun _gitBuildVersion(): JsonField = gitBuildVersion - - @JsonProperty("git.closest.tag.commit.count") - @ExcludeMissing - fun _gitClosestTagCommitCount(): JsonField = gitClosestTagCommitCount - - @JsonProperty("git.closest.tag.name") - @ExcludeMissing - fun _gitClosestTagName(): JsonField = gitClosestTagName - - @JsonProperty("git.commit.id") - @ExcludeMissing - fun _gitCommitId(): JsonField = gitCommitId - - @JsonProperty("git.commit.id.abbrev") - @ExcludeMissing - fun _gitCommitIdAbbrev(): JsonField = gitCommitIdAbbrev - - @JsonProperty("git.commit.id.describe") - @ExcludeMissing - fun _gitCommitIdDescribe(): JsonField = gitCommitIdDescribe - - @JsonProperty("git.commit.id.describe-short") - @ExcludeMissing - fun _gitCommitIdDescribeShort(): JsonField = gitCommitIdDescribeShort - - @JsonProperty("git.commit.message.full") - @ExcludeMissing - fun _gitCommitMessageFull(): JsonField = gitCommitMessageFull - - @JsonProperty("git.commit.message.short") - @ExcludeMissing - fun _gitCommitMessageShort(): JsonField = gitCommitMessageShort - - @JsonProperty("git.commit.time") - @ExcludeMissing - fun _gitCommitTime(): JsonField = gitCommitTime - - @JsonProperty("git.commit.user.email") - @ExcludeMissing - fun _gitCommitUserEmail(): JsonField = gitCommitUserEmail - - @JsonProperty("git.commit.user.name") - @ExcludeMissing - fun _gitCommitUserName(): JsonField = gitCommitUserName - - @JsonProperty("git.dirty") - @ExcludeMissing - fun _gitDirty(): JsonField = gitDirty - - @JsonProperty("git.remote.origin.url") - @ExcludeMissing - fun _gitRemoteOriginUrl(): JsonField = gitRemoteOriginUrl - - @JsonProperty("git.tags") - @ExcludeMissing - fun _gitTags(): JsonField = gitTags - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GitProperties = apply { - if (validated) { - return@apply - } - - gitBranch() - gitBuildHost() - gitBuildTime() - gitBuildUserEmail() - gitBuildUserName() - gitBuildVersion() - gitClosestTagCommitCount() - gitClosestTagName() - gitCommitId() - gitCommitIdAbbrev() - gitCommitIdDescribe() - gitCommitIdDescribeShort() - gitCommitMessageFull() - gitCommitMessageShort() - gitCommitTime() - gitCommitUserEmail() - gitCommitUserName() - gitDirty() - gitRemoteOriginUrl() - gitTags() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GitProperties]. */ - class Builder internal constructor() { - - private var gitBranch: JsonField = JsonMissing.of() - private var gitBuildHost: JsonField = JsonMissing.of() - private var gitBuildTime: JsonField = JsonMissing.of() - private var gitBuildUserEmail: JsonField = JsonMissing.of() - private var gitBuildUserName: JsonField = JsonMissing.of() - private var gitBuildVersion: JsonField = JsonMissing.of() - private var gitClosestTagCommitCount: JsonField = JsonMissing.of() - private var gitClosestTagName: JsonField = JsonMissing.of() - private var gitCommitId: JsonField = JsonMissing.of() - private var gitCommitIdAbbrev: JsonField = JsonMissing.of() - private var gitCommitIdDescribe: JsonField = JsonMissing.of() - private var gitCommitIdDescribeShort: JsonField = JsonMissing.of() - private var gitCommitMessageFull: JsonField = JsonMissing.of() - private var gitCommitMessageShort: JsonField = JsonMissing.of() - private var gitCommitTime: JsonField = JsonMissing.of() - private var gitCommitUserEmail: JsonField = JsonMissing.of() - private var gitCommitUserName: JsonField = JsonMissing.of() - private var gitDirty: JsonField = JsonMissing.of() - private var gitRemoteOriginUrl: JsonField = JsonMissing.of() - private var gitTags: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitProperties: GitProperties) = apply { - gitBranch = gitProperties.gitBranch - gitBuildHost = gitProperties.gitBuildHost - gitBuildTime = gitProperties.gitBuildTime - gitBuildUserEmail = gitProperties.gitBuildUserEmail - gitBuildUserName = gitProperties.gitBuildUserName - gitBuildVersion = gitProperties.gitBuildVersion - gitClosestTagCommitCount = gitProperties.gitClosestTagCommitCount - gitClosestTagName = gitProperties.gitClosestTagName - gitCommitId = gitProperties.gitCommitId - gitCommitIdAbbrev = gitProperties.gitCommitIdAbbrev - gitCommitIdDescribe = gitProperties.gitCommitIdDescribe - gitCommitIdDescribeShort = gitProperties.gitCommitIdDescribeShort - gitCommitMessageFull = gitProperties.gitCommitMessageFull - gitCommitMessageShort = gitProperties.gitCommitMessageShort - gitCommitTime = gitProperties.gitCommitTime - gitCommitUserEmail = gitProperties.gitCommitUserEmail - gitCommitUserName = gitProperties.gitCommitUserName - gitDirty = gitProperties.gitDirty - gitRemoteOriginUrl = gitProperties.gitRemoteOriginUrl - gitTags = gitProperties.gitTags - additionalProperties = gitProperties.additionalProperties.toMutableMap() - } - - fun gitBranch(gitBranch: String) = gitBranch(JsonField.of(gitBranch)) - - fun gitBranch(gitBranch: JsonField) = apply { - this.gitBranch = gitBranch - } - - fun gitBuildHost(gitBuildHost: String) = - gitBuildHost(JsonField.of(gitBuildHost)) - - fun gitBuildHost(gitBuildHost: JsonField) = apply { - this.gitBuildHost = gitBuildHost - } - - fun gitBuildTime(gitBuildTime: String) = - gitBuildTime(JsonField.of(gitBuildTime)) - - fun gitBuildTime(gitBuildTime: JsonField) = apply { - this.gitBuildTime = gitBuildTime - } - - fun gitBuildUserEmail(gitBuildUserEmail: String) = - gitBuildUserEmail(JsonField.of(gitBuildUserEmail)) - - fun gitBuildUserEmail(gitBuildUserEmail: JsonField) = apply { - this.gitBuildUserEmail = gitBuildUserEmail - } - - fun gitBuildUserName(gitBuildUserName: String) = - gitBuildUserName(JsonField.of(gitBuildUserName)) - - fun gitBuildUserName(gitBuildUserName: JsonField) = apply { - this.gitBuildUserName = gitBuildUserName - } - - fun gitBuildVersion(gitBuildVersion: String) = - gitBuildVersion(JsonField.of(gitBuildVersion)) - - fun gitBuildVersion(gitBuildVersion: JsonField) = apply { - this.gitBuildVersion = gitBuildVersion - } - - fun gitClosestTagCommitCount(gitClosestTagCommitCount: String) = - gitClosestTagCommitCount(JsonField.of(gitClosestTagCommitCount)) - - fun gitClosestTagCommitCount(gitClosestTagCommitCount: JsonField) = - apply { - this.gitClosestTagCommitCount = gitClosestTagCommitCount - } - - fun gitClosestTagName(gitClosestTagName: String) = - gitClosestTagName(JsonField.of(gitClosestTagName)) - - fun gitClosestTagName(gitClosestTagName: JsonField) = apply { - this.gitClosestTagName = gitClosestTagName - } - - fun gitCommitId(gitCommitId: String) = gitCommitId(JsonField.of(gitCommitId)) - - fun gitCommitId(gitCommitId: JsonField) = apply { - this.gitCommitId = gitCommitId - } - - fun gitCommitIdAbbrev(gitCommitIdAbbrev: String) = - gitCommitIdAbbrev(JsonField.of(gitCommitIdAbbrev)) - - fun gitCommitIdAbbrev(gitCommitIdAbbrev: JsonField) = apply { - this.gitCommitIdAbbrev = gitCommitIdAbbrev - } - - fun gitCommitIdDescribe(gitCommitIdDescribe: String) = - gitCommitIdDescribe(JsonField.of(gitCommitIdDescribe)) - - fun gitCommitIdDescribe(gitCommitIdDescribe: JsonField) = apply { - this.gitCommitIdDescribe = gitCommitIdDescribe - } - - fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: String) = - gitCommitIdDescribeShort(JsonField.of(gitCommitIdDescribeShort)) - - fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: JsonField) = - apply { - this.gitCommitIdDescribeShort = gitCommitIdDescribeShort - } - - fun gitCommitMessageFull(gitCommitMessageFull: String) = - gitCommitMessageFull(JsonField.of(gitCommitMessageFull)) - - fun gitCommitMessageFull(gitCommitMessageFull: JsonField) = apply { - this.gitCommitMessageFull = gitCommitMessageFull - } - - fun gitCommitMessageShort(gitCommitMessageShort: String) = - gitCommitMessageShort(JsonField.of(gitCommitMessageShort)) - - fun gitCommitMessageShort(gitCommitMessageShort: JsonField) = apply { - this.gitCommitMessageShort = gitCommitMessageShort - } - - fun gitCommitTime(gitCommitTime: String) = - gitCommitTime(JsonField.of(gitCommitTime)) - - fun gitCommitTime(gitCommitTime: JsonField) = apply { - this.gitCommitTime = gitCommitTime - } - - fun gitCommitUserEmail(gitCommitUserEmail: String) = - gitCommitUserEmail(JsonField.of(gitCommitUserEmail)) - - fun gitCommitUserEmail(gitCommitUserEmail: JsonField) = apply { - this.gitCommitUserEmail = gitCommitUserEmail - } - - fun gitCommitUserName(gitCommitUserName: String) = - gitCommitUserName(JsonField.of(gitCommitUserName)) - - fun gitCommitUserName(gitCommitUserName: JsonField) = apply { - this.gitCommitUserName = gitCommitUserName - } - - fun gitDirty(gitDirty: String) = gitDirty(JsonField.of(gitDirty)) - - fun gitDirty(gitDirty: JsonField) = apply { this.gitDirty = gitDirty } - - fun gitRemoteOriginUrl(gitRemoteOriginUrl: String) = - gitRemoteOriginUrl(JsonField.of(gitRemoteOriginUrl)) - - fun gitRemoteOriginUrl(gitRemoteOriginUrl: JsonField) = apply { - this.gitRemoteOriginUrl = gitRemoteOriginUrl - } - - fun gitTags(gitTags: String) = gitTags(JsonField.of(gitTags)) - - fun gitTags(gitTags: JsonField) = apply { this.gitTags = gitTags } - - 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) - } - - fun build(): GitProperties = - GitProperties( - gitBranch, - gitBuildHost, - gitBuildTime, - gitBuildUserEmail, - gitBuildUserName, - gitBuildVersion, - gitClosestTagCommitCount, - gitClosestTagName, - gitCommitId, - gitCommitIdAbbrev, - gitCommitIdDescribe, - gitCommitIdDescribeShort, - gitCommitMessageFull, - gitCommitMessageShort, - gitCommitTime, - gitCommitUserEmail, - gitCommitUserName, - gitDirty, - gitRemoteOriginUrl, - gitTags, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitProperties && gitBranch == other.gitBranch && gitBuildHost == other.gitBuildHost && gitBuildTime == other.gitBuildTime && gitBuildUserEmail == other.gitBuildUserEmail && gitBuildUserName == other.gitBuildUserName && gitBuildVersion == other.gitBuildVersion && gitClosestTagCommitCount == other.gitClosestTagCommitCount && gitClosestTagName == other.gitClosestTagName && gitCommitId == other.gitCommitId && gitCommitIdAbbrev == other.gitCommitIdAbbrev && gitCommitIdDescribe == other.gitCommitIdDescribe && gitCommitIdDescribeShort == other.gitCommitIdDescribeShort && gitCommitMessageFull == other.gitCommitMessageFull && gitCommitMessageShort == other.gitCommitMessageShort && gitCommitTime == other.gitCommitTime && gitCommitUserEmail == other.gitCommitUserEmail && gitCommitUserName == other.gitCommitUserName && gitDirty == other.gitDirty && gitRemoteOriginUrl == other.gitRemoteOriginUrl && gitTags == other.gitTags && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(gitBranch, gitBuildHost, gitBuildTime, gitBuildUserEmail, gitBuildUserName, gitBuildVersion, gitClosestTagCommitCount, gitClosestTagName, gitCommitId, gitCommitIdAbbrev, gitCommitIdDescribe, gitCommitIdDescribeShort, gitCommitMessageFull, gitCommitMessageShort, gitCommitTime, gitCommitUserEmail, gitCommitUserName, gitDirty, gitRemoteOriginUrl, gitTags, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitProperties{gitBranch=$gitBranch, gitBuildHost=$gitBuildHost, gitBuildTime=$gitBuildTime, gitBuildUserEmail=$gitBuildUserEmail, gitBuildUserName=$gitBuildUserName, gitBuildVersion=$gitBuildVersion, gitClosestTagCommitCount=$gitClosestTagCommitCount, gitClosestTagName=$gitClosestTagName, gitCommitId=$gitCommitId, gitCommitIdAbbrev=$gitCommitIdAbbrev, gitCommitIdDescribe=$gitCommitIdDescribe, gitCommitIdDescribeShort=$gitCommitIdDescribeShort, gitCommitMessageFull=$gitCommitMessageFull, gitCommitMessageShort=$gitCommitMessageShort, gitCommitTime=$gitCommitTime, gitCommitUserEmail=$gitCommitUserEmail, gitCommitUserName=$gitCommitUserName, gitDirty=$gitDirty, gitRemoteOriginUrl=$gitRemoteOriginUrl, gitTags=$gitTags, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && id == other.id && gitProperties == other.gitProperties && name == other.name && serviceDateFrom == other.serviceDateFrom && serviceDateTo == other.serviceDateTo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitProperties, name, serviceDateFrom, serviceDateTo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{id=$id, gitProperties=$gitProperties, name=$name, serviceDateFrom=$serviceDateFrom, serviceDateTo=$serviceDateTo, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is ConfigRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ConfigRetrieveResponse{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/CurrentTimeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt deleted file mode 100644 index 328b9a3..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveResponse.kt +++ /dev/null @@ -1,412 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class CurrentTimeRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): CurrentTimeRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CurrentTimeRetrieveResponse]. */ - 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(currentTimeRetrieveResponse: CurrentTimeRetrieveResponse) = apply { - code = currentTimeRetrieveResponse.code - currentTime = currentTimeRetrieveResponse.currentTime - text = currentTimeRetrieveResponse.text - version = currentTimeRetrieveResponse.version - data = currentTimeRetrieveResponse.data - additionalProperties = currentTimeRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): CurrentTimeRetrieveResponse = - CurrentTimeRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("readableTime") - @ExcludeMissing - private val readableTime: JsonField = JsonMissing.of(), - @JsonProperty("time") - @ExcludeMissing - private val time: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun readableTime(): Optional = - Optional.ofNullable(readableTime.getNullable("readableTime")) - - fun time(): Optional = Optional.ofNullable(time.getNullable("time")) - - @JsonProperty("readableTime") - @ExcludeMissing - fun _readableTime(): JsonField = readableTime - - @JsonProperty("time") @ExcludeMissing fun _time(): JsonField = time - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - readableTime() - time() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var readableTime: JsonField = JsonMissing.of() - private var time: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - readableTime = entry.readableTime - time = entry.time - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun readableTime(readableTime: String) = readableTime(JsonField.of(readableTime)) - - fun readableTime(readableTime: JsonField) = apply { - this.readableTime = readableTime - } - - fun time(time: Long) = time(JsonField.of(time)) - - fun time(time: JsonField) = apply { this.time = time } - - 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) - } - - fun build(): Entry = - Entry( - readableTime, - time, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && readableTime == other.readableTime && time == other.time && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(readableTime, time, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{readableTime=$readableTime, time=$time, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is CurrentTimeRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CurrentTimeRetrieveResponse{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/References.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt index b855db0..9bbb9ed 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 @@ -6,96 +6,156 @@ 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.Enum import org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect +import org.onebusaway.core.checkKnown import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap import org.onebusaway.core.toImmutable import org.onebusaway.errors.OnebusawaySdkInvalidDataException -@NoAutoDetect class References -@JsonCreator private constructor( - @JsonProperty("agencies") - @ExcludeMissing - private val agencies: JsonField> = JsonMissing.of(), - @JsonProperty("routes") - @ExcludeMissing - private val routes: JsonField> = JsonMissing.of(), - @JsonProperty("situations") - @ExcludeMissing - private val situations: JsonField> = JsonMissing.of(), - @JsonProperty("stops") - @ExcludeMissing - private val stops: JsonField> = JsonMissing.of(), - @JsonProperty("stopTimes") - @ExcludeMissing - private val stopTimes: JsonField> = JsonMissing.of(), - @JsonProperty("trips") - @ExcludeMissing - private val trips: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + private val agencies: JsonField>, + private val routes: JsonField>, + private val situations: JsonField>, + private val stops: JsonField>, + private val stopTimes: JsonField>, + private val trips: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("agencies") + @ExcludeMissing + agencies: JsonField> = JsonMissing.of(), + @JsonProperty("routes") @ExcludeMissing routes: JsonField> = JsonMissing.of(), + @JsonProperty("situations") + @ExcludeMissing + situations: JsonField> = JsonMissing.of(), + @JsonProperty("stops") @ExcludeMissing stops: JsonField> = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("trips") @ExcludeMissing trips: JsonField> = JsonMissing.of(), + ) : this(agencies, routes, situations, stops, stopTimes, trips, 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 agencies(): List = agencies.getRequired("agencies") + /** + * @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 routes(): List = routes.getRequired("routes") + /** + * @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 situations(): List = situations.getRequired("situations") + /** + * @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 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 trips(): List = trips.getRequired("trips") + /** + * Returns the raw JSON value of [agencies]. + * + * Unlike [agencies], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("agencies") @ExcludeMissing fun _agencies(): JsonField> = agencies + /** + * Returns the raw JSON value of [routes]. + * + * Unlike [routes], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("routes") @ExcludeMissing fun _routes(): JsonField> = routes + /** + * Returns the raw JSON value of [situations]. + * + * Unlike [situations], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("situations") @ExcludeMissing fun _situations(): JsonField> = situations + /** + * 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 [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 [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) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): References = apply { - if (validated) { - return@apply - } - - agencies().forEach { it.validate() } - routes().forEach { it.validate() } - situations().forEach { it.validate() } - stops().forEach { it.validate() } - stopTimes().forEach { it.validate() } - trips().forEach { it.validate() } - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [References]. + * + * The following fields are required: + * ```java + * .agencies() + * .routes() + * .situations() + * .stops() + * .stopTimes() + * .trips() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -123,116 +183,148 @@ private constructor( fun agencies(agencies: List) = agencies(JsonField.of(agencies)) + /** + * Sets [Builder.agencies] to an arbitrary JSON value. + * + * You should usually call [Builder.agencies] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun agencies(agencies: JsonField>) = apply { this.agencies = agencies.map { it.toMutableList() } } + /** + * Adds a single [Agency] to [agencies]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAgency(agency: Agency) = apply { agencies = - (agencies ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(agency) + (agencies ?: JsonField.of(mutableListOf())).also { + checkKnown("agencies", it).add(agency) } } fun routes(routes: List) = routes(JsonField.of(routes)) + /** + * Sets [Builder.routes] to an arbitrary JSON value. + * + * You should usually call [Builder.routes] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun routes(routes: JsonField>) = apply { this.routes = routes.map { it.toMutableList() } } + /** + * Adds a single [Route] to [routes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRoute(route: Route) = apply { routes = - (routes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(route) + (routes ?: JsonField.of(mutableListOf())).also { + checkKnown("routes", it).add(route) } } fun situations(situations: List) = situations(JsonField.of(situations)) + /** + * Sets [Builder.situations] to an arbitrary JSON value. + * + * You should usually call [Builder.situations] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun situations(situations: JsonField>) = apply { this.situations = situations.map { it.toMutableList() } } + /** + * Adds a single [Situation] to [situations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addSituation(situation: Situation) = apply { situations = - (situations ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situation) + (situations ?: JsonField.of(mutableListOf())).also { + checkKnown("situations", it).add(situation) } } 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())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stop) - } + (stops ?: JsonField.of(mutableListOf())).also { checkKnown("stops", it).add(stop) } } fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) + /** + * 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() } } + /** + * 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())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopTime) + (stopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTimes", it).add(stopTime) } } 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())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(trip) - } + (trips ?: JsonField.of(mutableListOf())).also { checkKnown("trips", it).add(trip) } } fun additionalProperties(additionalProperties: Map) = apply { @@ -254,6 +346,23 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [References]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agencies() + * .routes() + * .situations() + * .stops() + * .stopTimes() + * .trips() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): References = References( checkRequired("agencies", agencies).map { it.toImmutable() }, @@ -262,118 +371,255 @@ private constructor( checkRequired("stops", stops).map { it.toImmutable() }, checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, checkRequired("trips", trips).map { it.toImmutable() }, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } - @NoAutoDetect + private var validated: Boolean = false + + fun validate(): References = apply { + if (validated) { + return@apply + } + + agencies().forEach { it.validate() } + routes().forEach { it.validate() } + situations().forEach { it.validate() } + stops().forEach { it.validate() } + stopTimes().forEach { it.validate() } + trips().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 = + (agencies.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (routes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (situations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stops.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (trips.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Agency - @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("timezone") - @ExcludeMissing - private val timezone: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("disclaimer") - @ExcludeMissing - private val disclaimer: JsonField = JsonMissing.of(), - @JsonProperty("email") - @ExcludeMissing - private val email: JsonField = JsonMissing.of(), - @JsonProperty("fareUrl") - @ExcludeMissing - private val fareUrl: JsonField = JsonMissing.of(), - @JsonProperty("lang") - @ExcludeMissing - private val lang: JsonField = JsonMissing.of(), - @JsonProperty("phone") - @ExcludeMissing - private val phone: JsonField = JsonMissing.of(), - @JsonProperty("privateService") - @ExcludeMissing - private val privateService: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val id: JsonField, + private val name: JsonField, + private val timezone: JsonField, + private val url: JsonField, + private val disclaimer: JsonField, + private val email: JsonField, + private val fareUrl: JsonField, + private val lang: JsonField, + private val phone: JsonField, + private val privateService: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + timezone: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("disclaimer") + @ExcludeMissing + disclaimer: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("fareUrl") @ExcludeMissing fareUrl: JsonField = JsonMissing.of(), + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("phone") @ExcludeMissing phone: JsonField = JsonMissing.of(), + @JsonProperty("privateService") + @ExcludeMissing + privateService: JsonField = JsonMissing.of(), + ) : this( + id, + name, + timezone, + url, + disclaimer, + email, + fareUrl, + lang, + phone, + privateService, + 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 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 timezone(): String = timezone.getRequired("timezone") + /** + * @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 url(): String = url.getRequired("url") - fun disclaimer(): Optional = - Optional.ofNullable(disclaimer.getNullable("disclaimer")) - - fun email(): Optional = Optional.ofNullable(email.getNullable("email")) - - fun fareUrl(): Optional = Optional.ofNullable(fareUrl.getNullable("fareUrl")) - - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) - - fun phone(): Optional = Optional.ofNullable(phone.getNullable("phone")) - - fun privateService(): Optional = - Optional.ofNullable(privateService.getNullable("privateService")) - + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun disclaimer(): Optional = disclaimer.getOptional("disclaimer") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fareUrl(): Optional = fareUrl.getOptional("fareUrl") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun phone(): Optional = phone.getOptional("phone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun privateService(): Optional = privateService.getOptional("privateService") + + /** + * 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 [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + /** + * Returns the raw JSON value of [disclaimer]. + * + * Unlike [disclaimer], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("disclaimer") @ExcludeMissing fun _disclaimer(): JsonField = disclaimer + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + /** + * Returns the raw JSON value of [fareUrl]. + * + * Unlike [fareUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl(): JsonField = fareUrl + /** + * Returns the raw JSON value of [lang]. + * + * Unlike [lang], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang + /** + * Returns the raw JSON value of [phone]. + * + * Unlike [phone], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone + /** + * Returns the raw JSON value of [privateService]. + * + * Unlike [privateService], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("privateService") @ExcludeMissing fun _privateService(): JsonField = privateService + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Agency = apply { - if (validated) { - return@apply - } - - id() - name() - timezone() - url() - disclaimer() - email() - fareUrl() - lang() - phone() - privateService() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Agency]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .timezone() + * .url() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -409,43 +655,113 @@ private constructor( 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: 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 timezone(timezone: String) = timezone(JsonField.of(timezone)) + /** + * 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 } fun url(url: String) = url(JsonField.of(url)) + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun url(url: JsonField) = apply { this.url = url } fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) + /** + * Sets [Builder.disclaimer] to an arbitrary JSON value. + * + * You should usually call [Builder.disclaimer] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun disclaimer(disclaimer: JsonField) = apply { this.disclaimer = disclaimer } fun email(email: String) = email(JsonField.of(email)) + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun email(email: JsonField) = apply { this.email = email } fun fareUrl(fareUrl: String) = fareUrl(JsonField.of(fareUrl)) + /** + * Sets [Builder.fareUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.fareUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } fun lang(lang: String) = lang(JsonField.of(lang)) + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun lang(lang: JsonField) = apply { this.lang = lang } fun phone(phone: String) = phone(JsonField.of(phone)) + /** + * Sets [Builder.phone] to an arbitrary JSON value. + * + * You should usually call [Builder.phone] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun phone(phone: JsonField) = apply { this.phone = phone } fun privateService(privateService: Boolean) = privateService(JsonField.of(privateService)) + /** + * Sets [Builder.privateService] to an arbitrary JSON value. + * + * You should usually call [Builder.privateService] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun privateService(privateService: JsonField) = apply { this.privateService = privateService } @@ -469,6 +785,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Agency]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .timezone() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Agency = Agency( checkRequired("id", id), @@ -481,10 +812,57 @@ private constructor( lang, phone, privateService, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): Agency = apply { + if (validated) { + return@apply + } + + id() + name() + timezone() + url() + disclaimer() + email() + fareUrl() + lang() + phone() + privateService() + 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 (name.asKnown().isPresent) 1 else 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (disclaimer.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (fareUrl.asKnown().isPresent) 1 else 0) + + (if (lang.asKnown().isPresent) 1 else 0) + + (if (phone.asKnown().isPresent) 1 else 0) + + (if (privateService.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -503,112 +881,219 @@ private constructor( "Agency{id=$id, name=$name, timezone=$timezone, url=$url, disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, lang=$lang, phone=$phone, privateService=$privateService, additionalProperties=$additionalProperties}" } - @NoAutoDetect class Route - @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("agencyId") - @ExcludeMissing - private val agencyId: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("longName") - @ExcludeMissing - private val longName: JsonField = JsonMissing.of(), - @JsonProperty("nullSafeShortName") - @ExcludeMissing - private val nullSafeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shortName") - @ExcludeMissing - private val shortName: JsonField = JsonMissing.of(), - @JsonProperty("textColor") - @ExcludeMissing - private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + 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 agencyId(): String = agencyId.getRequired("agencyId") + /** + * @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 type(): Long = type.getRequired("type") - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = Optional.ofNullable(textColor.getNullable("textColor")) - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * 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 [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + /** + * 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 + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("nullSafeShortName") @ExcludeMissing fun _nullSafeShortName(): JsonField = nullSafeShortName + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("shortName") @ExcludeMissing fun _shortName(): JsonField = shortName + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("textColor") @ExcludeMissing fun _textColor(): JsonField = textColor + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Route = apply { - if (validated) { - return@apply - } - - id() - agencyId() - type() - color() - description() - longName() - nullSafeShortName() - shortName() - textColor() - url() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Route]. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -644,49 +1129,119 @@ private constructor( 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 agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } fun type(type: Long) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] 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 color(color: String) = color(JsonField.of(color)) + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun color(color: JsonField) = apply { this.color = color } fun description(description: String) = description(JsonField.of(description)) + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } fun longName(longName: String) = longName(JsonField.of(longName)) + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun longName(longName: JsonField) = apply { this.longName = longName } fun nullSafeShortName(nullSafeShortName: String) = nullSafeShortName(JsonField.of(nullSafeShortName)) + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun nullSafeShortName(nullSafeShortName: JsonField) = apply { this.nullSafeShortName = nullSafeShortName } fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun shortName(shortName: JsonField) = apply { this.shortName = shortName } fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun textColor(textColor: JsonField) = apply { this.textColor = textColor } fun url(url: String) = url(JsonField.of(url)) - fun url(url: JsonField) = apply { this.url = url } - + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -706,6 +1261,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Route]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Route = Route( checkRequired("id", id), @@ -718,10 +1287,57 @@ private constructor( shortName, textColor, url, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): Route = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + 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 (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -740,154 +1356,280 @@ private constructor( "Route{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" } - @NoAutoDetect class Situation - @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("creationTime") - @ExcludeMissing - private val creationTime: JsonField = JsonMissing.of(), - @JsonProperty("activeWindows") - @ExcludeMissing - private val activeWindows: JsonField> = JsonMissing.of(), - @JsonProperty("allAffects") - @ExcludeMissing - private val allAffects: JsonField> = JsonMissing.of(), - @JsonProperty("consequenceMessage") - @ExcludeMissing - private val consequenceMessage: JsonField = JsonMissing.of(), - @JsonProperty("consequences") - @ExcludeMissing - private val consequences: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("publicationWindows") - @ExcludeMissing - private val publicationWindows: JsonField> = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("severity") - @ExcludeMissing - private val severity: JsonField = JsonMissing.of(), - @JsonProperty("summary") - @ExcludeMissing - private val summary: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val id: JsonField, + private val creationTime: JsonField, + private val activeWindows: JsonField>, + private val allAffects: JsonField>, + private val consequenceMessage: JsonField, + private val consequences: JsonField>, + private val description: JsonField, + private val publicationWindows: JsonField>, + private val reason: JsonField, + private val severity: JsonField, + private val summary: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, ) { - /** Unique identifier for the situation. */ + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creationTime") + @ExcludeMissing + creationTime: JsonField = JsonMissing.of(), + @JsonProperty("activeWindows") + @ExcludeMissing + activeWindows: JsonField> = JsonMissing.of(), + @JsonProperty("allAffects") + @ExcludeMissing + allAffects: JsonField> = JsonMissing.of(), + @JsonProperty("consequenceMessage") + @ExcludeMissing + consequenceMessage: JsonField = JsonMissing.of(), + @JsonProperty("consequences") + @ExcludeMissing + consequences: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("publicationWindows") + @ExcludeMissing + publicationWindows: JsonField> = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("severity") + @ExcludeMissing + severity: JsonField = JsonMissing.of(), + @JsonProperty("summary") @ExcludeMissing summary: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + creationTime, + activeWindows, + allAffects, + consequenceMessage, + consequences, + description, + publicationWindows, + reason, + severity, + summary, + url, + mutableMapOf(), + ) + + /** + * Unique identifier for the situation. + * + * @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") - /** Unix timestamp of when this situation was created. */ + /** + * Unix timestamp of when this situation was created. + * + * @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 creationTime(): Long = creationTime.getRequired("creationTime") + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun activeWindows(): Optional> = - Optional.ofNullable(activeWindows.getNullable("activeWindows")) - - fun allAffects(): Optional> = - Optional.ofNullable(allAffects.getNullable("allAffects")) - - /** Message regarding the consequence of the situation. */ + activeWindows.getOptional("activeWindows") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allAffects(): Optional> = allAffects.getOptional("allAffects") + + /** + * Message regarding the consequence of the situation. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun consequenceMessage(): Optional = - Optional.ofNullable(consequenceMessage.getNullable("consequenceMessage")) - - fun consequences(): Optional> = - Optional.ofNullable(consequences.getNullable("consequences")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - + consequenceMessage.getOptional("consequenceMessage") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consequences(): Optional> = consequences.getOptional("consequences") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun publicationWindows(): Optional> = - Optional.ofNullable(publicationWindows.getNullable("publicationWindows")) - - /** Reason for the service alert, taken from TPEG codes. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** Severity of the situation. */ - fun severity(): Optional = Optional.ofNullable(severity.getNullable("severity")) - - fun summary(): Optional = Optional.ofNullable(summary.getNullable("summary")) - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - /** Unique identifier for the situation. */ + publicationWindows.getOptional("publicationWindows") + + /** + * Reason for the service alert, taken from TPEG codes. + * + * @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") + + /** + * Severity of the situation. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun severity(): Optional = severity.getOptional("severity") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun summary(): Optional = summary.getOptional("summary") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * 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 - /** Unix timestamp of when this situation was created. */ + /** + * Returns the raw JSON value of [creationTime]. + * + * Unlike [creationTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("creationTime") @ExcludeMissing fun _creationTime(): JsonField = creationTime + /** + * Returns the raw JSON value of [activeWindows]. + * + * Unlike [activeWindows], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("activeWindows") @ExcludeMissing fun _activeWindows(): JsonField> = activeWindows + /** + * Returns the raw JSON value of [allAffects]. + * + * Unlike [allAffects], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("allAffects") @ExcludeMissing fun _allAffects(): JsonField> = allAffects - /** Message regarding the consequence of the situation. */ + /** + * Returns the raw JSON value of [consequenceMessage]. + * + * Unlike [consequenceMessage], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("consequenceMessage") @ExcludeMissing fun _consequenceMessage(): JsonField = consequenceMessage + /** + * Returns the raw JSON value of [consequences]. + * + * Unlike [consequences], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("consequences") @ExcludeMissing fun _consequences(): JsonField> = consequences + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [publicationWindows]. + * + * Unlike [publicationWindows], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("publicationWindows") @ExcludeMissing fun _publicationWindows(): JsonField> = publicationWindows - /** Reason for the service alert, taken from TPEG codes. */ + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - /** Severity of the situation. */ + /** + * Returns the raw JSON value of [severity]. + * + * Unlike [severity], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("severity") @ExcludeMissing fun _severity(): JsonField = severity + /** + * Returns the raw JSON value of [summary]. + * + * Unlike [summary], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("summary") @ExcludeMissing fun _summary(): JsonField = summary + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Situation = apply { - if (validated) { - return@apply - } - - id() - creationTime() - activeWindows().ifPresent { it.forEach { it.validate() } } - allAffects().ifPresent { it.forEach { it.validate() } } - consequenceMessage() - consequences().ifPresent { it.forEach { it.validate() } } - description().ifPresent { it.validate() } - publicationWindows().ifPresent { it.forEach { it.validate() } } - reason() - severity() - summary().ifPresent { it.validate() } - url().ifPresent { it.validate() } - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Situation]. + * + * The following fields are required: + * ```java + * .id() + * .creationTime() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -928,13 +1670,25 @@ private constructor( /** Unique identifier for the situation. */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the situation. */ + /** + * 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 } /** Unix timestamp of when this situation was created. */ fun creationTime(creationTime: Long) = creationTime(JsonField.of(creationTime)) - /** Unix timestamp of when this situation was created. */ + /** + * Sets [Builder.creationTime] to an arbitrary JSON value. + * + * You should usually call [Builder.creationTime] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun creationTime(creationTime: JsonField) = apply { this.creationTime = creationTime } @@ -942,39 +1696,51 @@ private constructor( fun activeWindows(activeWindows: List) = activeWindows(JsonField.of(activeWindows)) + /** + * Sets [Builder.activeWindows] to an arbitrary JSON value. + * + * You should usually call [Builder.activeWindows] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ fun activeWindows(activeWindows: JsonField>) = apply { this.activeWindows = activeWindows.map { it.toMutableList() } } + /** + * Adds a single [ActiveWindow] to [activeWindows]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addActiveWindow(activeWindow: ActiveWindow) = apply { activeWindows = - (activeWindows ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(activeWindow) + (activeWindows ?: JsonField.of(mutableListOf())).also { + checkKnown("activeWindows", it).add(activeWindow) } } fun allAffects(allAffects: List) = allAffects(JsonField.of(allAffects)) + /** + * Sets [Builder.allAffects] to an arbitrary JSON value. + * + * You should usually call [Builder.allAffects] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun allAffects(allAffects: JsonField>) = apply { this.allAffects = allAffects.map { it.toMutableList() } } + /** + * Adds a single [AllAffect] to [allAffects]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAllAffect(allAffect: AllAffect) = apply { allAffects = - (allAffects ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(allAffect) + (allAffects ?: JsonField.of(mutableListOf())).also { + checkKnown("allAffects", it).add(allAffect) } } @@ -982,7 +1748,13 @@ private constructor( fun consequenceMessage(consequenceMessage: String) = consequenceMessage(JsonField.of(consequenceMessage)) - /** Message regarding the consequence of the situation. */ + /** + * Sets [Builder.consequenceMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.consequenceMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun consequenceMessage(consequenceMessage: JsonField) = apply { this.consequenceMessage = consequenceMessage } @@ -990,25 +1762,38 @@ private constructor( fun consequences(consequences: List) = consequences(JsonField.of(consequences)) + /** + * Sets [Builder.consequences] to an arbitrary JSON value. + * + * You should usually call [Builder.consequences] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun consequences(consequences: JsonField>) = apply { this.consequences = consequences.map { it.toMutableList() } } + /** + * Adds a single [Consequence] to [consequences]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addConsequence(consequence: Consequence) = apply { consequences = - (consequences ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(consequence) + (consequences ?: JsonField.of(mutableListOf())).also { + checkKnown("consequences", it).add(consequence) } } fun description(description: Description) = description(JsonField.of(description)) + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [Description] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -1016,41 +1801,73 @@ private constructor( fun publicationWindows(publicationWindows: List) = publicationWindows(JsonField.of(publicationWindows)) + /** + * Sets [Builder.publicationWindows] to an arbitrary JSON value. + * + * You should usually call [Builder.publicationWindows] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun publicationWindows(publicationWindows: JsonField>) = apply { this.publicationWindows = publicationWindows.map { it.toMutableList() } } + /** + * Adds a single [PublicationWindow] to [publicationWindows]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addPublicationWindow(publicationWindow: PublicationWindow) = apply { publicationWindows = - (publicationWindows ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(publicationWindow) + (publicationWindows ?: JsonField.of(mutableListOf())).also { + checkKnown("publicationWindows", it).add(publicationWindow) } } /** Reason for the service alert, taken from TPEG codes. */ fun reason(reason: Reason) = reason(JsonField.of(reason)) - /** Reason for the service alert, taken from TPEG codes. */ + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [Reason] 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 } /** Severity of the situation. */ fun severity(severity: String) = severity(JsonField.of(severity)) - /** Severity of the situation. */ + /** + * Sets [Builder.severity] to an arbitrary JSON value. + * + * You should usually call [Builder.severity] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun severity(severity: JsonField) = apply { this.severity = severity } fun summary(summary: Summary) = summary(JsonField.of(summary)) + /** + * Sets [Builder.summary] to an arbitrary JSON value. + * + * You should usually call [Builder.summary] with a well-typed [Summary] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun summary(summary: JsonField) = apply { this.summary = summary } fun url(url: Url) = url(JsonField.of(url)) + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [Url] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { @@ -1072,6 +1889,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Situation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creationTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Situation = Situation( checkRequired("id", id), @@ -1086,54 +1916,119 @@ private constructor( severity, summary, url, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } - @NoAutoDetect + private var validated: Boolean = false + + fun validate(): Situation = apply { + if (validated) { + return@apply + } + + id() + creationTime() + activeWindows().ifPresent { it.forEach { it.validate() } } + allAffects().ifPresent { it.forEach { it.validate() } } + consequenceMessage() + consequences().ifPresent { it.forEach { it.validate() } } + description().ifPresent { it.validate() } + publicationWindows().ifPresent { it.forEach { it.validate() } } + reason().ifPresent { it.validate() } + severity() + summary().ifPresent { it.validate() } + url().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 (id.asKnown().isPresent) 1 else 0) + + (if (creationTime.asKnown().isPresent) 1 else 0) + + (activeWindows.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (allAffects.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (consequenceMessage.asKnown().isPresent) 1 else 0) + + (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 (severity.asKnown().isPresent) 1 else 0) + + (summary.asKnown().getOrNull()?.validity() ?: 0) + + (url.asKnown().getOrNull()?.validity() ?: 0) + class ActiveWindow - @JsonCreator private constructor( - @JsonProperty("from") - @ExcludeMissing - private val from: JsonField = JsonMissing.of(), - @JsonProperty("to") @ExcludeMissing private val to: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val from: JsonField, + private val to: JsonField, + private val additionalProperties: MutableMap, ) { - /** Start time of the active window as a Unix timestamp. */ - fun from(): Optional = Optional.ofNullable(from.getNullable("from")) + @JsonCreator + private constructor( + @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + ) : this(from, to, mutableMapOf()) + + /** + * Start time of the active window as a Unix timestamp. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun from(): Optional = from.getOptional("from") - /** End time of the active window as a Unix timestamp. */ - fun to(): Optional = Optional.ofNullable(to.getNullable("to")) + /** + * End time of the active window as a Unix timestamp. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun to(): Optional = to.getOptional("to") - /** Start time of the active window as a Unix timestamp. */ + /** + * Returns the raw JSON value of [from]. + * + * Unlike [from], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from - /** End time of the active window as a Unix timestamp. */ + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ActiveWindow = apply { - if (validated) { - return@apply - } - - from() - to() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [ActiveWindow]. */ @JvmStatic fun builder() = Builder() } @@ -1154,13 +2049,25 @@ private constructor( /** Start time of the active window as a Unix timestamp. */ fun from(from: Long) = from(JsonField.of(from)) - /** Start time of the active window as a Unix timestamp. */ + /** + * Sets [Builder.from] to an arbitrary JSON value. + * + * You should usually call [Builder.from] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun from(from: JsonField) = apply { this.from = from } /** End time of the active window as a Unix timestamp. */ fun to(to: Long) = to(JsonField.of(to)) - /** End time of the active window as a Unix timestamp. */ + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun to(to: JsonField) = apply { this.to = to } fun additionalProperties(additionalProperties: Map) = apply { @@ -1185,14 +2092,45 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ActiveWindow]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ActiveWindow = - ActiveWindow( - from, - to, - additionalProperties.toImmutable(), - ) + ActiveWindow(from, to, additionalProperties.toMutableMap()) } + private var validated: Boolean = false + + fun validate(): ActiveWindow = apply { + if (validated) { + return@apply + } + + from() + to() + 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 (from.asKnown().isPresent) 1 else 0) + (if (to.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1211,98 +2149,149 @@ private constructor( "ActiveWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" } - @NoAutoDetect class AllAffect - @JsonCreator private constructor( - @JsonProperty("agencyId") - @ExcludeMissing - private val agencyId: JsonField = JsonMissing.of(), - @JsonProperty("applicationId") - @ExcludeMissing - private val applicationId: JsonField = JsonMissing.of(), - @JsonProperty("directionId") - @ExcludeMissing - private val directionId: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val agencyId: JsonField, + private val applicationId: JsonField, + private val directionId: JsonField, + private val routeId: JsonField, + private val stopId: JsonField, + private val tripId: JsonField, + private val additionalProperties: MutableMap, ) { - /** Identifier for the agency. */ - fun agencyId(): Optional = Optional.ofNullable(agencyId.getNullable("agencyId")) + @JsonCreator + private constructor( + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("applicationId") + @ExcludeMissing + applicationId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + directionId: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") @ExcludeMissing tripId: JsonField = JsonMissing.of(), + ) : this(agencyId, applicationId, directionId, routeId, stopId, tripId, mutableMapOf()) - /** Identifier for the application. */ - fun applicationId(): Optional = - Optional.ofNullable(applicationId.getNullable("applicationId")) + /** + * Identifier for the agency. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun agencyId(): Optional = agencyId.getOptional("agencyId") - /** Identifier for the direction. */ - fun directionId(): Optional = - Optional.ofNullable(directionId.getNullable("directionId")) + /** + * Identifier for the application. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicationId(): Optional = applicationId.getOptional("applicationId") - /** Identifier for the route. */ - fun routeId(): Optional = Optional.ofNullable(routeId.getNullable("routeId")) + /** + * Identifier for the direction. + * + * @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") - /** Identifier for the stop. */ - fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) + /** + * Identifier for the route. + * + * @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") - /** Identifier for the trip. */ - fun tripId(): Optional = Optional.ofNullable(tripId.getNullable("tripId")) + /** + * Identifier for the stop. + * + * @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") - /** Identifier for the agency. */ + /** + * Identifier for the trip. + * + * @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") + + /** + * Returns the raw JSON value of [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - /** Identifier for the application. */ + /** + * Returns the raw JSON value of [applicationId]. + * + * Unlike [applicationId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("applicationId") @ExcludeMissing fun _applicationId(): JsonField = applicationId - /** Identifier for the direction. */ + /** + * 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 - /** Identifier for the route. */ + /** + * 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 - /** Identifier for the stop. */ + /** + * 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 - /** Identifier for the trip. */ + /** + * 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 = additionalProperties - - private var validated: Boolean = false - - fun validate(): AllAffect = apply { - if (validated) { - return@apply - } - - agencyId() - applicationId() - directionId() - routeId() - stopId() - tripId() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [AllAffect]. */ @JvmStatic fun builder() = Builder() } @@ -1331,14 +2320,26 @@ private constructor( /** Identifier for the agency. */ fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - /** Identifier for the agency. */ + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } /** Identifier for the application. */ fun applicationId(applicationId: String) = applicationId(JsonField.of(applicationId)) - /** Identifier for the application. */ + /** + * Sets [Builder.applicationId] to an arbitrary JSON value. + * + * You should usually call [Builder.applicationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun applicationId(applicationId: JsonField) = apply { this.applicationId = applicationId } @@ -1346,7 +2347,13 @@ private constructor( /** Identifier for the direction. */ fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - /** Identifier for the direction. */ + /** + * 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 } @@ -1354,19 +2361,37 @@ private constructor( /** Identifier for the route. */ fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - /** Identifier for the route. */ + /** + * 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 } /** Identifier for the stop. */ fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - /** Identifier for the stop. */ + /** + * 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 } /** Identifier for the trip. */ fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - /** Identifier for the trip. */ + /** + * 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 { @@ -1391,6 +2416,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [AllAffect]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): AllAffect = AllAffect( agencyId, @@ -1399,10 +2429,49 @@ private constructor( routeId, stopId, tripId, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): AllAffect = apply { + if (validated) { + return@apply + } + + agencyId() + applicationId() + directionId() + routeId() + stopId() + 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 = + (if (agencyId.asKnown().isPresent) 1 else 0) + + (if (applicationId.asKnown().isPresent) 1 else 0) + + (if (directionId.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1421,56 +2490,73 @@ private constructor( "AllAffect{agencyId=$agencyId, applicationId=$applicationId, directionId=$directionId, routeId=$routeId, stopId=$stopId, tripId=$tripId, additionalProperties=$additionalProperties}" } - @NoAutoDetect class Consequence - @JsonCreator private constructor( - @JsonProperty("condition") - @ExcludeMissing - private val condition: JsonField = JsonMissing.of(), - @JsonProperty("conditionDetails") - @ExcludeMissing - private val conditionDetails: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val condition: JsonField, + private val conditionDetails: JsonField, + private val additionalProperties: MutableMap, ) { - /** Condition of the consequence. */ - fun condition(): Optional = - Optional.ofNullable(condition.getNullable("condition")) + @JsonCreator + private constructor( + @JsonProperty("condition") + @ExcludeMissing + condition: JsonField = JsonMissing.of(), + @JsonProperty("conditionDetails") + @ExcludeMissing + conditionDetails: JsonField = JsonMissing.of(), + ) : this(condition, conditionDetails, mutableMapOf()) + + /** + * Condition of the consequence. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun condition(): Optional = condition.getOptional("condition") + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ fun conditionDetails(): Optional = - Optional.ofNullable(conditionDetails.getNullable("conditionDetails")) + conditionDetails.getOptional("conditionDetails") - /** Condition of the consequence. */ + /** + * Returns the raw JSON value of [condition]. + * + * Unlike [condition], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("condition") @ExcludeMissing fun _condition(): JsonField = condition + /** + * Returns the raw JSON value of [conditionDetails]. + * + * Unlike [conditionDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("conditionDetails") @ExcludeMissing fun _conditionDetails(): JsonField = conditionDetails + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Consequence = apply { - if (validated) { - return@apply - } - - condition() - conditionDetails().ifPresent { it.validate() } - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [Consequence]. */ @JvmStatic fun builder() = Builder() } @@ -1491,12 +2577,25 @@ private constructor( /** Condition of the consequence. */ fun condition(condition: String) = condition(JsonField.of(condition)) - /** Condition of the consequence. */ + /** + * Sets [Builder.condition] to an arbitrary JSON value. + * + * You should usually call [Builder.condition] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun condition(condition: JsonField) = apply { this.condition = condition } fun conditionDetails(conditionDetails: ConditionDetails) = conditionDetails(JsonField.of(conditionDetails)) + /** + * Sets [Builder.conditionDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.conditionDetails] with a well-typed + * [ConditionDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ fun conditionDetails(conditionDetails: JsonField) = apply { this.conditionDetails = conditionDetails } @@ -1523,62 +2622,114 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Consequence]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Consequence = - Consequence( - condition, - conditionDetails, - additionalProperties.toImmutable(), - ) + Consequence(condition, conditionDetails, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Consequence = apply { + if (validated) { + return@apply + } + + condition() + conditionDetails().ifPresent { it.validate() } + validated = true } - @NoAutoDetect + 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 (condition.asKnown().isPresent) 1 else 0) + + (conditionDetails.asKnown().getOrNull()?.validity() ?: 0) + class ConditionDetails - @JsonCreator private constructor( - @JsonProperty("diversionPath") - @ExcludeMissing - private val diversionPath: JsonField = JsonMissing.of(), - @JsonProperty("diversionStopIds") - @ExcludeMissing - private val diversionStopIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val diversionPath: JsonField, + private val diversionStopIds: JsonField>, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("diversionPath") + @ExcludeMissing + diversionPath: JsonField = JsonMissing.of(), + @JsonProperty("diversionStopIds") + @ExcludeMissing + diversionStopIds: JsonField> = JsonMissing.of(), + ) : this(diversionPath, diversionStopIds, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun diversionPath(): Optional = - Optional.ofNullable(diversionPath.getNullable("diversionPath")) + diversionPath.getOptional("diversionPath") + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun diversionStopIds(): Optional> = - Optional.ofNullable(diversionStopIds.getNullable("diversionStopIds")) + diversionStopIds.getOptional("diversionStopIds") + /** + * Returns the raw JSON value of [diversionPath]. + * + * Unlike [diversionPath], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("diversionPath") @ExcludeMissing fun _diversionPath(): JsonField = diversionPath + /** + * Returns the raw JSON value of [diversionStopIds]. + * + * Unlike [diversionStopIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("diversionStopIds") @ExcludeMissing fun _diversionStopIds(): JsonField> = diversionStopIds + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ConditionDetails = apply { - if (validated) { - return@apply - } - - diversionPath().ifPresent { it.validate() } - diversionStopIds() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [ConditionDetails]. + */ @JvmStatic fun builder() = Builder() } @@ -1600,6 +2751,13 @@ private constructor( fun diversionPath(diversionPath: DiversionPath) = diversionPath(JsonField.of(diversionPath)) + /** + * Sets [Builder.diversionPath] to an arbitrary JSON value. + * + * You should usually call [Builder.diversionPath] with a well-typed + * [DiversionPath] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ fun diversionPath(diversionPath: JsonField) = apply { this.diversionPath = diversionPath } @@ -1607,20 +2765,26 @@ private constructor( fun diversionStopIds(diversionStopIds: List) = diversionStopIds(JsonField.of(diversionStopIds)) + /** + * Sets [Builder.diversionStopIds] to an arbitrary JSON value. + * + * You should usually call [Builder.diversionStopIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ fun diversionStopIds(diversionStopIds: JsonField>) = apply { this.diversionStopIds = diversionStopIds.map { it.toMutableList() } } + /** + * Adds a single [String] to [diversionStopIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addDiversionStopId(diversionStopId: String) = apply { diversionStopIds = - (diversionStopIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(diversionStopId) + (diversionStopIds ?: JsonField.of(mutableListOf())).also { + checkKnown("diversionStopIds", it).add(diversionStopId) } } @@ -1646,76 +2810,141 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ConditionDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ConditionDetails = ConditionDetails( diversionPath, (diversionStopIds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } - @NoAutoDetect - class DiversionPath - @JsonCreator - private constructor( - @JsonProperty("length") - @ExcludeMissing - private val length: JsonField = JsonMissing.of(), - @JsonProperty("levels") - @ExcludeMissing - private val levels: JsonField = JsonMissing.of(), - @JsonProperty("points") - @ExcludeMissing - private val points: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + private var validated: Boolean = false + + fun validate(): ConditionDetails = apply { + if (validated) { + return@apply + } + + diversionPath().ifPresent { it.validate() } + diversionStopIds() + validated = true + } - /** Length of the diversion path. */ - fun length(): Optional = Optional.ofNullable(length.getNullable("length")) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } - /** Levels of the diversion path. */ - fun levels(): Optional = - Optional.ofNullable(levels.getNullable("levels")) + /** + * 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 = + (diversionPath.asKnown().getOrNull()?.validity() ?: 0) + + (diversionStopIds.asKnown().getOrNull()?.size ?: 0) - /** Points of the diversion path. */ - fun points(): Optional = - Optional.ofNullable(points.getNullable("points")) + class DiversionPath + private constructor( + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Length of the diversion path. */ + @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()) + + /** + * Length of the diversion path. + * + * @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") + + /** + * Levels of the diversion path. + * + * @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") + + /** + * Points of the diversion path. + * + * @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 - /** Levels of the diversion path. */ + /** + * 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 - /** Points of the diversion path. */ + /** + * 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 = additionalProperties - - private var validated: Boolean = false - - fun validate(): DiversionPath = apply { - if (validated) { - return@apply - } - - length() - levels() - points() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [DiversionPath]. + */ @JvmStatic fun builder() = Builder() } @@ -1739,19 +2968,37 @@ private constructor( /** Length of the diversion path. */ fun length(length: Long) = length(JsonField.of(length)) - /** Length of the diversion path. */ + /** + * 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 } /** Levels of the diversion path. */ fun levels(levels: String) = levels(JsonField.of(levels)) - /** Levels of the diversion path. */ + /** + * 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 } /** Points of the diversion path. */ fun points(points: String) = points(JsonField.of(points)) - /** Points of the diversion path. */ + /** + * 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) = @@ -1776,15 +3023,53 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [DiversionPath]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): DiversionPath = DiversionPath( length, levels, points, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): DiversionPath = 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 @@ -1839,52 +3124,64 @@ private constructor( "Consequence{condition=$condition, conditionDetails=$conditionDetails, additionalProperties=$additionalProperties}" } - @NoAutoDetect class Description - @JsonCreator private constructor( - @JsonProperty("lang") - @ExcludeMissing - private val lang: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val lang: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, ) { - /** Language of the description. */ - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) + @JsonCreator + private constructor( + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(lang, value, mutableMapOf()) + + /** + * Language of the description. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") - /** Longer description of the situation. */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + /** + * Longer description of the situation. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") - /** Language of the description. */ + /** + * Returns the raw JSON value of [lang]. + * + * Unlike [lang], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang - /** Longer description of the situation. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Description = apply { - if (validated) { - return@apply - } - - lang() - value() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [Description]. */ @JvmStatic fun builder() = Builder() } @@ -1905,13 +3202,25 @@ private constructor( /** Language of the description. */ fun lang(lang: String) = lang(JsonField.of(lang)) - /** Language of the description. */ + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun lang(lang: JsonField) = apply { this.lang = lang } /** Longer description of the situation. */ fun value(value: String) = value(JsonField.of(value)) - /** Longer description of the situation. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { @@ -1936,14 +3245,45 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Description]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Description = - Description( - lang, - value, - additionalProperties.toImmutable(), - ) + Description(lang, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Description = apply { + if (validated) { + return@apply + } + + lang() + value() + 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 (lang.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1962,50 +3302,74 @@ private constructor( "Description{lang=$lang, value=$value, additionalProperties=$additionalProperties}" } - @NoAutoDetect class PublicationWindow - @JsonCreator private constructor( - @JsonProperty("from") - @ExcludeMissing - private val from: JsonField = JsonMissing.of(), - @JsonProperty("to") @ExcludeMissing private val to: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val from: JsonField, + private val to: JsonField, + private val additionalProperties: MutableMap, ) { - /** Start time of the time window as a Unix timestamp. */ + @JsonCreator + private constructor( + @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + ) : this(from, to, mutableMapOf()) + + /** + * Start time of the time window as a Unix timestamp. + * + * @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 from(): Long = from.getRequired("from") - /** End time of the time window as a Unix timestamp. */ + /** + * End time of the time window as a Unix timestamp. + * + * @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 to(): Long = to.getRequired("to") - /** Start time of the time window as a Unix timestamp. */ + /** + * Returns the raw JSON value of [from]. + * + * Unlike [from], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from - /** End time of the time window as a Unix timestamp. */ + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PublicationWindow = apply { - if (validated) { - return@apply - } - - from() - to() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [PublicationWindow]. + * + * The following fields are required: + * ```java + * .from() + * .to() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2026,13 +3390,25 @@ private constructor( /** Start time of the time window as a Unix timestamp. */ fun from(from: Long) = from(JsonField.of(from)) - /** Start time of the time window as a Unix timestamp. */ + /** + * Sets [Builder.from] to an arbitrary JSON value. + * + * You should usually call [Builder.from] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun from(from: JsonField) = apply { this.from = from } /** End time of the time window as a Unix timestamp. */ fun to(to: Long) = to(JsonField.of(to)) - /** End time of the time window as a Unix timestamp. */ + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun to(to: JsonField) = apply { this.to = to } fun additionalProperties(additionalProperties: Map) = apply { @@ -2057,14 +3433,57 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [PublicationWindow]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .from() + * .to() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PublicationWindow = PublicationWindow( checkRequired("from", from), checkRequired("to", to), - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): PublicationWindow = apply { + if (validated) { + return@apply + } + + from() + to() + 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 (from.asKnown().isPresent) 1 else 0) + (if (to.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2084,11 +3503,7 @@ private constructor( } /** Reason for the service alert, taken from TPEG codes. */ - class Reason - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -2181,7 +3596,46 @@ private constructor( else -> throw OnebusawaySdkInvalidDataException("Unknown Reason: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2196,52 +3650,64 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect class Summary - @JsonCreator private constructor( - @JsonProperty("lang") - @ExcludeMissing - private val lang: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val lang: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, ) { - /** Language of the summary. */ - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) + @JsonCreator + private constructor( + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(lang, value, mutableMapOf()) + + /** + * Language of the summary. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") - /** Short summary of the situation. */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + /** + * Short summary of the situation. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") - /** Language of the summary. */ + /** + * Returns the raw JSON value of [lang]. + * + * Unlike [lang], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang - /** Short summary of the situation. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Summary = apply { - if (validated) { - return@apply - } - - lang() - value() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [Summary]. */ @JvmStatic fun builder() = Builder() } @@ -2262,13 +3728,25 @@ private constructor( /** Language of the summary. */ fun lang(lang: String) = lang(JsonField.of(lang)) - /** Language of the summary. */ + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun lang(lang: JsonField) = apply { this.lang = lang } /** Short summary of the situation. */ fun value(value: String) = value(JsonField.of(value)) - /** Short summary of the situation. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { @@ -2293,14 +3771,44 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Summary = - Summary( - lang, - value, - additionalProperties.toImmutable(), - ) + /** + * Returns an immutable instance of [Summary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Summary = Summary(lang, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Summary = apply { + if (validated) { + return@apply + } + + lang() + value() + 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 (lang.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2319,52 +3827,64 @@ private constructor( "Summary{lang=$lang, value=$value, additionalProperties=$additionalProperties}" } - @NoAutoDetect class Url - @JsonCreator private constructor( - @JsonProperty("lang") - @ExcludeMissing - private val lang: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val lang: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, ) { - /** Language of the URL. */ - fun lang(): Optional = Optional.ofNullable(lang.getNullable("lang")) + @JsonCreator + private constructor( + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(lang, value, mutableMapOf()) + + /** + * Language of the URL. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") - /** URL for more information about the situation. */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + /** + * URL for more information about the situation. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") - /** Language of the URL. */ + /** + * Returns the raw JSON value of [lang]. + * + * Unlike [lang], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang - /** URL for more information about the situation. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Url = apply { - if (validated) { - return@apply - } - - lang() - value() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [Url]. */ @JvmStatic fun builder() = Builder() } @@ -2385,13 +3905,25 @@ private constructor( /** Language of the URL. */ fun lang(lang: String) = lang(JsonField.of(lang)) - /** Language of the URL. */ + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun lang(lang: JsonField) = apply { this.lang = lang } /** URL for more information about the situation. */ fun value(value: String) = value(JsonField.of(value)) - /** URL for more information about the situation. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { @@ -2416,14 +3948,44 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Url = - Url( - lang, - value, - additionalProperties.toImmutable(), - ) + /** + * Returns an immutable instance of [Url]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Url = Url(lang, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Url = apply { + if (validated) { + return@apply + } + + lang() + value() + 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 (lang.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2460,123 +4022,244 @@ private constructor( "Situation{id=$id, creationTime=$creationTime, activeWindows=$activeWindows, allAffects=$allAffects, consequenceMessage=$consequenceMessage, consequences=$consequences, description=$description, publicationWindows=$publicationWindows, reason=$reason, severity=$severity, summary=$summary, url=$url, additionalProperties=$additionalProperties}" } - @NoAutoDetect class Stop - @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), - @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), - @JsonProperty("routeIds") - @ExcludeMissing - private val routeIds: JsonField> = JsonMissing.of(), - @JsonProperty("staticRouteIds") - @ExcludeMissing - private val staticRouteIds: JsonField> = JsonMissing.of(), - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - private val wheelchairBoarding: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + 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, + 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") + /** + * @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(): 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(): List = staticRouteIds.getRequired("staticRouteIds") - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - + /** + * @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 = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) + 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 = additionalProperties - - private var validated: Boolean = false - - fun validate(): Stop = apply { - if (validated) { - return@apply - } - - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - code() - direction() - wheelchairBoarding() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Stop]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2614,80 +4297,155 @@ private constructor( 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: 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())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(routeId) + (routeIds ?: JsonField.of(mutableListOf())).also { + checkKnown("routeIds", it).add(routeId) } } fun staticRouteIds(staticRouteIds: 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())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(staticRouteId) + (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 } @@ -2711,6 +4469,25 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Stop]. + * + * 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(): Stop = Stop( checkRequired("id", id), @@ -2724,10 +4501,59 @@ private constructor( code, direction, wheelchairBoarding, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): Stop = 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 @@ -2746,95 +4572,154 @@ private constructor( "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}" } - @NoAutoDetect class StopTime - @JsonCreator private constructor( - @JsonProperty("arrivalTime") - @ExcludeMissing - private val arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("historicalOccupancy") - @ExcludeMissing - private val historicalOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, ) { - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") @ExcludeMissing stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) + distanceAlongTrip.getOptional("distanceAlongTrip") + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = Optional.ofNullable(stopId.getNullable("stopId")) - + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * @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") + + /** + * @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 [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 [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 [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 [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 [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 [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 = additionalProperties - - private var validated: Boolean = false - - fun validate(): StopTime = apply { - if (validated) { - return@apply - } - - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** Returns a mutable builder for constructing an instance of [StopTime]. */ @JvmStatic fun builder() = Builder() } @@ -2862,10 +4747,24 @@ private constructor( 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 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 } @@ -2873,6 +4772,13 @@ private constructor( 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 } @@ -2880,18 +4786,39 @@ private constructor( 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 } 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 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 { @@ -2913,6 +4840,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): StopTime = StopTime( arrivalTime, @@ -2921,10 +4853,49 @@ private constructor( historicalOccupancy, stopHeadsign, stopId, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + 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 (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2943,133 +4914,244 @@ private constructor( "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" } - @NoAutoDetect class Trip - @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), - @JsonProperty("blockId") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("directionId") - @ExcludeMissing - private val directionId: JsonField = JsonMissing.of(), - @JsonProperty("peakOffpeak") - @ExcludeMissing - private val peakOffpeak: JsonField = JsonMissing.of(), - @JsonProperty("routeShortName") - @ExcludeMissing - private val routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shapeId") - @ExcludeMissing - private val shapeId: JsonField = JsonMissing.of(), - @JsonProperty("timeZone") - @ExcludeMissing - private val timeZone: JsonField = JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - private val tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("tripShortName") - @ExcludeMissing - private val tripShortName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + 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") - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) - - fun directionId(): Optional = - Optional.ofNullable(directionId.getNullable("directionId")) - - fun peakOffpeak(): Optional = - Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - fun shapeId(): Optional = Optional.ofNullable(shapeId.getNullable("shapeId")) - - fun timeZone(): Optional = Optional.ofNullable(timeZone.getNullable("timeZone")) - - fun tripHeadsign(): Optional = - Optional.ofNullable(tripHeadsign.getNullable("tripHeadsign")) - - fun tripShortName(): Optional = - Optional.ofNullable(tripShortName.getNullable("tripShortName")) - + /** + * @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") + + /** + * 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 [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 [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 [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 [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 [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 [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 [shapeId]. + * + * Unlike [shapeId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId + /** + * 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 + /** + * 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 [tripShortName]. + * + * Unlike [tripShortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("tripShortName") @ExcludeMissing fun _tripShortName(): JsonField = tripShortName + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Trip = apply { - if (validated) { - return@apply - } - - id() - routeId() - serviceId() - blockId() - directionId() - peakOffpeak() - routeShortName() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [Trip]. + * + * The following fields are required: + * ```java + * .id() + * .routeId() + * .serviceId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3107,53 +5189,130 @@ private constructor( 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 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 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 blockId(blockId: String) = blockId(JsonField.of(blockId)) + /** + * 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 directionId(directionId: String) = directionId(JsonField.of(directionId)) + /** + * 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 peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) + /** + * 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 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 } fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) + /** + * 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 timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + /** + * 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 } 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 } fun tripShortName(tripShortName: String) = tripShortName(JsonField.of(tripShortName)) + /** + * 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 } @@ -3177,6 +5336,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * 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), @@ -3190,10 +5363,59 @@ private constructor( timeZone, tripHeadsign, tripShortName, - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): Trip = apply { + if (validated) { + return@apply + } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + 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 (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 equals(other: Any?): Boolean { if (this === other) { return true 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 2ca005b..2ac9738 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 @@ -6,69 +6,111 @@ 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 org.onebusaway.core.ExcludeMissing import org.onebusaway.core.JsonField import org.onebusaway.core.JsonMissing import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException -@NoAutoDetect class ResponseWrapper -@JsonCreator private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: 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(), + ) : this(code, currentTime, text, version, 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 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") + /** + * 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 + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ResponseWrapper = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - validated = true - } + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [ResponseWrapper]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -92,18 +134,43 @@ private constructor( 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 additionalProperties(additionalProperties: Map) = apply { @@ -125,16 +192,65 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ResponseWrapper]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ResponseWrapper = ResponseWrapper( checkRequired("code", code), checkRequired("currentTime", currentTime), checkRequired("text", text), checkRequired("version", version), - additionalProperties.toImmutable(), + additionalProperties.toMutableMap(), ) } + private var validated: Boolean = false + + fun validate(): ResponseWrapper = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + 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) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt deleted file mode 100644 index dd63e25..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListResponse.kt +++ /dev/null @@ -1,325 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class RouteIdsForAgencyListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): RouteIdsForAgencyListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RouteIdsForAgencyListResponse]. */ - 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(routeIdsForAgencyListResponse: RouteIdsForAgencyListResponse) = apply { - code = routeIdsForAgencyListResponse.code - currentTime = routeIdsForAgencyListResponse.currentTime - text = routeIdsForAgencyListResponse.text - version = routeIdsForAgencyListResponse.version - data = routeIdsForAgencyListResponse.data - additionalProperties = routeIdsForAgencyListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): RouteIdsForAgencyListResponse = - RouteIdsForAgencyListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded - list = data.list.map { it.toMutableList() } - references = data.references - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: String) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RouteIdsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RouteIdsForAgencyListResponse{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/RouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt deleted file mode 100644 index 0f81450..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveResponse.kt +++ /dev/null @@ -1,544 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class RouteRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): RouteRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RouteRetrieveResponse]. */ - 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(routeRetrieveResponse: RouteRetrieveResponse) = apply { - code = routeRetrieveResponse.code - currentTime = routeRetrieveResponse.currentTime - text = routeRetrieveResponse.text - version = routeRetrieveResponse.version - data = routeRetrieveResponse.data - additionalProperties = routeRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): RouteRetrieveResponse = - RouteRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("agencyId") - @ExcludeMissing - private val agencyId: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("longName") - @ExcludeMissing - private val longName: JsonField = JsonMissing.of(), - @JsonProperty("nullSafeShortName") - @ExcludeMissing - private val nullSafeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shortName") - @ExcludeMissing - private val shortName: JsonField = JsonMissing.of(), - @JsonProperty("textColor") - @ExcludeMissing - private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("url") - @ExcludeMissing - private val url: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun type(): Long = type.getRequired("type") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = - Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = - Optional.ofNullable(textColor.getNullable("textColor")) - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun _nullSafeShortName(): JsonField = nullSafeShortName - - @JsonProperty("shortName") - @ExcludeMissing - fun _shortName(): JsonField = shortName - - @JsonProperty("textColor") - @ExcludeMissing - fun _textColor(): JsonField = textColor - - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - id() - agencyId() - type() - color() - description() - longName() - nullSafeShortName() - shortName() - textColor() - url() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var agencyId: JsonField? = null - private var type: JsonField? = null - private var color: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var longName: JsonField = JsonMissing.of() - private var nullSafeShortName: JsonField = JsonMissing.of() - private var shortName: JsonField = JsonMissing.of() - private var textColor: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - id = entry.id - agencyId = entry.agencyId - type = entry.type - color = entry.color - description = entry.description - longName = entry.longName - nullSafeShortName = entry.nullSafeShortName - shortName = entry.shortName - textColor = entry.textColor - url = entry.url - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun color(color: String) = color(JsonField.of(color)) - - fun color(color: JsonField) = apply { this.color = color } - - fun description(description: String) = description(JsonField.of(description)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun longName(longName: String) = longName(JsonField.of(longName)) - - fun longName(longName: JsonField) = apply { this.longName = longName } - - fun nullSafeShortName(nullSafeShortName: String) = - nullSafeShortName(JsonField.of(nullSafeShortName)) - - fun nullSafeShortName(nullSafeShortName: JsonField) = apply { - this.nullSafeShortName = nullSafeShortName - } - - fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - - fun shortName(shortName: JsonField) = apply { this.shortName = shortName } - - fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - - fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - - fun url(url: String) = url(JsonField.of(url)) - - fun url(url: JsonField) = apply { this.url = url } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("id", id), - checkRequired("agencyId", agencyId), - checkRequired("type", type), - color, - description, - longName, - nullSafeShortName, - shortName, - textColor, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is RouteRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RouteRetrieveResponse{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/RoutesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt deleted file mode 100644 index cf24f91..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListResponse.kt +++ /dev/null @@ -1,580 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class RoutesForAgencyListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): RoutesForAgencyListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RoutesForAgencyListResponse]. */ - 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(routesForAgencyListResponse: RoutesForAgencyListResponse) = apply { - code = routesForAgencyListResponse.code - currentTime = routesForAgencyListResponse.currentTime - text = routesForAgencyListResponse.text - version = routesForAgencyListResponse.version - data = routesForAgencyListResponse.data - additionalProperties = routesForAgencyListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): RoutesForAgencyListResponse = - RoutesForAgencyListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded - list = data.list.map { it.toMutableList() } - references = data.references - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("agencyId") - @ExcludeMissing - private val agencyId: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("longName") - @ExcludeMissing - private val longName: JsonField = JsonMissing.of(), - @JsonProperty("nullSafeShortName") - @ExcludeMissing - private val nullSafeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shortName") - @ExcludeMissing - private val shortName: JsonField = JsonMissing.of(), - @JsonProperty("textColor") - @ExcludeMissing - private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("url") - @ExcludeMissing - private val url: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun type(): Long = type.getRequired("type") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = - Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = - Optional.ofNullable(textColor.getNullable("textColor")) - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun _nullSafeShortName(): JsonField = nullSafeShortName - - @JsonProperty("shortName") - @ExcludeMissing - fun _shortName(): JsonField = shortName - - @JsonProperty("textColor") - @ExcludeMissing - fun _textColor(): JsonField = textColor - - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - id() - agencyId() - type() - color() - description() - longName() - nullSafeShortName() - shortName() - textColor() - url() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var agencyId: JsonField? = null - private var type: JsonField? = null - private var color: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var longName: JsonField = JsonMissing.of() - private var nullSafeShortName: JsonField = JsonMissing.of() - private var shortName: JsonField = JsonMissing.of() - private var textColor: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - id = list.id - agencyId = list.agencyId - type = list.type - color = list.color - description = list.description - longName = list.longName - nullSafeShortName = list.nullSafeShortName - shortName = list.shortName - textColor = list.textColor - url = list.url - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun color(color: String) = color(JsonField.of(color)) - - fun color(color: JsonField) = apply { this.color = color } - - fun description(description: String) = description(JsonField.of(description)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun longName(longName: String) = longName(JsonField.of(longName)) - - fun longName(longName: JsonField) = apply { this.longName = longName } - - fun nullSafeShortName(nullSafeShortName: String) = - nullSafeShortName(JsonField.of(nullSafeShortName)) - - fun nullSafeShortName(nullSafeShortName: JsonField) = apply { - this.nullSafeShortName = nullSafeShortName - } - - fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - - fun shortName(shortName: JsonField) = apply { this.shortName = shortName } - - fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - - fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - - fun url(url: String) = url(JsonField.of(url)) - - fun url(url: JsonField) = apply { this.url = url } - - 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) - } - - fun build(): List = - List( - checkRequired("id", id), - checkRequired("agencyId", agencyId), - checkRequired("type", type), - color, - description, - longName, - nullSafeShortName, - shortName, - textColor, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoutesForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RoutesForAgencyListResponse{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/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt deleted file mode 100644 index 80b0395..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListResponse.kt +++ /dev/null @@ -1,597 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class RoutesForLocationListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): RoutesForLocationListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RoutesForLocationListResponse]. */ - 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(routesForLocationListResponse: RoutesForLocationListResponse) = apply { - code = routesForLocationListResponse.code - currentTime = routesForLocationListResponse.currentTime - text = routesForLocationListResponse.text - version = routesForLocationListResponse.version - data = routesForLocationListResponse.data - additionalProperties = routesForLocationListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): RoutesForLocationListResponse = - RoutesForLocationListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("outOfRange") - @ExcludeMissing - fun _outOfRange(): JsonField = outOfRange - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 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 - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("outOfRange", outOfRange), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("agencyId") - @ExcludeMissing - private val agencyId: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("longName") - @ExcludeMissing - private val longName: JsonField = JsonMissing.of(), - @JsonProperty("nullSafeShortName") - @ExcludeMissing - private val nullSafeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shortName") - @ExcludeMissing - private val shortName: JsonField = JsonMissing.of(), - @JsonProperty("textColor") - @ExcludeMissing - private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("url") - @ExcludeMissing - private val url: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun type(): Long = type.getRequired("type") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = - Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = - Optional.ofNullable(textColor.getNullable("textColor")) - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun _nullSafeShortName(): JsonField = nullSafeShortName - - @JsonProperty("shortName") - @ExcludeMissing - fun _shortName(): JsonField = shortName - - @JsonProperty("textColor") - @ExcludeMissing - fun _textColor(): JsonField = textColor - - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - id() - agencyId() - type() - color() - description() - longName() - nullSafeShortName() - shortName() - textColor() - url() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var agencyId: JsonField? = null - private var type: JsonField? = null - private var color: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var longName: JsonField = JsonMissing.of() - private var nullSafeShortName: JsonField = JsonMissing.of() - private var shortName: JsonField = JsonMissing.of() - private var textColor: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - id = list.id - agencyId = list.agencyId - type = list.type - color = list.color - description = list.description - longName = list.longName - nullSafeShortName = list.nullSafeShortName - shortName = list.shortName - textColor = list.textColor - url = list.url - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun color(color: String) = color(JsonField.of(color)) - - fun color(color: JsonField) = apply { this.color = color } - - fun description(description: String) = description(JsonField.of(description)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun longName(longName: String) = longName(JsonField.of(longName)) - - fun longName(longName: JsonField) = apply { this.longName = longName } - - fun nullSafeShortName(nullSafeShortName: String) = - nullSafeShortName(JsonField.of(nullSafeShortName)) - - fun nullSafeShortName(nullSafeShortName: JsonField) = apply { - this.nullSafeShortName = nullSafeShortName - } - - fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - - fun shortName(shortName: JsonField) = apply { this.shortName = shortName } - - fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - - fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - - fun url(url: String) = url(JsonField.of(url)) - - fun url(url: JsonField) = apply { this.url = url } - - 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) - } - - fun build(): List = - List( - checkRequired("id", id), - checkRequired("agencyId", agencyId), - checkRequired("type", type), - color, - description, - longName, - nullSafeShortName, - shortName, - textColor, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoutesForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RoutesForLocationListResponse{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/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt deleted file mode 100644 index f686c9f..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveResponse.kt +++ /dev/null @@ -1,1727 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class ScheduleForRouteRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): ScheduleForRouteRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScheduleForRouteRetrieveResponse]. */ - 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(scheduleForRouteRetrieveResponse: ScheduleForRouteRetrieveResponse) = - apply { - code = scheduleForRouteRetrieveResponse.code - currentTime = scheduleForRouteRetrieveResponse.currentTime - text = scheduleForRouteRetrieveResponse.text - version = scheduleForRouteRetrieveResponse.version - data = scheduleForRouteRetrieveResponse.data - additionalProperties = - scheduleForRouteRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): ScheduleForRouteRetrieveResponse = - ScheduleForRouteRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var entry: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - entry = data.entry - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun entry(entry: Entry) = entry(JsonField.of(entry)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - 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) - } - - fun build(): Data = - Data(checkRequired("entry", entry), additionalProperties.toImmutable()) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDate") - @ExcludeMissing - private val scheduleDate: JsonField = JsonMissing.of(), - @JsonProperty("serviceIds") - @ExcludeMissing - private val serviceIds: JsonField> = JsonMissing.of(), - @JsonProperty("stops") - @ExcludeMissing - private val stops: JsonField> = JsonMissing.of(), - @JsonProperty("stopTripGroupings") - @ExcludeMissing - private val stopTripGroupings: JsonField> = JsonMissing.of(), - @JsonProperty("trips") - @ExcludeMissing - private val trips: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun routeId(): String = routeId.getRequired("routeId") - - fun scheduleDate(): Long = scheduleDate.getRequired("scheduleDate") - - fun serviceIds(): List = serviceIds.getRequired("serviceIds") - - fun stops(): List = stops.getRequired("stops") - - fun stopTripGroupings(): List = - stopTripGroupings.getRequired("stopTripGroupings") - - fun trips(): List = trips.getRequired("trips") - - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - - @JsonProperty("scheduleDate") - @ExcludeMissing - fun _scheduleDate(): JsonField = scheduleDate - - @JsonProperty("serviceIds") - @ExcludeMissing - fun _serviceIds(): JsonField> = serviceIds - - @JsonProperty("stops") @ExcludeMissing fun _stops(): JsonField> = stops - - @JsonProperty("stopTripGroupings") - @ExcludeMissing - fun _stopTripGroupings(): JsonField> = stopTripGroupings - - @JsonProperty("trips") @ExcludeMissing fun _trips(): JsonField> = trips - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - routeId() - scheduleDate() - serviceIds() - stops().forEach { it.validate() } - stopTripGroupings().forEach { it.validate() } - trips().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal 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 - internal fun from(entry: Entry) = apply { - 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() - } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun scheduleDate(scheduleDate: Long) = scheduleDate(JsonField.of(scheduleDate)) - - fun scheduleDate(scheduleDate: JsonField) = apply { - this.scheduleDate = scheduleDate - } - - fun serviceIds(serviceIds: List) = serviceIds(JsonField.of(serviceIds)) - - fun serviceIds(serviceIds: JsonField>) = apply { - this.serviceIds = serviceIds.map { it.toMutableList() } - } - - fun addServiceId(serviceId: String) = apply { - serviceIds = - (serviceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(serviceId) - } - } - - fun stops(stops: List) = stops(JsonField.of(stops)) - - fun stops(stops: JsonField>) = apply { - this.stops = stops.map { it.toMutableList() } - } - - fun addStop(stop: Stop) = apply { - stops = - (stops ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stop) - } - } - - fun stopTripGroupings(stopTripGroupings: List) = - stopTripGroupings(JsonField.of(stopTripGroupings)) - - fun stopTripGroupings(stopTripGroupings: JsonField>) = - apply { - this.stopTripGroupings = stopTripGroupings.map { it.toMutableList() } - } - - fun addStopTripGrouping(stopTripGrouping: StopTripGrouping) = apply { - stopTripGroupings = - (stopTripGroupings ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopTripGrouping) - } - } - - fun trips(trips: List) = trips(JsonField.of(trips)) - - fun trips(trips: JsonField>) = apply { - this.trips = trips.map { it.toMutableList() } - } - - fun addTrip(trip: Trip) = apply { - trips = - (trips ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(trip) - } - } - - 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) - } - - fun build(): Entry = - Entry( - 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.toImmutable(), - ) - } - - @NoAutoDetect - class Stop - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), - @JsonProperty("routeIds") - @ExcludeMissing - private val routeIds: JsonField> = JsonMissing.of(), - @JsonProperty("staticRouteIds") - @ExcludeMissing - private val staticRouteIds: JsonField> = JsonMissing.of(), - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - private val wheelchairBoarding: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Long = locationType.getRequired("locationType") - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - - @JsonProperty("routeIds") - @ExcludeMissing - fun _routeIds(): JsonField> = routeIds - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun _staticRouteIds(): JsonField> = staticRouteIds - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("direction") - @ExcludeMissing - fun _direction(): JsonField = direction - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding(): JsonField = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Stop = apply { - if (validated) { - return@apply - } - - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - code() - direction() - wheelchairBoarding() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Stop]. */ - 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(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() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds.map { it.toMutableList() } - } - - fun addRouteId(routeId: String) = apply { - routeIds = - (routeIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(routeId) - } - } - - fun staticRouteIds(staticRouteIds: List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds.map { it.toMutableList() } - } - - fun addStaticRouteId(staticRouteId: String) = apply { - staticRouteIds = - (staticRouteIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(staticRouteId) - } - } - - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { - this.direction = direction - } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - 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) - } - - 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, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - 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}" - } - - @NoAutoDetect - class StopTripGrouping - @JsonCreator - private constructor( - @JsonProperty("directionId") - @ExcludeMissing - private val directionId: JsonField = JsonMissing.of(), - @JsonProperty("stopIds") - @ExcludeMissing - private val stopIds: JsonField> = JsonMissing.of(), - @JsonProperty("tripHeadsigns") - @ExcludeMissing - private val tripHeadsigns: JsonField> = JsonMissing.of(), - @JsonProperty("tripIds") - @ExcludeMissing - private val tripIds: JsonField> = JsonMissing.of(), - @JsonProperty("tripsWithStopTimes") - @ExcludeMissing - private val tripsWithStopTimes: JsonField> = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun directionId(): String = directionId.getRequired("directionId") - - fun stopIds(): List = stopIds.getRequired("stopIds") - - fun tripHeadsigns(): List = tripHeadsigns.getRequired("tripHeadsigns") - - fun tripIds(): List = tripIds.getRequired("tripIds") - - fun tripsWithStopTimes(): Optional> = - Optional.ofNullable(tripsWithStopTimes.getNullable("tripsWithStopTimes")) - - @JsonProperty("directionId") - @ExcludeMissing - fun _directionId(): JsonField = directionId - - @JsonProperty("stopIds") - @ExcludeMissing - fun _stopIds(): JsonField> = stopIds - - @JsonProperty("tripHeadsigns") - @ExcludeMissing - fun _tripHeadsigns(): JsonField> = tripHeadsigns - - @JsonProperty("tripIds") - @ExcludeMissing - fun _tripIds(): JsonField> = tripIds - - @JsonProperty("tripsWithStopTimes") - @ExcludeMissing - fun _tripsWithStopTimes(): JsonField> = tripsWithStopTimes - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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() - - @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() - } - - fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - - fun directionId(directionId: JsonField) = apply { - this.directionId = directionId - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - - fun stopIds(stopIds: JsonField>) = apply { - this.stopIds = stopIds.map { it.toMutableList() } - } - - fun addStopId(stopId: String) = apply { - stopIds = - (stopIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopId) - } - } - - fun tripHeadsigns(tripHeadsigns: List) = - tripHeadsigns(JsonField.of(tripHeadsigns)) - - fun tripHeadsigns(tripHeadsigns: JsonField>) = apply { - this.tripHeadsigns = tripHeadsigns.map { it.toMutableList() } - } - - fun addTripHeadsign(tripHeadsign: String) = apply { - tripHeadsigns = - (tripHeadsigns ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tripHeadsign) - } - } - - fun tripIds(tripIds: List) = tripIds(JsonField.of(tripIds)) - - fun tripIds(tripIds: JsonField>) = apply { - this.tripIds = tripIds.map { it.toMutableList() } - } - - fun addTripId(tripId: String) = apply { - tripIds = - (tripIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tripId) - } - } - - fun tripsWithStopTimes(tripsWithStopTimes: List) = - tripsWithStopTimes(JsonField.of(tripsWithStopTimes)) - - fun tripsWithStopTimes(tripsWithStopTimes: JsonField>) = - apply { - this.tripsWithStopTimes = tripsWithStopTimes.map { it.toMutableList() } - } - - fun addTripsWithStopTime(tripsWithStopTime: TripsWithStopTime) = apply { - tripsWithStopTimes = - (tripsWithStopTimes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tripsWithStopTime) - } - } - - 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) - } - - 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.toImmutable(), - ) - } - - @NoAutoDetect - class TripsWithStopTime - @JsonCreator - private constructor( - @JsonProperty("stopTimes") - @ExcludeMissing - private val stopTimes: JsonField> = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("stopTimes") - @ExcludeMissing - fun _stopTimes(): JsonField> = stopTimes - - @JsonProperty("tripId") - @ExcludeMissing - fun _tripId(): JsonField = tripId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TripsWithStopTime = apply { - if (validated) { - return@apply - } - - stopTimes().forEach { it.validate() } - tripId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TripsWithStopTime]. */ - class Builder internal constructor() { - - private var stopTimes: JsonField>? = null - private var tripId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tripsWithStopTime: TripsWithStopTime) = apply { - stopTimes = tripsWithStopTime.stopTimes.map { it.toMutableList() } - tripId = tripsWithStopTime.tripId - additionalProperties = - tripsWithStopTime.additionalProperties.toMutableMap() - } - - fun stopTimes(stopTimes: List) = - stopTimes(JsonField.of(stopTimes)) - - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes.map { it.toMutableList() } - } - - fun addStopTime(stopTime: StopTime) = apply { - stopTimes = - (stopTimes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopTime) - } - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - 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) - } - - fun build(): TripsWithStopTime = - TripsWithStopTime( - checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, - checkRequired("tripId", tripId), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class StopTime - @JsonCreator - private constructor( - @JsonProperty("arrivalEnabled") - @ExcludeMissing - private val arrivalEnabled: JsonField = JsonMissing.of(), - @JsonProperty("arrivalTime") - @ExcludeMissing - private val arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureEnabled") - @ExcludeMissing - private val departureEnabled: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") - - fun departureEnabled(): Boolean = - departureEnabled.getRequired("departureEnabled") - - fun departureTime(): Long = departureTime.getRequired("departureTime") - - fun stopId(): String = stopId.getRequired("stopId") - - fun tripId(): String = tripId.getRequired("tripId") - - fun serviceId(): Optional = - Optional.ofNullable(serviceId.getNullable("serviceId")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun _arrivalEnabled(): JsonField = arrivalEnabled - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime(): JsonField = arrivalTime - - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled(): JsonField = departureEnabled - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime(): JsonField = departureTime - - @JsonProperty("stopId") - @ExcludeMissing - fun _stopId(): JsonField = stopId - - @JsonProperty("tripId") - @ExcludeMissing - fun _tripId(): JsonField = tripId - - @JsonProperty("serviceId") - @ExcludeMissing - fun _serviceId(): JsonField = serviceId - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign(): JsonField = stopHeadsign - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): StopTime = apply { - if (validated) { - return@apply - } - - arrivalEnabled() - arrivalTime() - departureEnabled() - departureTime() - stopId() - tripId() - serviceId() - stopHeadsign() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun arrivalEnabled(arrivalEnabled: JsonField) = apply { - this.arrivalEnabled = arrivalEnabled - } - - fun arrivalTime(arrivalTime: Long) = - arrivalTime(JsonField.of(arrivalTime)) - - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureEnabled(departureEnabled: Boolean) = - departureEnabled(JsonField.of(departureEnabled)) - - fun departureEnabled(departureEnabled: JsonField) = apply { - this.departureEnabled = departureEnabled - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - 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) - } - - 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.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, stopId, tripId, serviceId, stopHeadsign, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is TripsWithStopTime && stopTimes == other.stopTimes && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(stopTimes, tripId, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is StopTripGrouping && directionId == other.directionId && stopIds == other.stopIds && tripHeadsigns == other.tripHeadsigns && tripIds == other.tripIds && tripsWithStopTimes == other.tripsWithStopTimes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(directionId, stopIds, tripHeadsigns, tripIds, tripsWithStopTimes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Trip - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), - @JsonProperty("blockId") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("directionId") - @ExcludeMissing - private val directionId: JsonField = JsonMissing.of(), - @JsonProperty("peakOffpeak") - @ExcludeMissing - private val peakOffpeak: JsonField = JsonMissing.of(), - @JsonProperty("routeShortName") - @ExcludeMissing - private val routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shapeId") - @ExcludeMissing - private val shapeId: JsonField = JsonMissing.of(), - @JsonProperty("timeZone") - @ExcludeMissing - private val timeZone: JsonField = JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - private val tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("tripShortName") - @ExcludeMissing - private val tripShortName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun routeId(): String = routeId.getRequired("routeId") - - fun serviceId(): String = serviceId.getRequired("serviceId") - - fun blockId(): Optional = - Optional.ofNullable(blockId.getNullable("blockId")) - - fun directionId(): Optional = - Optional.ofNullable(directionId.getNullable("directionId")) - - fun peakOffpeak(): Optional = - Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - fun shapeId(): Optional = - Optional.ofNullable(shapeId.getNullable("shapeId")) - - fun timeZone(): Optional = - Optional.ofNullable(timeZone.getNullable("timeZone")) - - fun tripHeadsign(): Optional = - Optional.ofNullable(tripHeadsign.getNullable("tripHeadsign")) - - fun tripShortName(): Optional = - Optional.ofNullable(tripShortName.getNullable("tripShortName")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - - @JsonProperty("serviceId") - @ExcludeMissing - fun _serviceId(): JsonField = serviceId - - @JsonProperty("blockId") @ExcludeMissing fun _blockId(): JsonField = blockId - - @JsonProperty("directionId") - @ExcludeMissing - fun _directionId(): JsonField = directionId - - @JsonProperty("peakOffpeak") - @ExcludeMissing - fun _peakOffpeak(): JsonField = peakOffpeak - - @JsonProperty("routeShortName") - @ExcludeMissing - fun _routeShortName(): JsonField = routeShortName - - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId - - @JsonProperty("timeZone") - @ExcludeMissing - fun _timeZone(): JsonField = timeZone - - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun _tripHeadsign(): JsonField = tripHeadsign - - @JsonProperty("tripShortName") - @ExcludeMissing - fun _tripShortName(): JsonField = tripShortName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Trip = apply { - if (validated) { - return@apply - } - - id() - routeId() - serviceId() - blockId() - directionId() - peakOffpeak() - routeShortName() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Trip]. */ - class Builder internal constructor() { - - 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() - - @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 id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - - fun directionId(directionId: JsonField) = apply { - this.directionId = directionId - } - - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) - - fun peakOffpeak(peakOffpeak: JsonField) = apply { - this.peakOffpeak = peakOffpeak - } - - fun routeShortName(routeShortName: String) = - routeShortName(JsonField.of(routeShortName)) - - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } - - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) - - fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun tripHeadsign(tripHeadsign: String) = - tripHeadsign(JsonField.of(tripHeadsign)) - - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } - - fun tripShortName(tripShortName: String) = - tripShortName(JsonField.of(tripShortName)) - - fun tripShortName(tripShortName: JsonField) = apply { - this.tripShortName = tripShortName - } - - 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) - } - - fun build(): Trip = - Trip( - checkRequired("id", id), - checkRequired("routeId", routeId), - checkRequired("serviceId", serviceId), - blockId, - directionId, - peakOffpeak, - routeShortName, - shapeId, - timeZone, - tripHeadsign, - tripShortName, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Trip && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } - /* spotless:on */ - - 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}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && routeId == other.routeId && scheduleDate == other.scheduleDate && serviceIds == other.serviceIds && stops == other.stops && stopTripGroupings == other.stopTripGroupings && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(routeId, scheduleDate, serviceIds, stops, stopTripGroupings, trips, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stops=$stops, stopTripGroupings=$stopTripGroupings, trips=$trips, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{entry=$entry, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleForRouteRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScheduleForRouteRetrieveResponse{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/ScheduleForStopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt deleted file mode 100644 index 386941c..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveResponse.kt +++ /dev/null @@ -1,1214 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class ScheduleForStopRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): ScheduleForStopRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScheduleForStopRetrieveResponse]. */ - 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(scheduleForStopRetrieveResponse: ScheduleForStopRetrieveResponse) = - apply { - code = scheduleForStopRetrieveResponse.code - currentTime = scheduleForStopRetrieveResponse.currentTime - text = scheduleForStopRetrieveResponse.text - version = scheduleForStopRetrieveResponse.version - data = scheduleForStopRetrieveResponse.data - additionalProperties = - scheduleForStopRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): ScheduleForStopRetrieveResponse = - ScheduleForStopRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("date") - @ExcludeMissing - private val date: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonProperty("stopRouteSchedules") - @ExcludeMissing - private val stopRouteSchedules: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun date(): Long = date.getRequired("date") - - fun stopId(): String = stopId.getRequired("stopId") - - fun stopRouteSchedules(): List = - stopRouteSchedules.getRequired("stopRouteSchedules") - - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date - - @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId - - @JsonProperty("stopRouteSchedules") - @ExcludeMissing - fun _stopRouteSchedules(): JsonField> = stopRouteSchedules - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - date() - stopId() - stopRouteSchedules().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var date: JsonField? = null - private var stopId: JsonField? = null - private var stopRouteSchedules: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - date = entry.date - stopId = entry.stopId - stopRouteSchedules = entry.stopRouteSchedules.map { it.toMutableList() } - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun date(date: Long) = date(JsonField.of(date)) - - fun date(date: JsonField) = apply { this.date = date } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - fun stopId(stopId: JsonField) = apply { this.stopId = stopId } - - fun stopRouteSchedules(stopRouteSchedules: List) = - stopRouteSchedules(JsonField.of(stopRouteSchedules)) - - fun stopRouteSchedules(stopRouteSchedules: JsonField>) = - apply { - this.stopRouteSchedules = stopRouteSchedules.map { it.toMutableList() } - } - - fun addStopRouteSchedule(stopRouteSchedule: StopRouteSchedule) = apply { - stopRouteSchedules = - (stopRouteSchedules ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopRouteSchedule) - } - } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("date", date), - checkRequired("stopId", stopId), - checkRequired("stopRouteSchedules", stopRouteSchedules).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class StopRouteSchedule - @JsonCreator - private constructor( - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("stopRouteDirectionSchedules") - @ExcludeMissing - private val stopRouteDirectionSchedules: - JsonField> = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun routeId(): String = routeId.getRequired("routeId") - - fun stopRouteDirectionSchedules(): List = - stopRouteDirectionSchedules.getRequired("stopRouteDirectionSchedules") - - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - - @JsonProperty("stopRouteDirectionSchedules") - @ExcludeMissing - fun _stopRouteDirectionSchedules(): JsonField> = - stopRouteDirectionSchedules - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): StopRouteSchedule = apply { - if (validated) { - return@apply - } - - routeId() - stopRouteDirectionSchedules().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopRouteSchedule]. */ - class Builder internal constructor() { - - private var routeId: JsonField? = null - private var stopRouteDirectionSchedules: - JsonField>? = - null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stopRouteSchedule: StopRouteSchedule) = apply { - routeId = stopRouteSchedule.routeId - stopRouteDirectionSchedules = - stopRouteSchedule.stopRouteDirectionSchedules.map { it.toMutableList() } - additionalProperties = stopRouteSchedule.additionalProperties.toMutableMap() - } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun stopRouteDirectionSchedules( - stopRouteDirectionSchedules: List - ) = stopRouteDirectionSchedules(JsonField.of(stopRouteDirectionSchedules)) - - fun stopRouteDirectionSchedules( - stopRouteDirectionSchedules: JsonField> - ) = apply { - this.stopRouteDirectionSchedules = - stopRouteDirectionSchedules.map { it.toMutableList() } - } - - fun addStopRouteDirectionSchedule( - stopRouteDirectionSchedule: StopRouteDirectionSchedule - ) = apply { - stopRouteDirectionSchedules = - (stopRouteDirectionSchedules ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopRouteDirectionSchedule) - } - } - - 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) - } - - fun build(): StopRouteSchedule = - StopRouteSchedule( - checkRequired("routeId", routeId), - checkRequired( - "stopRouteDirectionSchedules", - stopRouteDirectionSchedules - ) - .map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class StopRouteDirectionSchedule - @JsonCreator - private constructor( - @JsonProperty("scheduleStopTimes") - @ExcludeMissing - private val scheduleStopTimes: JsonField> = - JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - private val tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("scheduleFrequencies") - @ExcludeMissing - private val scheduleFrequencies: JsonField> = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun scheduleStopTimes(): List = - scheduleStopTimes.getRequired("scheduleStopTimes") - - fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") - - fun scheduleFrequencies(): Optional> = - Optional.ofNullable(scheduleFrequencies.getNullable("scheduleFrequencies")) - - @JsonProperty("scheduleStopTimes") - @ExcludeMissing - fun _scheduleStopTimes(): JsonField> = scheduleStopTimes - - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun _tripHeadsign(): JsonField = tripHeadsign - - @JsonProperty("scheduleFrequencies") - @ExcludeMissing - fun _scheduleFrequencies(): JsonField> = - scheduleFrequencies - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): StopRouteDirectionSchedule = apply { - if (validated) { - return@apply - } - - scheduleStopTimes().forEach { it.validate() } - tripHeadsign() - scheduleFrequencies().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopRouteDirectionSchedule]. */ - class Builder internal constructor() { - - private var scheduleStopTimes: JsonField>? = - null - private var tripHeadsign: JsonField? = null - private var scheduleFrequencies: - JsonField>? = - null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopRouteDirectionSchedule: StopRouteDirectionSchedule) = - apply { - scheduleStopTimes = - stopRouteDirectionSchedule.scheduleStopTimes.map { - it.toMutableList() - } - tripHeadsign = stopRouteDirectionSchedule.tripHeadsign - scheduleFrequencies = - stopRouteDirectionSchedule.scheduleFrequencies.map { - it.toMutableList() - } - additionalProperties = - stopRouteDirectionSchedule.additionalProperties.toMutableMap() - } - - fun scheduleStopTimes(scheduleStopTimes: List) = - scheduleStopTimes(JsonField.of(scheduleStopTimes)) - - fun scheduleStopTimes( - scheduleStopTimes: JsonField> - ) = apply { - this.scheduleStopTimes = scheduleStopTimes.map { it.toMutableList() } - } - - fun addScheduleStopTime(scheduleStopTime: ScheduleStopTime) = apply { - scheduleStopTimes = - (scheduleStopTimes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(scheduleStopTime) - } - } - - fun tripHeadsign(tripHeadsign: String) = - tripHeadsign(JsonField.of(tripHeadsign)) - - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } - - fun scheduleFrequencies(scheduleFrequencies: List) = - scheduleFrequencies(JsonField.of(scheduleFrequencies)) - - fun scheduleFrequencies( - scheduleFrequencies: JsonField> - ) = apply { - this.scheduleFrequencies = - scheduleFrequencies.map { it.toMutableList() } - } - - fun addScheduleFrequency(scheduleFrequency: ScheduleFrequency) = apply { - scheduleFrequencies = - (scheduleFrequencies ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(scheduleFrequency) - } - } - - 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) - } - - fun build(): StopRouteDirectionSchedule = - StopRouteDirectionSchedule( - checkRequired("scheduleStopTimes", scheduleStopTimes).map { - it.toImmutable() - }, - checkRequired("tripHeadsign", tripHeadsign), - (scheduleFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class ScheduleStopTime - @JsonCreator - private constructor( - @JsonProperty("arrivalEnabled") - @ExcludeMissing - private val arrivalEnabled: JsonField = JsonMissing.of(), - @JsonProperty("arrivalTime") - @ExcludeMissing - private val arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureEnabled") - @ExcludeMissing - private val departureEnabled: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") - - fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") - - fun departureEnabled(): Boolean = - departureEnabled.getRequired("departureEnabled") - - fun departureTime(): Long = departureTime.getRequired("departureTime") - - fun serviceId(): String = serviceId.getRequired("serviceId") - - fun tripId(): String = tripId.getRequired("tripId") - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - @JsonProperty("arrivalEnabled") - @ExcludeMissing - fun _arrivalEnabled(): JsonField = arrivalEnabled - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime(): JsonField = arrivalTime - - @JsonProperty("departureEnabled") - @ExcludeMissing - fun _departureEnabled(): JsonField = departureEnabled - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime(): JsonField = departureTime - - @JsonProperty("serviceId") - @ExcludeMissing - fun _serviceId(): JsonField = serviceId - - @JsonProperty("tripId") - @ExcludeMissing - fun _tripId(): JsonField = tripId - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign(): JsonField = stopHeadsign - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScheduleStopTime = apply { - if (validated) { - return@apply - } - - arrivalEnabled() - arrivalTime() - departureEnabled() - departureTime() - serviceId() - tripId() - stopHeadsign() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScheduleStopTime]. */ - 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 serviceId: JsonField? = null - private var tripId: JsonField? = null - private var stopHeadsign: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(scheduleStopTime: ScheduleStopTime) = apply { - arrivalEnabled = scheduleStopTime.arrivalEnabled - arrivalTime = scheduleStopTime.arrivalTime - departureEnabled = scheduleStopTime.departureEnabled - departureTime = scheduleStopTime.departureTime - serviceId = scheduleStopTime.serviceId - tripId = scheduleStopTime.tripId - stopHeadsign = scheduleStopTime.stopHeadsign - additionalProperties = - scheduleStopTime.additionalProperties.toMutableMap() - } - - fun arrivalEnabled(arrivalEnabled: Boolean) = - arrivalEnabled(JsonField.of(arrivalEnabled)) - - fun arrivalEnabled(arrivalEnabled: JsonField) = apply { - this.arrivalEnabled = arrivalEnabled - } - - fun arrivalTime(arrivalTime: Long) = - arrivalTime(JsonField.of(arrivalTime)) - - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureEnabled(departureEnabled: Boolean) = - departureEnabled(JsonField.of(departureEnabled)) - - fun departureEnabled(departureEnabled: JsonField) = apply { - this.departureEnabled = departureEnabled - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - 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) - } - - fun build(): ScheduleStopTime = - ScheduleStopTime( - checkRequired("arrivalEnabled", arrivalEnabled), - checkRequired("arrivalTime", arrivalTime), - checkRequired("departureEnabled", departureEnabled), - checkRequired("departureTime", departureTime), - checkRequired("serviceId", serviceId), - checkRequired("tripId", tripId), - stopHeadsign, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleStopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && serviceId == other.serviceId && tripId == other.tripId && stopHeadsign == other.stopHeadsign && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, tripId, stopHeadsign, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScheduleStopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, tripId=$tripId, stopHeadsign=$stopHeadsign, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ScheduleFrequency - @JsonCreator - private constructor( - @JsonProperty("endTime") - @ExcludeMissing - private val endTime: JsonField = JsonMissing.of(), - @JsonProperty("headway") - @ExcludeMissing - private val headway: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), - @JsonProperty("startTime") - @ExcludeMissing - private val startTime: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - fun endTime(): Long = endTime.getRequired("endTime") - - fun headway(): Long = headway.getRequired("headway") - - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - fun serviceId(): String = serviceId.getRequired("serviceId") - - fun startTime(): Long = startTime.getRequired("startTime") - - fun tripId(): String = tripId.getRequired("tripId") - - @JsonProperty("endTime") - @ExcludeMissing - fun _endTime(): JsonField = endTime - - @JsonProperty("headway") - @ExcludeMissing - fun _headway(): JsonField = headway - - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - @JsonProperty("serviceId") - @ExcludeMissing - fun _serviceId(): JsonField = serviceId - - @JsonProperty("startTime") - @ExcludeMissing - fun _startTime(): JsonField = startTime - - @JsonProperty("tripId") - @ExcludeMissing - fun _tripId(): JsonField = tripId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScheduleFrequency = apply { - if (validated) { - return@apply - } - - endTime() - headway() - serviceDate() - serviceId() - startTime() - tripId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScheduleFrequency]. */ - class Builder internal constructor() { - - private var endTime: JsonField? = null - private var headway: JsonField? = null - private var serviceDate: JsonField? = null - private var serviceId: JsonField? = null - private var startTime: JsonField? = null - private var tripId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(scheduleFrequency: ScheduleFrequency) = apply { - endTime = scheduleFrequency.endTime - headway = scheduleFrequency.headway - serviceDate = scheduleFrequency.serviceDate - serviceId = scheduleFrequency.serviceId - startTime = scheduleFrequency.startTime - tripId = scheduleFrequency.tripId - additionalProperties = - scheduleFrequency.additionalProperties.toMutableMap() - } - - fun endTime(endTime: Long) = endTime(JsonField.of(endTime)) - - fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - - fun headway(headway: Long) = headway(JsonField.of(headway)) - - fun headway(headway: JsonField) = apply { this.headway = headway } - - fun serviceDate(serviceDate: Long) = - serviceDate(JsonField.of(serviceDate)) - - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - fun serviceId(serviceId: JsonField) = apply { - this.serviceId = serviceId - } - - fun startTime(startTime: Long) = startTime(JsonField.of(startTime)) - - fun startTime(startTime: JsonField) = apply { - this.startTime = startTime - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - 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) - } - - fun build(): ScheduleFrequency = - ScheduleFrequency( - checkRequired("endTime", endTime), - checkRequired("headway", headway), - checkRequired("serviceDate", serviceDate), - checkRequired("serviceId", serviceId), - checkRequired("startTime", startTime), - checkRequired("tripId", tripId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScheduleFrequency && endTime == other.endTime && headway == other.headway && serviceDate == other.serviceDate && serviceId == other.serviceId && startTime == other.startTime && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endTime, headway, serviceDate, serviceId, startTime, tripId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScheduleFrequency{endTime=$endTime, headway=$headway, serviceDate=$serviceDate, serviceId=$serviceId, startTime=$startTime, tripId=$tripId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopRouteDirectionSchedule && scheduleStopTimes == other.scheduleStopTimes && tripHeadsign == other.tripHeadsign && scheduleFrequencies == other.scheduleFrequencies && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(scheduleStopTimes, tripHeadsign, scheduleFrequencies, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopRouteDirectionSchedule{scheduleStopTimes=$scheduleStopTimes, tripHeadsign=$tripHeadsign, scheduleFrequencies=$scheduleFrequencies, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopRouteSchedule && routeId == other.routeId && stopRouteDirectionSchedules == other.stopRouteDirectionSchedules && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(routeId, stopRouteDirectionSchedules, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopRouteSchedule{routeId=$routeId, stopRouteDirectionSchedules=$stopRouteDirectionSchedules, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && date == other.date && stopId == other.stopId && stopRouteSchedules == other.stopRouteSchedules && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(date, stopId, stopRouteSchedules, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{date=$date, stopId=$stopId, stopRouteSchedules=$stopRouteSchedules, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is ScheduleForStopRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScheduleForStopRetrieveResponse{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/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt deleted file mode 100644 index 0db7b57..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListResponse.kt +++ /dev/null @@ -1,597 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class SearchForRouteListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): SearchForRouteListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SearchForRouteListResponse]. */ - 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 = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(searchForRouteListResponse: SearchForRouteListResponse) = apply { - code = searchForRouteListResponse.code - currentTime = searchForRouteListResponse.currentTime - text = searchForRouteListResponse.text - version = searchForRouteListResponse.version - data = searchForRouteListResponse.data - additionalProperties = searchForRouteListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): SearchForRouteListResponse = - SearchForRouteListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - data, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("outOfRange") - @ExcludeMissing - fun _outOfRange(): JsonField = outOfRange - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 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 - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("outOfRange", outOfRange), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("agencyId") - @ExcludeMissing - private val agencyId: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("longName") - @ExcludeMissing - private val longName: JsonField = JsonMissing.of(), - @JsonProperty("nullSafeShortName") - @ExcludeMissing - private val nullSafeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shortName") - @ExcludeMissing - private val shortName: JsonField = JsonMissing.of(), - @JsonProperty("textColor") - @ExcludeMissing - private val textColor: JsonField = JsonMissing.of(), - @JsonProperty("url") - @ExcludeMissing - private val url: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun agencyId(): String = agencyId.getRequired("agencyId") - - fun type(): Long = type.getRequired("type") - - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun longName(): Optional = Optional.ofNullable(longName.getNullable("longName")) - - fun nullSafeShortName(): Optional = - Optional.ofNullable(nullSafeShortName.getNullable("nullSafeShortName")) - - fun shortName(): Optional = - Optional.ofNullable(shortName.getNullable("shortName")) - - fun textColor(): Optional = - Optional.ofNullable(textColor.getNullable("textColor")) - - fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName - - @JsonProperty("nullSafeShortName") - @ExcludeMissing - fun _nullSafeShortName(): JsonField = nullSafeShortName - - @JsonProperty("shortName") - @ExcludeMissing - fun _shortName(): JsonField = shortName - - @JsonProperty("textColor") - @ExcludeMissing - fun _textColor(): JsonField = textColor - - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - id() - agencyId() - type() - color() - description() - longName() - nullSafeShortName() - shortName() - textColor() - url() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var agencyId: JsonField? = null - private var type: JsonField? = null - private var color: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var longName: JsonField = JsonMissing.of() - private var nullSafeShortName: JsonField = JsonMissing.of() - private var shortName: JsonField = JsonMissing.of() - private var textColor: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - id = list.id - agencyId = list.agencyId - type = list.type - color = list.color - description = list.description - longName = list.longName - nullSafeShortName = list.nullSafeShortName - shortName = list.shortName - textColor = list.textColor - url = list.url - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) - - fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } - - fun type(type: Long) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun color(color: String) = color(JsonField.of(color)) - - fun color(color: JsonField) = apply { this.color = color } - - fun description(description: String) = description(JsonField.of(description)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun longName(longName: String) = longName(JsonField.of(longName)) - - fun longName(longName: JsonField) = apply { this.longName = longName } - - fun nullSafeShortName(nullSafeShortName: String) = - nullSafeShortName(JsonField.of(nullSafeShortName)) - - fun nullSafeShortName(nullSafeShortName: JsonField) = apply { - this.nullSafeShortName = nullSafeShortName - } - - fun shortName(shortName: String) = shortName(JsonField.of(shortName)) - - fun shortName(shortName: JsonField) = apply { this.shortName = shortName } - - fun textColor(textColor: String) = textColor(JsonField.of(textColor)) - - fun textColor(textColor: JsonField) = apply { this.textColor = textColor } - - fun url(url: String) = url(JsonField.of(url)) - - fun url(url: JsonField) = apply { this.url = url } - - 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) - } - - fun build(): List = - List( - checkRequired("id", id), - checkRequired("agencyId", agencyId), - checkRequired("type", type), - color, - description, - longName, - nullSafeShortName, - shortName, - textColor, - url, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SearchForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SearchForRouteListResponse{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/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt deleted file mode 100644 index ad7f970..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListResponse.kt +++ /dev/null @@ -1,647 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class SearchForStopListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): SearchForStopListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SearchForStopListResponse]. */ - 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 = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(searchForStopListResponse: SearchForStopListResponse) = apply { - code = searchForStopListResponse.code - currentTime = searchForStopListResponse.currentTime - text = searchForStopListResponse.text - version = searchForStopListResponse.version - data = searchForStopListResponse.data - additionalProperties = searchForStopListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): SearchForStopListResponse = - SearchForStopListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - data, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun outOfRange(): Boolean = outOfRange.getRequired("outOfRange") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("outOfRange") - @ExcludeMissing - fun _outOfRange(): JsonField = outOfRange - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - outOfRange() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 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 - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("outOfRange", outOfRange), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), - @JsonProperty("routeIds") - @ExcludeMissing - private val routeIds: JsonField> = JsonMissing.of(), - @JsonProperty("staticRouteIds") - @ExcludeMissing - private val staticRouteIds: JsonField> = - JsonMissing.of(), - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - private val wheelchairBoarding: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Long = locationType.getRequired("locationType") - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): kotlin.collections.List = - staticRouteIds.getRequired("staticRouteIds") - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - - @JsonProperty("routeIds") - @ExcludeMissing - fun _routeIds(): JsonField> = routeIds - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun _staticRouteIds(): JsonField> = staticRouteIds - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("direction") - @ExcludeMissing - fun _direction(): JsonField = direction - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding(): JsonField = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: kotlin.collections.List) = - routeIds(JsonField.of(routeIds)) - - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds.map { it.toMutableList() } - } - - fun addRouteId(routeId: String) = apply { - routeIds = - (routeIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(routeId) - } - } - - fun staticRouteIds(staticRouteIds: kotlin.collections.List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - fun staticRouteIds(staticRouteIds: JsonField>) = - apply { - this.staticRouteIds = staticRouteIds.map { it.toMutableList() } - } - - fun addStaticRouteId(staticRouteId: String) = apply { - staticRouteIds = - (staticRouteIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(staticRouteId) - } - } - - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - 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) - } - - 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.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SearchForStopListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SearchForStopListResponse{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/ShapeRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt deleted file mode 100644 index 3ab1dd0..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveResponse.kt +++ /dev/null @@ -1,426 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class ShapeRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): ShapeRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ShapeRetrieveResponse]. */ - 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(shapeRetrieveResponse: ShapeRetrieveResponse) = apply { - code = shapeRetrieveResponse.code - currentTime = shapeRetrieveResponse.currentTime - text = shapeRetrieveResponse.text - version = shapeRetrieveResponse.version - data = shapeRetrieveResponse.data - additionalProperties = shapeRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): ShapeRetrieveResponse = - ShapeRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("length") - @ExcludeMissing - private val length: JsonField = JsonMissing.of(), - @JsonProperty("points") - @ExcludeMissing - private val points: JsonField = JsonMissing.of(), - @JsonProperty("levels") - @ExcludeMissing - private val levels: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun length(): Long = length.getRequired("length") - - /** Encoded polyline format representing the shape of the path */ - fun points(): String = points.getRequired("points") - - fun levels(): Optional = Optional.ofNullable(levels.getNullable("levels")) - - @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length - - /** Encoded polyline format representing the shape of the path */ - @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points - - @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - length() - points() - levels() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var length: JsonField? = null - private var points: JsonField? = null - private var levels: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - length = entry.length - points = entry.points - levels = entry.levels - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun length(length: Long) = length(JsonField.of(length)) - - fun length(length: JsonField) = apply { this.length = length } - - /** Encoded polyline format representing the shape of the path */ - fun points(points: String) = points(JsonField.of(points)) - - /** Encoded polyline format representing the shape of the path */ - fun points(points: JsonField) = apply { this.points = points } - - fun levels(levels: String) = levels(JsonField.of(levels)) - - fun levels(levels: JsonField) = apply { this.levels = levels } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("length", length), - checkRequired("points", points), - levels, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && length == other.length && points == other.points && levels == other.levels && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(length, points, levels, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{length=$length, points=$points, levels=$levels, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is ShapeRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ShapeRetrieveResponse{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/StopIdsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt deleted file mode 100644 index f73bb4a..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListResponse.kt +++ /dev/null @@ -1,325 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class StopIdsForAgencyListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): StopIdsForAgencyListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopIdsForAgencyListResponse]. */ - 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(stopIdsForAgencyListResponse: StopIdsForAgencyListResponse) = apply { - code = stopIdsForAgencyListResponse.code - currentTime = stopIdsForAgencyListResponse.currentTime - text = stopIdsForAgencyListResponse.text - version = stopIdsForAgencyListResponse.version - data = stopIdsForAgencyListResponse.data - additionalProperties = stopIdsForAgencyListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): StopIdsForAgencyListResponse = - StopIdsForAgencyListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") @ExcludeMissing fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded - list = data.list.map { it.toMutableList() } - references = data.references - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: String) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopIdsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopIdsForAgencyListResponse{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/StopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt deleted file mode 100644 index 5de09a5..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveResponse.kt +++ /dev/null @@ -1,590 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class StopRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): StopRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopRetrieveResponse]. */ - 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(stopRetrieveResponse: StopRetrieveResponse) = apply { - code = stopRetrieveResponse.code - currentTime = stopRetrieveResponse.currentTime - text = stopRetrieveResponse.text - version = stopRetrieveResponse.version - data = stopRetrieveResponse.data - additionalProperties = stopRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): StopRetrieveResponse = - StopRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), - @JsonProperty("routeIds") - @ExcludeMissing - private val routeIds: JsonField> = JsonMissing.of(), - @JsonProperty("staticRouteIds") - @ExcludeMissing - private val staticRouteIds: JsonField> = JsonMissing.of(), - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - private val wheelchairBoarding: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Long = locationType.getRequired("locationType") - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): List = staticRouteIds.getRequired("staticRouteIds") - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - - @JsonProperty("routeIds") - @ExcludeMissing - fun _routeIds(): JsonField> = routeIds - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun _staticRouteIds(): JsonField> = staticRouteIds - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("direction") - @ExcludeMissing - fun _direction(): JsonField = direction - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding(): JsonField = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - id() - lat() - locationType() - lon() - name() - parent() - routeIds() - staticRouteIds() - code() - direction() - wheelchairBoarding() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - 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(entry: Entry) = apply { - id = entry.id - lat = entry.lat - locationType = entry.locationType - lon = entry.lon - name = entry.name - parent = entry.parent - routeIds = entry.routeIds.map { it.toMutableList() } - staticRouteIds = entry.staticRouteIds.map { it.toMutableList() } - code = entry.code - direction = entry.direction - wheelchairBoarding = entry.wheelchairBoarding - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: List) = routeIds(JsonField.of(routeIds)) - - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds.map { it.toMutableList() } - } - - fun addRouteId(routeId: String) = apply { - routeIds = - (routeIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(routeId) - } - } - - fun staticRouteIds(staticRouteIds: List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds.map { it.toMutableList() } - } - - fun addStaticRouteId(staticRouteId: String) = apply { - staticRouteIds = - (staticRouteIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(staticRouteId) - } - } - - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - 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) - } - - fun build(): Entry = - Entry( - 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.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && 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 /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{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 /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is StopRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopRetrieveResponse{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/StopsForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt deleted file mode 100644 index e78c5d8..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListResponse.kt +++ /dev/null @@ -1,534 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class StopsForAgencyListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - fun outOfRange(): Optional = Optional.ofNullable(outOfRange.getNullable("outOfRange")) - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange(): JsonField = outOfRange - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): StopsForAgencyListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - limitExceeded() - list().forEach { it.validate() } - references().validate() - outOfRange() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopsForAgencyListResponse]. */ - 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 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(stopsForAgencyListResponse: StopsForAgencyListResponse) = apply { - code = stopsForAgencyListResponse.code - currentTime = stopsForAgencyListResponse.currentTime - text = stopsForAgencyListResponse.text - version = stopsForAgencyListResponse.version - limitExceeded = stopsForAgencyListResponse.limitExceeded - list = stopsForAgencyListResponse.list.map { it.toMutableList() } - references = stopsForAgencyListResponse.references - outOfRange = stopsForAgencyListResponse.outOfRange - additionalProperties = stopsForAgencyListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - fun references(references: JsonField) = apply { this.references = references } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - 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) - } - - fun build(): StopsForAgencyListResponse = - StopsForAgencyListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - outOfRange, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("lat") @ExcludeMissing private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), - @JsonProperty("lon") @ExcludeMissing private val lon: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), - @JsonProperty("routeIds") - @ExcludeMissing - private val routeIds: JsonField> = JsonMissing.of(), - @JsonProperty("staticRouteIds") - @ExcludeMissing - private val staticRouteIds: JsonField> = JsonMissing.of(), - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - private val wheelchairBoarding: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Long = locationType.getRequired("locationType") - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): kotlin.collections.List = - staticRouteIds.getRequired("staticRouteIds") - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = Optional.ofNullable(direction.getNullable("direction")) - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - - @JsonProperty("routeIds") - @ExcludeMissing - fun _routeIds(): JsonField> = routeIds - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun _staticRouteIds(): JsonField> = staticRouteIds - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("direction") @ExcludeMissing fun _direction(): JsonField = direction - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding(): JsonField = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: kotlin.collections.List) = - routeIds(JsonField.of(routeIds)) - - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds.map { it.toMutableList() } - } - - fun addRouteId(routeId: String) = apply { - routeIds = - (routeIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(routeId) - } - } - - fun staticRouteIds(staticRouteIds: kotlin.collections.List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - fun staticRouteIds(staticRouteIds: JsonField>) = apply { - this.staticRouteIds = staticRouteIds.map { it.toMutableList() } - } - - fun addStaticRouteId(staticRouteId: String) = apply { - staticRouteIds = - (staticRouteIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(staticRouteId) - } - } - - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - 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) - } - - 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.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is StopsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, limitExceeded, list, references, outOfRange, additionalProperties) } - /* spotless:on */ - - 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}" -} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt deleted file mode 100644 index 5fc7409..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListResponse.kt +++ /dev/null @@ -1,648 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class StopsForLocationListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): StopsForLocationListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopsForLocationListResponse]. */ - 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(stopsForLocationListResponse: StopsForLocationListResponse) = apply { - code = stopsForLocationListResponse.code - currentTime = stopsForLocationListResponse.currentTime - text = stopsForLocationListResponse.text - version = stopsForLocationListResponse.version - data = stopsForLocationListResponse.data - additionalProperties = stopsForLocationListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): StopsForLocationListResponse = - StopsForLocationListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - fun outOfRange(): Optional = - Optional.ofNullable(outOfRange.getNullable("outOfRange")) - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonProperty("outOfRange") - @ExcludeMissing - fun _outOfRange(): JsonField = outOfRange - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - references().validate() - outOfRange() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 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 - outOfRange = data.outOfRange - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - fun references(references: JsonField) = apply { - this.references = references - } - - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - outOfRange, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("locationType") - @ExcludeMissing - private val locationType: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), - @JsonProperty("routeIds") - @ExcludeMissing - private val routeIds: JsonField> = JsonMissing.of(), - @JsonProperty("staticRouteIds") - @ExcludeMissing - private val staticRouteIds: JsonField> = - JsonMissing.of(), - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("direction") - @ExcludeMissing - private val direction: JsonField = JsonMissing.of(), - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - private val wheelchairBoarding: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun lat(): Double = lat.getRequired("lat") - - fun locationType(): Long = locationType.getRequired("locationType") - - fun lon(): Double = lon.getRequired("lon") - - fun name(): String = name.getRequired("name") - - fun parent(): String = parent.getRequired("parent") - - fun routeIds(): kotlin.collections.List = routeIds.getRequired("routeIds") - - fun staticRouteIds(): kotlin.collections.List = - staticRouteIds.getRequired("staticRouteIds") - - fun code(): Optional = Optional.ofNullable(code.getNullable("code")) - - fun direction(): Optional = - Optional.ofNullable(direction.getNullable("direction")) - - fun wheelchairBoarding(): Optional = - Optional.ofNullable(wheelchairBoarding.getNullable("wheelchairBoarding")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - @JsonProperty("locationType") - @ExcludeMissing - fun _locationType(): JsonField = locationType - - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - - @JsonProperty("routeIds") - @ExcludeMissing - fun _routeIds(): JsonField> = routeIds - - @JsonProperty("staticRouteIds") - @ExcludeMissing - fun _staticRouteIds(): JsonField> = staticRouteIds - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("direction") - @ExcludeMissing - fun _direction(): JsonField = direction - - @JsonProperty("wheelchairBoarding") - @ExcludeMissing - fun _wheelchairBoarding(): JsonField = wheelchairBoarding - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun id(id: JsonField) = apply { this.id = id } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun locationType(locationType: Long) = locationType(JsonField.of(locationType)) - - fun locationType(locationType: JsonField) = apply { - this.locationType = locationType - } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - fun lon(lon: JsonField) = apply { this.lon = lon } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun parent(parent: String) = parent(JsonField.of(parent)) - - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun routeIds(routeIds: kotlin.collections.List) = - routeIds(JsonField.of(routeIds)) - - fun routeIds(routeIds: JsonField>) = apply { - this.routeIds = routeIds.map { it.toMutableList() } - } - - fun addRouteId(routeId: String) = apply { - routeIds = - (routeIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(routeId) - } - } - - fun staticRouteIds(staticRouteIds: kotlin.collections.List) = - staticRouteIds(JsonField.of(staticRouteIds)) - - fun staticRouteIds(staticRouteIds: JsonField>) = - apply { - this.staticRouteIds = staticRouteIds.map { it.toMutableList() } - } - - fun addStaticRouteId(staticRouteId: String) = apply { - staticRouteIds = - (staticRouteIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(staticRouteId) - } - } - - fun code(code: String) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun direction(direction: String) = direction(JsonField.of(direction)) - - fun direction(direction: JsonField) = apply { this.direction = direction } - - fun wheelchairBoarding(wheelchairBoarding: String) = - wheelchairBoarding(JsonField.of(wheelchairBoarding)) - - 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) - } - - 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.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopsForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopsForLocationListResponse{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/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt deleted file mode 100644 index 2676f66..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListResponse.kt +++ /dev/null @@ -1,1089 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class StopsForRouteListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): StopsForRouteListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopsForRouteListResponse]. */ - 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(stopsForRouteListResponse: StopsForRouteListResponse) = apply { - code = stopsForRouteListResponse.code - currentTime = stopsForRouteListResponse.currentTime - text = stopsForRouteListResponse.text - version = stopsForRouteListResponse.version - data = stopsForRouteListResponse.data - additionalProperties = stopsForRouteListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): StopsForRouteListResponse = - StopsForRouteListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("polylines") - @ExcludeMissing - private val polylines: JsonField> = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("stopGroupings") - @ExcludeMissing - private val stopGroupings: JsonField> = JsonMissing.of(), - @JsonProperty("stopIds") - @ExcludeMissing - private val stopIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun polylines(): Optional> = - Optional.ofNullable(polylines.getNullable("polylines")) - - fun routeId(): Optional = Optional.ofNullable(routeId.getNullable("routeId")) - - fun stopGroupings(): Optional> = - Optional.ofNullable(stopGroupings.getNullable("stopGroupings")) - - fun stopIds(): Optional> = - Optional.ofNullable(stopIds.getNullable("stopIds")) - - @JsonProperty("polylines") - @ExcludeMissing - fun _polylines(): JsonField> = polylines - - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - - @JsonProperty("stopGroupings") - @ExcludeMissing - fun _stopGroupings(): JsonField> = stopGroupings - - @JsonProperty("stopIds") - @ExcludeMissing - fun _stopIds(): JsonField> = stopIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - polylines().ifPresent { it.forEach { it.validate() } } - routeId() - stopGroupings().ifPresent { it.forEach { it.validate() } } - stopIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - 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 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)) - - fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines.map { it.toMutableList() } - } - - fun addPolyline(polyline: Polyline) = apply { - polylines = - (polylines ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(polyline) - } - } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun stopGroupings(stopGroupings: List) = - stopGroupings(JsonField.of(stopGroupings)) - - fun stopGroupings(stopGroupings: JsonField>) = apply { - this.stopGroupings = stopGroupings.map { it.toMutableList() } - } - - fun addStopGrouping(stopGrouping: StopGrouping) = apply { - stopGroupings = - (stopGroupings ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopGrouping) - } - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - - fun stopIds(stopIds: JsonField>) = apply { - this.stopIds = stopIds.map { it.toMutableList() } - } - - fun addStopId(stopId: String) = apply { - stopIds = - (stopIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): Entry = - Entry( - (polylines ?: JsonMissing.of()).map { it.toImmutable() }, - routeId, - (stopGroupings ?: JsonMissing.of()).map { it.toImmutable() }, - (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Polyline - @JsonCreator - private constructor( - @JsonProperty("length") - @ExcludeMissing - private val length: JsonField = JsonMissing.of(), - @JsonProperty("levels") - @ExcludeMissing - private val levels: JsonField = JsonMissing.of(), - @JsonProperty("points") - @ExcludeMissing - private val points: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun length(): Optional = Optional.ofNullable(length.getNullable("length")) - - fun levels(): Optional = Optional.ofNullable(levels.getNullable("levels")) - - fun points(): Optional = Optional.ofNullable(points.getNullable("points")) - - @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length - - @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels - - @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Polyline = apply { - if (validated) { - return@apply - } - - length() - levels() - points() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun length(length: JsonField) = apply { this.length = length } - - fun levels(levels: String) = levels(JsonField.of(levels)) - - fun levels(levels: JsonField) = apply { this.levels = levels } - - fun points(points: String) = points(JsonField.of(points)) - - 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) - } - - fun build(): Polyline = - Polyline( - length, - levels, - points, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Polyline && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class StopGrouping - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("polylines") - @ExcludeMissing - private val polylines: JsonField> = JsonMissing.of(), - @JsonProperty("stopIds") - @ExcludeMissing - private val stopIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun polylines(): Optional> = - Optional.ofNullable(polylines.getNullable("polylines")) - - fun stopIds(): Optional> = - Optional.ofNullable(stopIds.getNullable("stopIds")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("polylines") - @ExcludeMissing - fun _polylines(): JsonField> = polylines - - @JsonProperty("stopIds") - @ExcludeMissing - fun _stopIds(): JsonField> = stopIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: Name) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun polylines(polylines: List) = polylines(JsonField.of(polylines)) - - fun polylines(polylines: JsonField>) = apply { - this.polylines = polylines.map { it.toMutableList() } - } - - fun addPolyline(polyline: Polyline) = apply { - polylines = - (polylines ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(polyline) - } - } - - fun stopIds(stopIds: List) = stopIds(JsonField.of(stopIds)) - - fun stopIds(stopIds: JsonField>) = apply { - this.stopIds = stopIds.map { it.toMutableList() } - } - - fun addStopId(stopId: String) = apply { - stopIds = - (stopIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): StopGrouping = - StopGrouping( - id, - name, - (polylines ?: JsonMissing.of()).map { it.toImmutable() }, - (stopIds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Name - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("names") - @ExcludeMissing - private val names: JsonField> = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun names(): Optional> = - Optional.ofNullable(names.getNullable("names")) - - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("names") - @ExcludeMissing - fun _names(): JsonField> = names - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - name() - names() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun name(name: JsonField) = apply { this.name = name } - - fun names(names: List) = names(JsonField.of(names)) - - fun names(names: JsonField>) = apply { - this.names = names.map { it.toMutableList() } - } - - fun addName(name: String) = apply { - names = - (names ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(name) - } - } - - fun type(type: String) = type(JsonField.of(type)) - - 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) - } - - fun build(): Name = - Name( - name, - (names ?: JsonMissing.of()).map { it.toImmutable() }, - type, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Name && name == other.name && names == other.names && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, names, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Polyline - @JsonCreator - private constructor( - @JsonProperty("length") - @ExcludeMissing - private val length: JsonField = JsonMissing.of(), - @JsonProperty("levels") - @ExcludeMissing - private val levels: JsonField = JsonMissing.of(), - @JsonProperty("points") - @ExcludeMissing - private val points: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun length(): Optional = Optional.ofNullable(length.getNullable("length")) - - fun levels(): Optional = - Optional.ofNullable(levels.getNullable("levels")) - - fun points(): Optional = - Optional.ofNullable(points.getNullable("points")) - - @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length - - @JsonProperty("levels") - @ExcludeMissing - fun _levels(): JsonField = levels - - @JsonProperty("points") - @ExcludeMissing - fun _points(): JsonField = points - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Polyline = apply { - if (validated) { - return@apply - } - - length() - levels() - points() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun length(length: JsonField) = apply { this.length = length } - - fun levels(levels: String) = levels(JsonField.of(levels)) - - fun levels(levels: JsonField) = apply { this.levels = levels } - - fun points(points: String) = points(JsonField.of(points)) - - 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) - } - - fun build(): Polyline = - Polyline( - length, - levels, - points, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Polyline && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is StopGrouping && id == other.id && name == other.name && polylines == other.polylines && stopIds == other.stopIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, polylines, stopIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && polylines == other.polylines && routeId == other.routeId && stopGroupings == other.stopGroupings && stopIds == other.stopIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is StopsForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopsForRouteListResponse{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/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt deleted file mode 100644 index 7277b0b..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveResponse.kt +++ /dev/null @@ -1,1990 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class TripDetailRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): TripDetailRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TripDetailRetrieveResponse]. */ - 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(tripDetailRetrieveResponse: TripDetailRetrieveResponse) = apply { - code = tripDetailRetrieveResponse.code - currentTime = tripDetailRetrieveResponse.currentTime - text = tripDetailRetrieveResponse.text - version = tripDetailRetrieveResponse.version - data = tripDetailRetrieveResponse.data - additionalProperties = tripDetailRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): TripDetailRetrieveResponse = - TripDetailRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - private val schedule: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun tripId(): String = tripId.getRequired("tripId") - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun schedule(): Optional = - Optional.ofNullable(schedule.getNullable("schedule")) - - fun serviceDate(): Optional = - Optional.ofNullable(serviceDate.getNullable("serviceDate")) - - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - @JsonProperty("schedule") - @ExcludeMissing - fun _schedule(): JsonField = schedule - - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - tripId() - frequency() - schedule().ifPresent { it.validate() } - serviceDate() - situationIds() - status().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var tripId: JsonField? = null - private var frequency: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField>? = null - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - tripId = entry.tripId - frequency = entry.frequency - schedule = entry.schedule - serviceDate = entry.serviceDate - situationIds = entry.situationIds.map { it.toMutableList() } - status = entry.status - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) - - fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) - - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("tripId", tripId), - frequency, - schedule, - serviceDate, - (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, - status, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Schedule - @JsonCreator - private constructor( - @JsonProperty("nextTripId") - @ExcludeMissing - private val nextTripId: JsonField = JsonMissing.of(), - @JsonProperty("previousTripId") - @ExcludeMissing - private val previousTripId: JsonField = JsonMissing.of(), - @JsonProperty("stopTimes") - @ExcludeMissing - private val stopTimes: JsonField> = JsonMissing.of(), - @JsonProperty("timeZone") - @ExcludeMissing - private val timeZone: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun nextTripId(): String = nextTripId.getRequired("nextTripId") - - fun previousTripId(): String = previousTripId.getRequired("previousTripId") - - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - - fun timeZone(): String = timeZone.getRequired("timeZone") - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - @JsonProperty("nextTripId") - @ExcludeMissing - fun _nextTripId(): JsonField = nextTripId - - @JsonProperty("previousTripId") - @ExcludeMissing - fun _previousTripId(): JsonField = previousTripId - - @JsonProperty("stopTimes") - @ExcludeMissing - fun _stopTimes(): JsonField> = stopTimes - - @JsonProperty("timeZone") - @ExcludeMissing - fun _timeZone(): JsonField = timeZone - - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Schedule = apply { - if (validated) { - return@apply - } - - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - frequency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Schedule]. */ - class Builder internal constructor() { - - private var nextTripId: JsonField? = null - private var previousTripId: JsonField? = null - private var stopTimes: JsonField>? = null - private var timeZone: JsonField? = null - private var frequency: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - nextTripId = schedule.nextTripId - previousTripId = schedule.previousTripId - stopTimes = schedule.stopTimes.map { it.toMutableList() } - timeZone = schedule.timeZone - frequency = schedule.frequency - additionalProperties = schedule.additionalProperties.toMutableMap() - } - - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - - fun nextTripId(nextTripId: JsonField) = apply { - this.nextTripId = nextTripId - } - - fun previousTripId(previousTripId: String) = - previousTripId(JsonField.of(previousTripId)) - - fun previousTripId(previousTripId: JsonField) = apply { - this.previousTripId = previousTripId - } - - fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes.map { it.toMutableList() } - } - - fun addStopTime(stopTime: StopTime) = apply { - stopTimes = - (stopTimes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopTime) - } - } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) - - fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) - - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - 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) - } - - fun build(): Schedule = - Schedule( - checkRequired("nextTripId", nextTripId), - checkRequired("previousTripId", previousTripId), - checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, - checkRequired("timeZone", timeZone), - frequency, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class StopTime - @JsonCreator - private constructor( - @JsonProperty("arrivalTime") - @ExcludeMissing - private val arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("historicalOccupancy") - @ExcludeMissing - private val historicalOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - - fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) - - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = - Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime(): JsonField = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime(): JsonField = departureTime - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy(): JsonField = historicalOccupancy - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign(): JsonField = stopHeadsign - - @JsonProperty("stopId") - @ExcludeMissing - fun _stopId(): JsonField = stopId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): StopTime = apply { - if (validated) { - return@apply - } - - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopTime]. */ - class Builder internal constructor() { - - private var arrivalTime: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var historicalOccupancy: JsonField = JsonMissing.of() - private var stopHeadsign: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopTime: StopTime) = apply { - arrivalTime = stopTime.arrivalTime - departureTime = stopTime.departureTime - distanceAlongTrip = stopTime.distanceAlongTrip - historicalOccupancy = stopTime.historicalOccupancy - stopHeadsign = stopTime.stopHeadsign - stopId = stopTime.stopId - additionalProperties = stopTime.additionalProperties.toMutableMap() - } - - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - 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) - } - - fun build(): StopTime = - StopTime( - arrivalTime, - departureTime, - distanceAlongTrip, - historicalOccupancy, - stopHeadsign, - stopId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Status - @JsonCreator - private constructor( - @JsonProperty("activeTripId") - @ExcludeMissing - private val activeTripId: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("closestStop") - @ExcludeMissing - private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCapacity") - @ExcludeMissing - private val occupancyCapacity: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCount") - @ExcludeMissing - private val occupancyCount: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDeviation") - @ExcludeMissing - private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun _activeTripId(): JsonField = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun _closestStop(): JsonField = closestStop - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity(): JsonField = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount(): JsonField = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation(): JsonField = scheduleDeviation - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation(): JsonField = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation(): JsonField = lastKnownOrientation - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun _nextStop(): JsonField = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun _orientation(): JsonField = orientation - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Status = 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 toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Status]. */ - 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(status: Status) = apply { - activeTripId = status.activeTripId - blockTripSequence = status.blockTripSequence - closestStop = status.closestStop - distanceAlongTrip = status.distanceAlongTrip - lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - lastLocationUpdateTime = status.lastLocationUpdateTime - lastUpdateTime = status.lastUpdateTime - occupancyCapacity = status.occupancyCapacity - occupancyCount = status.occupancyCount - occupancyStatus = status.occupancyStatus - phase = status.phase - predicted = status.predicted - scheduleDeviation = status.scheduleDeviation - serviceDate = status.serviceDate - this.status = status.status - totalDistanceAlongTrip = status.totalDistanceAlongTrip - closestStopTimeOffset = status.closestStopTimeOffset - frequency = status.frequency - lastKnownLocation = status.lastKnownLocation - lastKnownOrientation = status.lastKnownOrientation - nextStop = status.nextStop - nextStopTimeOffset = status.nextStopTimeOffset - orientation = status.orientation - position = status.position - scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - situationIds = status.situationIds.map { it.toMutableList() } - vehicleId = status.vehicleId - additionalProperties = status.additionalProperties.toMutableMap() - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - 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)) - - /** Index of the active trip into the sequence of trips for the active block. */ - 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)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - 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)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - 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)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - 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)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - 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)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - 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)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - 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)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - 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)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - 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. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - 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)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - 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)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - 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)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** References to situation elements (if any) applicable to this trip. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - 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) - } - - fun build(): Status = - Status( - 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.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @NoAutoDetect - class LastKnownLocation - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LastKnownLocation = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the last known location of the transit vehicle. */ - 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)) - - /** Longitude of the last known location of the transit vehicle. */ - 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) - } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @NoAutoDetect - class Position - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Position = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the current position of the transit vehicle. */ - 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)) - - /** Longitude of the current position of the transit vehicle. */ - 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) - } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is Status && 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Status{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 /* spotless:off */ other is Entry && tripId == other.tripId && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tripId, frequency, schedule, serviceDate, situationIds, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{tripId=$tripId, frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is TripDetailRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TripDetailRetrieveResponse{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/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt deleted file mode 100644 index 3b9377f..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveResponse.kt +++ /dev/null @@ -1,1991 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class TripForVehicleRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): TripForVehicleRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TripForVehicleRetrieveResponse]. */ - 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(tripForVehicleRetrieveResponse: TripForVehicleRetrieveResponse) = apply { - code = tripForVehicleRetrieveResponse.code - currentTime = tripForVehicleRetrieveResponse.currentTime - text = tripForVehicleRetrieveResponse.text - version = tripForVehicleRetrieveResponse.version - data = tripForVehicleRetrieveResponse.data - additionalProperties = - tripForVehicleRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): TripForVehicleRetrieveResponse = - TripForVehicleRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - private val schedule: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun tripId(): String = tripId.getRequired("tripId") - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun schedule(): Optional = - Optional.ofNullable(schedule.getNullable("schedule")) - - fun serviceDate(): Optional = - Optional.ofNullable(serviceDate.getNullable("serviceDate")) - - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - @JsonProperty("schedule") - @ExcludeMissing - fun _schedule(): JsonField = schedule - - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - tripId() - frequency() - schedule().ifPresent { it.validate() } - serviceDate() - situationIds() - status().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - private var tripId: JsonField? = null - private var frequency: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField>? = null - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - tripId = entry.tripId - frequency = entry.frequency - schedule = entry.schedule - serviceDate = entry.serviceDate - situationIds = entry.situationIds.map { it.toMutableList() } - status = entry.status - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) - - fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) - - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun situationIds(situationIds: List) = - situationIds(JsonField.of(situationIds)) - - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("tripId", tripId), - frequency, - schedule, - serviceDate, - (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, - status, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Schedule - @JsonCreator - private constructor( - @JsonProperty("nextTripId") - @ExcludeMissing - private val nextTripId: JsonField = JsonMissing.of(), - @JsonProperty("previousTripId") - @ExcludeMissing - private val previousTripId: JsonField = JsonMissing.of(), - @JsonProperty("stopTimes") - @ExcludeMissing - private val stopTimes: JsonField> = JsonMissing.of(), - @JsonProperty("timeZone") - @ExcludeMissing - private val timeZone: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun nextTripId(): String = nextTripId.getRequired("nextTripId") - - fun previousTripId(): String = previousTripId.getRequired("previousTripId") - - fun stopTimes(): List = stopTimes.getRequired("stopTimes") - - fun timeZone(): String = timeZone.getRequired("timeZone") - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - @JsonProperty("nextTripId") - @ExcludeMissing - fun _nextTripId(): JsonField = nextTripId - - @JsonProperty("previousTripId") - @ExcludeMissing - fun _previousTripId(): JsonField = previousTripId - - @JsonProperty("stopTimes") - @ExcludeMissing - fun _stopTimes(): JsonField> = stopTimes - - @JsonProperty("timeZone") - @ExcludeMissing - fun _timeZone(): JsonField = timeZone - - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Schedule = apply { - if (validated) { - return@apply - } - - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - frequency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Schedule]. */ - class Builder internal constructor() { - - private var nextTripId: JsonField? = null - private var previousTripId: JsonField? = null - private var stopTimes: JsonField>? = null - private var timeZone: JsonField? = null - private var frequency: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - nextTripId = schedule.nextTripId - previousTripId = schedule.previousTripId - stopTimes = schedule.stopTimes.map { it.toMutableList() } - timeZone = schedule.timeZone - frequency = schedule.frequency - additionalProperties = schedule.additionalProperties.toMutableMap() - } - - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - - fun nextTripId(nextTripId: JsonField) = apply { - this.nextTripId = nextTripId - } - - fun previousTripId(previousTripId: String) = - previousTripId(JsonField.of(previousTripId)) - - fun previousTripId(previousTripId: JsonField) = apply { - this.previousTripId = previousTripId - } - - fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) - - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes.map { it.toMutableList() } - } - - fun addStopTime(stopTime: StopTime) = apply { - stopTimes = - (stopTimes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopTime) - } - } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) - - fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) - - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - 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) - } - - fun build(): Schedule = - Schedule( - checkRequired("nextTripId", nextTripId), - checkRequired("previousTripId", previousTripId), - checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, - checkRequired("timeZone", timeZone), - frequency, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class StopTime - @JsonCreator - private constructor( - @JsonProperty("arrivalTime") - @ExcludeMissing - private val arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("historicalOccupancy") - @ExcludeMissing - private val historicalOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - - fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) - - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = - Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime(): JsonField = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime(): JsonField = departureTime - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy(): JsonField = historicalOccupancy - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign(): JsonField = stopHeadsign - - @JsonProperty("stopId") - @ExcludeMissing - fun _stopId(): JsonField = stopId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): StopTime = apply { - if (validated) { - return@apply - } - - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopTime]. */ - class Builder internal constructor() { - - private var arrivalTime: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var historicalOccupancy: JsonField = JsonMissing.of() - private var stopHeadsign: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopTime: StopTime) = apply { - arrivalTime = stopTime.arrivalTime - departureTime = stopTime.departureTime - distanceAlongTrip = stopTime.distanceAlongTrip - historicalOccupancy = stopTime.historicalOccupancy - stopHeadsign = stopTime.stopHeadsign - stopId = stopTime.stopId - additionalProperties = stopTime.additionalProperties.toMutableMap() - } - - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - 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) - } - - fun build(): StopTime = - StopTime( - arrivalTime, - departureTime, - distanceAlongTrip, - historicalOccupancy, - stopHeadsign, - stopId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Status - @JsonCreator - private constructor( - @JsonProperty("activeTripId") - @ExcludeMissing - private val activeTripId: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("closestStop") - @ExcludeMissing - private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCapacity") - @ExcludeMissing - private val occupancyCapacity: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCount") - @ExcludeMissing - private val occupancyCount: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDeviation") - @ExcludeMissing - private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun _activeTripId(): JsonField = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun _closestStop(): JsonField = closestStop - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity(): JsonField = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount(): JsonField = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation(): JsonField = scheduleDeviation - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation(): JsonField = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation(): JsonField = lastKnownOrientation - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun _nextStop(): JsonField = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun _orientation(): JsonField = orientation - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Status = 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 toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Status]. */ - 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(status: Status) = apply { - activeTripId = status.activeTripId - blockTripSequence = status.blockTripSequence - closestStop = status.closestStop - distanceAlongTrip = status.distanceAlongTrip - lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - lastLocationUpdateTime = status.lastLocationUpdateTime - lastUpdateTime = status.lastUpdateTime - occupancyCapacity = status.occupancyCapacity - occupancyCount = status.occupancyCount - occupancyStatus = status.occupancyStatus - phase = status.phase - predicted = status.predicted - scheduleDeviation = status.scheduleDeviation - serviceDate = status.serviceDate - this.status = status.status - totalDistanceAlongTrip = status.totalDistanceAlongTrip - closestStopTimeOffset = status.closestStopTimeOffset - frequency = status.frequency - lastKnownLocation = status.lastKnownLocation - lastKnownOrientation = status.lastKnownOrientation - nextStop = status.nextStop - nextStopTimeOffset = status.nextStopTimeOffset - orientation = status.orientation - position = status.position - scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - situationIds = status.situationIds.map { it.toMutableList() } - vehicleId = status.vehicleId - additionalProperties = status.additionalProperties.toMutableMap() - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - 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)) - - /** Index of the active trip into the sequence of trips for the active block. */ - 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)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - 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)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - 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)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - 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)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - 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)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - 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)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - 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)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - 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)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - 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. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - 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)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - 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)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - 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)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** References to situation elements (if any) applicable to this trip. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - 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) - } - - fun build(): Status = - Status( - 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.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @NoAutoDetect - class LastKnownLocation - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LastKnownLocation = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the last known location of the transit vehicle. */ - 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)) - - /** Longitude of the last known location of the transit vehicle. */ - 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) - } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @NoAutoDetect - class Position - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Position = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the current position of the transit vehicle. */ - 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)) - - /** Longitude of the current position of the transit vehicle. */ - 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) - } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is Status && 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Status{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 /* spotless:off */ other is Entry && tripId == other.tripId && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tripId, frequency, schedule, serviceDate, situationIds, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{tripId=$tripId, frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is TripForVehicleRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TripForVehicleRetrieveResponse{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/TripRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt deleted file mode 100644 index c4986cd..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveResponse.kt +++ /dev/null @@ -1,571 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class TripRetrieveResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): TripRetrieveResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TripRetrieveResponse]. */ - 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(tripRetrieveResponse: TripRetrieveResponse) = apply { - code = tripRetrieveResponse.code - currentTime = tripRetrieveResponse.currentTime - text = tripRetrieveResponse.text - version = tripRetrieveResponse.version - data = tripRetrieveResponse.data - additionalProperties = tripRetrieveResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): TripRetrieveResponse = - TripRetrieveResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("entry") - @ExcludeMissing - private val entry: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entry(): Entry = entry.getRequired("entry") - - fun references(): References = references.getRequired("references") - - @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - entry().validate() - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun entry(entry: JsonField) = apply { this.entry = entry } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("entry", entry), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Entry - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("routeId") - @ExcludeMissing - private val routeId: JsonField = JsonMissing.of(), - @JsonProperty("serviceId") - @ExcludeMissing - private val serviceId: JsonField = JsonMissing.of(), - @JsonProperty("blockId") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("directionId") - @ExcludeMissing - private val directionId: JsonField = JsonMissing.of(), - @JsonProperty("peakOffpeak") - @ExcludeMissing - private val peakOffpeak: JsonField = JsonMissing.of(), - @JsonProperty("routeShortName") - @ExcludeMissing - private val routeShortName: JsonField = JsonMissing.of(), - @JsonProperty("shapeId") - @ExcludeMissing - private val shapeId: JsonField = JsonMissing.of(), - @JsonProperty("timeZone") - @ExcludeMissing - private val timeZone: JsonField = JsonMissing.of(), - @JsonProperty("tripHeadsign") - @ExcludeMissing - private val tripHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("tripShortName") - @ExcludeMissing - private val tripShortName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun routeId(): String = routeId.getRequired("routeId") - - fun serviceId(): String = serviceId.getRequired("serviceId") - - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("blockId")) - - fun directionId(): Optional = - Optional.ofNullable(directionId.getNullable("directionId")) - - fun peakOffpeak(): Optional = - Optional.ofNullable(peakOffpeak.getNullable("peakOffpeak")) - - fun routeShortName(): Optional = - Optional.ofNullable(routeShortName.getNullable("routeShortName")) - - fun shapeId(): Optional = Optional.ofNullable(shapeId.getNullable("shapeId")) - - fun timeZone(): Optional = Optional.ofNullable(timeZone.getNullable("timeZone")) - - fun tripHeadsign(): Optional = - Optional.ofNullable(tripHeadsign.getNullable("tripHeadsign")) - - fun tripShortName(): Optional = - Optional.ofNullable(tripShortName.getNullable("tripShortName")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId - - @JsonProperty("serviceId") - @ExcludeMissing - fun _serviceId(): JsonField = serviceId - - @JsonProperty("blockId") @ExcludeMissing fun _blockId(): JsonField = blockId - - @JsonProperty("directionId") - @ExcludeMissing - fun _directionId(): JsonField = directionId - - @JsonProperty("peakOffpeak") - @ExcludeMissing - fun _peakOffpeak(): JsonField = peakOffpeak - - @JsonProperty("routeShortName") - @ExcludeMissing - fun _routeShortName(): JsonField = routeShortName - - @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId - - @JsonProperty("timeZone") @ExcludeMissing fun _timeZone(): JsonField = timeZone - - @JsonProperty("tripHeadsign") - @ExcludeMissing - fun _tripHeadsign(): JsonField = tripHeadsign - - @JsonProperty("tripShortName") - @ExcludeMissing - fun _tripShortName(): JsonField = tripShortName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Entry = apply { - if (validated) { - return@apply - } - - id() - routeId() - serviceId() - blockId() - directionId() - peakOffpeak() - routeShortName() - shapeId() - timeZone() - tripHeadsign() - tripShortName() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Entry]. */ - class Builder internal constructor() { - - 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() - - @JvmSynthetic - internal fun from(entry: Entry) = apply { - id = entry.id - routeId = entry.routeId - serviceId = entry.serviceId - blockId = entry.blockId - directionId = entry.directionId - peakOffpeak = entry.peakOffpeak - routeShortName = entry.routeShortName - shapeId = entry.shapeId - timeZone = entry.timeZone - tripHeadsign = entry.tripHeadsign - tripShortName = entry.tripShortName - additionalProperties = entry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun routeId(routeId: String) = routeId(JsonField.of(routeId)) - - fun routeId(routeId: JsonField) = apply { this.routeId = routeId } - - fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) - - fun serviceId(serviceId: JsonField) = apply { this.serviceId = serviceId } - - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - fun directionId(directionId: String) = directionId(JsonField.of(directionId)) - - fun directionId(directionId: JsonField) = apply { - this.directionId = directionId - } - - fun peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) - - fun peakOffpeak(peakOffpeak: JsonField) = apply { - this.peakOffpeak = peakOffpeak - } - - fun routeShortName(routeShortName: String) = - routeShortName(JsonField.of(routeShortName)) - - fun routeShortName(routeShortName: JsonField) = apply { - this.routeShortName = routeShortName - } - - fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) - - fun shapeId(shapeId: JsonField) = apply { this.shapeId = shapeId } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun tripHeadsign(tripHeadsign: String) = tripHeadsign(JsonField.of(tripHeadsign)) - - fun tripHeadsign(tripHeadsign: JsonField) = apply { - this.tripHeadsign = tripHeadsign - } - - fun tripShortName(tripShortName: String) = - tripShortName(JsonField.of(tripShortName)) - - fun tripShortName(tripShortName: JsonField) = apply { - this.tripShortName = tripShortName - } - - 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) - } - - fun build(): Entry = - Entry( - checkRequired("id", id), - checkRequired("routeId", routeId), - checkRequired("serviceId", serviceId), - blockId, - directionId, - peakOffpeak, - routeShortName, - shapeId, - timeZone, - tripHeadsign, - tripShortName, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Entry && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entry{id=$id, routeId=$routeId, serviceId=$serviceId, blockId=$blockId, directionId=$directionId, peakOffpeak=$peakOffpeak, routeShortName=$routeShortName, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is TripRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TripRetrieveResponse{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/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt deleted file mode 100644 index 52cc892..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListResponse.kt +++ /dev/null @@ -1,2056 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class TripsForLocationListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): TripsForLocationListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TripsForLocationListResponse]. */ - 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(tripsForLocationListResponse: TripsForLocationListResponse) = apply { - code = tripsForLocationListResponse.code - currentTime = tripsForLocationListResponse.currentTime - text = tripsForLocationListResponse.text - version = tripsForLocationListResponse.version - data = tripsForLocationListResponse.data - additionalProperties = tripsForLocationListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): TripsForLocationListResponse = - TripsForLocationListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonProperty("outOfRange") - @ExcludeMissing - private val outOfRange: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Indicates if the limit of trips has been exceeded */ - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - /** Indicates if the search location is out of range */ - fun outOfRange(): Optional = - Optional.ofNullable(outOfRange.getNullable("outOfRange")) - - /** Indicates if the limit of trips has been exceeded */ - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - /** Indicates if the search location is out of range */ - @JsonProperty("outOfRange") - @ExcludeMissing - fun _outOfRange(): JsonField = outOfRange - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - references().validate() - outOfRange() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 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 - outOfRange = data.outOfRange - additionalProperties = data.additionalProperties.toMutableMap() - } - - /** Indicates if the limit of trips has been exceeded */ - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - /** Indicates if the limit of trips has been exceeded */ - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - fun references(references: JsonField) = apply { - this.references = references - } - - /** Indicates if the search location is out of range */ - fun outOfRange(outOfRange: Boolean) = outOfRange(JsonField.of(outOfRange)) - - /** Indicates if the search location is out of range */ - fun outOfRange(outOfRange: JsonField) = apply { this.outOfRange = outOfRange } - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - outOfRange, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("schedule") - @ExcludeMissing - private val schedule: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun schedule(): Schedule = schedule.getRequired("schedule") - - fun status(): Status = status.getRequired("status") - - fun tripId(): String = tripId.getRequired("tripId") - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun serviceDate(): Optional = - Optional.ofNullable(serviceDate.getNullable("serviceDate")) - - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - @JsonProperty("schedule") - @ExcludeMissing - fun _schedule(): JsonField = schedule - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - schedule().validate() - status().validate() - tripId() - frequency() - serviceDate() - situationIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal constructor() { - - private var schedule: JsonField? = null - private var status: JsonField? = null - private var situationIds: JsonField>? = null - private var tripId: JsonField? = null - private var frequency: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - schedule = list.schedule - status = list.status - tripId = list.tripId - frequency = list.frequency - serviceDate = list.serviceDate - situationIds = list.situationIds.map { it.toMutableList() } - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) - - fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) - - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): List = - List( - checkRequired("schedule", schedule), - checkRequired("status", status), - (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, - checkRequired("tripId", tripId), - frequency, - serviceDate, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Schedule - @JsonCreator - private constructor( - @JsonProperty("nextTripId") - @ExcludeMissing - private val nextTripId: JsonField = JsonMissing.of(), - @JsonProperty("previousTripId") - @ExcludeMissing - private val previousTripId: JsonField = JsonMissing.of(), - @JsonProperty("stopTimes") - @ExcludeMissing - private val stopTimes: JsonField> = - JsonMissing.of(), - @JsonProperty("timeZone") - @ExcludeMissing - private val timeZone: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun nextTripId(): String = nextTripId.getRequired("nextTripId") - - fun previousTripId(): String = previousTripId.getRequired("previousTripId") - - fun stopTimes(): kotlin.collections.List = - stopTimes.getRequired("stopTimes") - - fun timeZone(): String = timeZone.getRequired("timeZone") - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - @JsonProperty("nextTripId") - @ExcludeMissing - fun _nextTripId(): JsonField = nextTripId - - @JsonProperty("previousTripId") - @ExcludeMissing - fun _previousTripId(): JsonField = previousTripId - - @JsonProperty("stopTimes") - @ExcludeMissing - fun _stopTimes(): JsonField> = stopTimes - - @JsonProperty("timeZone") - @ExcludeMissing - fun _timeZone(): JsonField = timeZone - - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Schedule = apply { - if (validated) { - return@apply - } - - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - frequency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Schedule]. */ - class Builder internal constructor() { - - private var frequency: JsonField = JsonMissing.of() - private var nextTripId: JsonField? = null - private var previousTripId: JsonField? = null - private var stopTimes: JsonField>? = null - private var timeZone: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - nextTripId = schedule.nextTripId - previousTripId = schedule.previousTripId - stopTimes = schedule.stopTimes.map { it.toMutableList() } - timeZone = schedule.timeZone - frequency = schedule.frequency - additionalProperties = schedule.additionalProperties.toMutableMap() - } - - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - - fun nextTripId(nextTripId: JsonField) = apply { - this.nextTripId = nextTripId - } - - fun previousTripId(previousTripId: String) = - previousTripId(JsonField.of(previousTripId)) - - fun previousTripId(previousTripId: JsonField) = apply { - this.previousTripId = previousTripId - } - - fun stopTimes(stopTimes: kotlin.collections.List) = - stopTimes(JsonField.of(stopTimes)) - - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes.map { it.toMutableList() } - } - - fun addStopTime(stopTime: StopTime) = apply { - stopTimes = - (stopTimes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopTime) - } - } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) - - fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) - - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - 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) - } - - fun build(): Schedule = - Schedule( - checkRequired("nextTripId", nextTripId), - checkRequired("previousTripId", previousTripId), - checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, - checkRequired("timeZone", timeZone), - frequency, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class StopTime - @JsonCreator - private constructor( - @JsonProperty("arrivalTime") - @ExcludeMissing - private val arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("historicalOccupancy") - @ExcludeMissing - private val historicalOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - - fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) - - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = - Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime(): JsonField = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime(): JsonField = departureTime - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy(): JsonField = historicalOccupancy - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign(): JsonField = stopHeadsign - - @JsonProperty("stopId") - @ExcludeMissing - fun _stopId(): JsonField = stopId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): StopTime = apply { - if (validated) { - return@apply - } - - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopTime]. */ - class Builder internal constructor() { - - private var arrivalTime: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var historicalOccupancy: JsonField = JsonMissing.of() - private var stopHeadsign: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopTime: StopTime) = apply { - arrivalTime = stopTime.arrivalTime - departureTime = stopTime.departureTime - distanceAlongTrip = stopTime.distanceAlongTrip - historicalOccupancy = stopTime.historicalOccupancy - stopHeadsign = stopTime.stopHeadsign - stopId = stopTime.stopId - additionalProperties = stopTime.additionalProperties.toMutableMap() - } - - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - 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) - } - - fun build(): StopTime = - StopTime( - arrivalTime, - departureTime, - distanceAlongTrip, - historicalOccupancy, - stopHeadsign, - stopId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Status - @JsonCreator - private constructor( - @JsonProperty("activeTripId") - @ExcludeMissing - private val activeTripId: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("closestStop") - @ExcludeMissing - private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCapacity") - @ExcludeMissing - private val occupancyCapacity: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCount") - @ExcludeMissing - private val occupancyCount: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDeviation") - @ExcludeMissing - private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = - JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun _activeTripId(): JsonField = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun _closestStop(): JsonField = closestStop - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity(): JsonField = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount(): JsonField = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation(): JsonField = scheduleDeviation - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation(): JsonField = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation(): JsonField = lastKnownOrientation - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun _nextStop(): JsonField = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun _orientation(): JsonField = orientation - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Status = 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 toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Status]. */ - 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 situationIds: 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 vehicleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(status: Status) = apply { - activeTripId = status.activeTripId - blockTripSequence = status.blockTripSequence - closestStop = status.closestStop - distanceAlongTrip = status.distanceAlongTrip - lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - lastLocationUpdateTime = status.lastLocationUpdateTime - lastUpdateTime = status.lastUpdateTime - occupancyCapacity = status.occupancyCapacity - occupancyCount = status.occupancyCount - occupancyStatus = status.occupancyStatus - phase = status.phase - predicted = status.predicted - scheduleDeviation = status.scheduleDeviation - serviceDate = status.serviceDate - this.status = status.status - totalDistanceAlongTrip = status.totalDistanceAlongTrip - closestStopTimeOffset = status.closestStopTimeOffset - frequency = status.frequency - lastKnownLocation = status.lastKnownLocation - lastKnownOrientation = status.lastKnownOrientation - nextStop = status.nextStop - nextStopTimeOffset = status.nextStopTimeOffset - orientation = status.orientation - position = status.position - scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - situationIds = status.situationIds.map { it.toMutableList() } - vehicleId = status.vehicleId - additionalProperties = status.additionalProperties.toMutableMap() - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - 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)) - - /** Index of the active trip into the sequence of trips for the active block. */ - 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)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - 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)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - 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)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - 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)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - 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)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - 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)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = - apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - 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)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - 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)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - 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. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - 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)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - 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)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** References to situation elements (if any) applicable to this trip. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - 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) - } - - fun build(): Status = - Status( - 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), - (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, - checkRequired("status", status), - checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), - closestStopTimeOffset, - frequency, - lastKnownLocation, - lastKnownOrientation, - nextStop, - nextStopTimeOffset, - orientation, - position, - scheduledDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @NoAutoDetect - class LastKnownLocation - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LastKnownLocation = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the last known location of the transit vehicle. */ - 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)) - - /** Longitude of the last known location of the transit vehicle. */ - 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) - } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @NoAutoDetect - class Position - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Position = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the current position of the transit vehicle. */ - 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)) - - /** Longitude of the current position of the transit vehicle. */ - 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) - } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is Status && 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Status{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 /* spotless:off */ other is List && schedule == other.schedule && status == other.status && tripId == other.tripId && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(schedule, status, tripId, frequency, serviceDate, situationIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "List{schedule=$schedule, status=$status, tripId=$tripId, frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TripsForLocationListResponse{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/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt deleted file mode 100644 index 700dcd3..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListResponse.kt +++ /dev/null @@ -1,2031 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class TripsForRouteListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): TripsForRouteListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TripsForRouteListResponse]. */ - 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(tripsForRouteListResponse: TripsForRouteListResponse) = apply { - code = tripsForRouteListResponse.code - currentTime = tripsForRouteListResponse.currentTime - text = tripsForRouteListResponse.text - version = tripsForRouteListResponse.version - data = tripsForRouteListResponse.data - additionalProperties = tripsForRouteListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): TripsForRouteListResponse = - TripsForRouteListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun list(): kotlin.collections.List = list.getRequired("list") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** 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 additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded - list = data.list.map { it.toMutableList() } - references = data.references - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("limitExceeded", limitExceeded), - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("schedule") - @ExcludeMissing - private val schedule: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun schedule(): Schedule = schedule.getRequired("schedule") - - fun status(): Status = status.getRequired("status") - - fun tripId(): String = tripId.getRequired("tripId") - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - fun serviceDate(): Optional = - Optional.ofNullable(serviceDate.getNullable("serviceDate")) - - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - @JsonProperty("schedule") - @ExcludeMissing - fun _schedule(): JsonField = schedule - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - schedule().validate() - status().validate() - tripId() - frequency() - serviceDate() - situationIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal constructor() { - - private var schedule: JsonField? = null - private var status: JsonField? = null - private var tripId: JsonField? = null - private var frequency: JsonField = JsonMissing.of() - private var serviceDate: JsonField = JsonMissing.of() - private var situationIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - schedule = list.schedule - status = list.status - tripId = list.tripId - frequency = list.frequency - serviceDate = list.serviceDate - situationIds = list.situationIds.map { it.toMutableList() } - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) - - fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) - - fun frequency(frequency: JsonField) = apply { this.frequency = frequency } - - fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) - - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - fun situationIds(situationIds: JsonField>) = apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): List = - List( - checkRequired("schedule", schedule), - checkRequired("status", status), - checkRequired("tripId", tripId), - frequency, - serviceDate, - (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Schedule - @JsonCreator - private constructor( - @JsonProperty("nextTripId") - @ExcludeMissing - private val nextTripId: JsonField = JsonMissing.of(), - @JsonProperty("previousTripId") - @ExcludeMissing - private val previousTripId: JsonField = JsonMissing.of(), - @JsonProperty("stopTimes") - @ExcludeMissing - private val stopTimes: JsonField> = - JsonMissing.of(), - @JsonProperty("timeZone") - @ExcludeMissing - private val timeZone: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun nextTripId(): String = nextTripId.getRequired("nextTripId") - - fun previousTripId(): String = previousTripId.getRequired("previousTripId") - - fun stopTimes(): kotlin.collections.List = - stopTimes.getRequired("stopTimes") - - fun timeZone(): String = timeZone.getRequired("timeZone") - - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - @JsonProperty("nextTripId") - @ExcludeMissing - fun _nextTripId(): JsonField = nextTripId - - @JsonProperty("previousTripId") - @ExcludeMissing - fun _previousTripId(): JsonField = previousTripId - - @JsonProperty("stopTimes") - @ExcludeMissing - fun _stopTimes(): JsonField> = stopTimes - - @JsonProperty("timeZone") - @ExcludeMissing - fun _timeZone(): JsonField = timeZone - - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Schedule = apply { - if (validated) { - return@apply - } - - nextTripId() - previousTripId() - stopTimes().forEach { it.validate() } - timeZone() - frequency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Schedule]. */ - class Builder internal constructor() { - - private var nextTripId: JsonField? = null - private var previousTripId: JsonField? = null - private var stopTimes: JsonField>? = null - private var timeZone: JsonField? = null - private var frequency: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - nextTripId = schedule.nextTripId - previousTripId = schedule.previousTripId - stopTimes = schedule.stopTimes.map { it.toMutableList() } - timeZone = schedule.timeZone - frequency = schedule.frequency - additionalProperties = schedule.additionalProperties.toMutableMap() - } - - fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) - - fun nextTripId(nextTripId: JsonField) = apply { - this.nextTripId = nextTripId - } - - fun previousTripId(previousTripId: String) = - previousTripId(JsonField.of(previousTripId)) - - fun previousTripId(previousTripId: JsonField) = apply { - this.previousTripId = previousTripId - } - - fun stopTimes(stopTimes: kotlin.collections.List) = - stopTimes(JsonField.of(stopTimes)) - - fun stopTimes(stopTimes: JsonField>) = apply { - this.stopTimes = stopTimes.map { it.toMutableList() } - } - - fun addStopTime(stopTime: StopTime) = apply { - stopTimes = - (stopTimes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopTime) - } - } - - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) - - fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } - - fun frequency(frequency: String?) = frequency(JsonField.ofNullable(frequency)) - - fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) - - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - 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) - } - - fun build(): Schedule = - Schedule( - checkRequired("nextTripId", nextTripId), - checkRequired("previousTripId", previousTripId), - checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, - checkRequired("timeZone", timeZone), - frequency, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class StopTime - @JsonCreator - private constructor( - @JsonProperty("arrivalTime") - @ExcludeMissing - private val arrivalTime: JsonField = JsonMissing.of(), - @JsonProperty("departureTime") - @ExcludeMissing - private val departureTime: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("historicalOccupancy") - @ExcludeMissing - private val historicalOccupancy: JsonField = JsonMissing.of(), - @JsonProperty("stopHeadsign") - @ExcludeMissing - private val stopHeadsign: JsonField = JsonMissing.of(), - @JsonProperty("stopId") - @ExcludeMissing - private val stopId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun arrivalTime(): Optional = - Optional.ofNullable(arrivalTime.getNullable("arrivalTime")) - - fun departureTime(): Optional = - Optional.ofNullable(departureTime.getNullable("departureTime")) - - fun distanceAlongTrip(): Optional = - Optional.ofNullable(distanceAlongTrip.getNullable("distanceAlongTrip")) - - fun historicalOccupancy(): Optional = - Optional.ofNullable(historicalOccupancy.getNullable("historicalOccupancy")) - - fun stopHeadsign(): Optional = - Optional.ofNullable(stopHeadsign.getNullable("stopHeadsign")) - - fun stopId(): Optional = - Optional.ofNullable(stopId.getNullable("stopId")) - - @JsonProperty("arrivalTime") - @ExcludeMissing - fun _arrivalTime(): JsonField = arrivalTime - - @JsonProperty("departureTime") - @ExcludeMissing - fun _departureTime(): JsonField = departureTime - - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - @JsonProperty("historicalOccupancy") - @ExcludeMissing - fun _historicalOccupancy(): JsonField = historicalOccupancy - - @JsonProperty("stopHeadsign") - @ExcludeMissing - fun _stopHeadsign(): JsonField = stopHeadsign - - @JsonProperty("stopId") - @ExcludeMissing - fun _stopId(): JsonField = stopId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): StopTime = apply { - if (validated) { - return@apply - } - - arrivalTime() - departureTime() - distanceAlongTrip() - historicalOccupancy() - stopHeadsign() - stopId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StopTime]. */ - class Builder internal constructor() { - - private var arrivalTime: JsonField = JsonMissing.of() - private var departureTime: JsonField = JsonMissing.of() - private var distanceAlongTrip: JsonField = JsonMissing.of() - private var historicalOccupancy: JsonField = JsonMissing.of() - private var stopHeadsign: JsonField = JsonMissing.of() - private var stopId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(stopTime: StopTime) = apply { - arrivalTime = stopTime.arrivalTime - departureTime = stopTime.departureTime - distanceAlongTrip = stopTime.distanceAlongTrip - historicalOccupancy = stopTime.historicalOccupancy - stopHeadsign = stopTime.stopHeadsign - stopId = stopTime.stopId - additionalProperties = stopTime.additionalProperties.toMutableMap() - } - - fun arrivalTime(arrivalTime: Long) = arrivalTime(JsonField.of(arrivalTime)) - - fun arrivalTime(arrivalTime: JsonField) = apply { - this.arrivalTime = arrivalTime - } - - fun departureTime(departureTime: Long) = - departureTime(JsonField.of(departureTime)) - - fun departureTime(departureTime: JsonField) = apply { - this.departureTime = departureTime - } - - fun distanceAlongTrip(distanceAlongTrip: Double) = - distanceAlongTrip(JsonField.of(distanceAlongTrip)) - - fun distanceAlongTrip(distanceAlongTrip: JsonField) = apply { - this.distanceAlongTrip = distanceAlongTrip - } - - fun historicalOccupancy(historicalOccupancy: String) = - historicalOccupancy(JsonField.of(historicalOccupancy)) - - fun historicalOccupancy(historicalOccupancy: JsonField) = apply { - this.historicalOccupancy = historicalOccupancy - } - - fun stopHeadsign(stopHeadsign: String) = - stopHeadsign(JsonField.of(stopHeadsign)) - - fun stopHeadsign(stopHeadsign: JsonField) = apply { - this.stopHeadsign = stopHeadsign - } - - fun stopId(stopId: String) = stopId(JsonField.of(stopId)) - - 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) - } - - fun build(): StopTime = - StopTime( - arrivalTime, - departureTime, - distanceAlongTrip, - historicalOccupancy, - stopHeadsign, - stopId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Status - @JsonCreator - private constructor( - @JsonProperty("activeTripId") - @ExcludeMissing - private val activeTripId: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("closestStop") - @ExcludeMissing - private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCapacity") - @ExcludeMissing - private val occupancyCapacity: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCount") - @ExcludeMissing - private val occupancyCount: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDeviation") - @ExcludeMissing - private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = - JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun _activeTripId(): JsonField = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun _closestStop(): JsonField = closestStop - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity(): JsonField = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount(): JsonField = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation(): JsonField = scheduleDeviation - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation(): JsonField = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation(): JsonField = lastKnownOrientation - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun _nextStop(): JsonField = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun _orientation(): JsonField = orientation - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Status = 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 toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Status]. */ - 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(status: Status) = apply { - activeTripId = status.activeTripId - blockTripSequence = status.blockTripSequence - closestStop = status.closestStop - distanceAlongTrip = status.distanceAlongTrip - lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip - lastLocationUpdateTime = status.lastLocationUpdateTime - lastUpdateTime = status.lastUpdateTime - occupancyCapacity = status.occupancyCapacity - occupancyCount = status.occupancyCount - occupancyStatus = status.occupancyStatus - phase = status.phase - predicted = status.predicted - scheduleDeviation = status.scheduleDeviation - serviceDate = status.serviceDate - this.status = status.status - totalDistanceAlongTrip = status.totalDistanceAlongTrip - closestStopTimeOffset = status.closestStopTimeOffset - frequency = status.frequency - lastKnownLocation = status.lastKnownLocation - lastKnownOrientation = status.lastKnownOrientation - nextStop = status.nextStop - nextStopTimeOffset = status.nextStopTimeOffset - orientation = status.orientation - position = status.position - scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip - situationIds = status.situationIds.map { it.toMutableList() } - vehicleId = status.vehicleId - additionalProperties = status.additionalProperties.toMutableMap() - } - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(activeTripId: String) = - activeTripId(JsonField.of(activeTripId)) - - /** Trip ID of the trip the vehicle is actively serving. */ - 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)) - - /** Index of the active trip into the sequence of trips for the active block. */ - 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)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - 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)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - 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)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - 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)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - 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)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - 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)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - 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)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - 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)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - 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. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - 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)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - 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)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = - apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** References to situation elements (if any) applicable to this trip. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - 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) - } - - fun build(): Status = - Status( - 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.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @NoAutoDetect - class LastKnownLocation - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LastKnownLocation = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the last known location of the transit vehicle. */ - 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)) - - /** Longitude of the last known location of the transit vehicle. */ - 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) - } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @NoAutoDetect - class Position - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Position = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the current position of the transit vehicle. */ - 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)) - - /** Longitude of the current position of the transit vehicle. */ - 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) - } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ other is Status && 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Status{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 /* spotless:off */ other is List && schedule == other.schedule && status == other.status && tripId == other.tripId && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(schedule, status, tripId, frequency, serviceDate, situationIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "List{schedule=$schedule, status=$status, tripId=$tripId, frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TripsForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TripsForRouteListResponse{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/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt deleted file mode 100644 index 98ae4a2..0000000 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListResponse.kt +++ /dev/null @@ -1,1819 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -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.Objects -import java.util.Optional -import org.onebusaway.core.ExcludeMissing -import org.onebusaway.core.JsonField -import org.onebusaway.core.JsonMissing -import org.onebusaway.core.JsonValue -import org.onebusaway.core.NoAutoDetect -import org.onebusaway.core.checkRequired -import org.onebusaway.core.immutableEmptyMap -import org.onebusaway.core.toImmutable - -@NoAutoDetect -class VehiclesForAgencyListResponse -@JsonCreator -private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("currentTime") - @ExcludeMissing - private val currentTime: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun code(): Long = code.getRequired("code") - - fun currentTime(): Long = currentTime.getRequired("currentTime") - - fun text(): String = text.getRequired("text") - - fun version(): Long = version.getRequired("version") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime - - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toResponseWrapper(): ResponseWrapper = - ResponseWrapper.builder() - .code(code) - .currentTime(currentTime) - .text(text) - .version(version) - .build() - - private var validated: Boolean = false - - fun validate(): VehiclesForAgencyListResponse = apply { - if (validated) { - return@apply - } - - code() - currentTime() - text() - version() - data().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VehiclesForAgencyListResponse]. */ - 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(vehiclesForAgencyListResponse: VehiclesForAgencyListResponse) = apply { - code = vehiclesForAgencyListResponse.code - currentTime = vehiclesForAgencyListResponse.currentTime - text = vehiclesForAgencyListResponse.text - version = vehiclesForAgencyListResponse.version - data = vehiclesForAgencyListResponse.data - additionalProperties = vehiclesForAgencyListResponse.additionalProperties.toMutableMap() - } - - fun code(code: Long) = code(JsonField.of(code)) - - fun code(code: JsonField) = apply { this.code = code } - - fun currentTime(currentTime: Long) = currentTime(JsonField.of(currentTime)) - - fun currentTime(currentTime: JsonField) = apply { this.currentTime = currentTime } - - fun text(text: String) = text(JsonField.of(text)) - - fun text(text: JsonField) = apply { this.text = text } - - fun version(version: Long) = version(JsonField.of(version)) - - fun version(version: JsonField) = apply { this.version = version } - - fun data(data: Data) = data(JsonField.of(data)) - - 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) - } - - fun build(): VehiclesForAgencyListResponse = - VehiclesForAgencyListResponse( - checkRequired("code", code), - checkRequired("currentTime", currentTime), - checkRequired("text", text), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("list") - @ExcludeMissing - private val list: JsonField> = JsonMissing.of(), - @JsonProperty("limitExceeded") - @ExcludeMissing - private val limitExceeded: JsonField = JsonMissing.of(), - @JsonProperty("references") - @ExcludeMissing - private val references: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - fun list(): kotlin.collections.List = list.getRequired("list") - - fun limitExceeded(): Boolean = limitExceeded.getRequired("limitExceeded") - - fun references(): References = references.getRequired("references") - - @JsonProperty("limitExceeded") - @ExcludeMissing - fun _limitExceeded(): JsonField = limitExceeded - - @JsonProperty("list") - @ExcludeMissing - fun _list(): JsonField> = list - - @JsonProperty("references") - @ExcludeMissing - fun _references(): JsonField = references - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - limitExceeded() - list().forEach { it.validate() } - references().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var list: JsonField>? = null - private var limitExceeded: JsonField? = null - private var references: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - limitExceeded = data.limitExceeded - list = data.list.map { it.toMutableList() } - references = data.references - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun list(list: kotlin.collections.List) = list(JsonField.of(list)) - - fun list(list: JsonField>) = apply { - this.list = list.map { it.toMutableList() } - } - - fun limitExceeded(limitExceeded: Boolean) = limitExceeded(JsonField.of(limitExceeded)) - - fun limitExceeded(limitExceeded: JsonField) = apply { - this.limitExceeded = limitExceeded - } - - fun addList(list: List) = apply { - this.list = - (this.list ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(list) - } - } - - fun references(references: References) = references(JsonField.of(references)) - - 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) - } - - fun build(): Data = - Data( - checkRequired("list", list).map { it.toImmutable() }, - checkRequired("limitExceeded", limitExceeded), - checkRequired("references", references), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class List - @JsonCreator - private constructor( - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("tripId") - @ExcludeMissing - private val tripId: JsonField = JsonMissing.of(), - @JsonProperty("tripStatus") - @ExcludeMissing - private val tripStatus: JsonField = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCapacity") - @ExcludeMissing - private val occupancyCapacity: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCount") - @ExcludeMissing - private val occupancyCount: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - fun location(): Location = location.getRequired("location") - - fun tripId(): String = tripId.getRequired("tripId") - - fun tripStatus(): TripStatus = tripStatus.getRequired("tripStatus") - - fun vehicleId(): String = vehicleId.getRequired("vehicleId") - - fun occupancyCapacity(): Optional = - Optional.ofNullable(occupancyCapacity.getNullable("occupancyCapacity")) - - fun occupancyCount(): Optional = - Optional.ofNullable(occupancyCount.getNullable("occupancyCount")) - - fun occupancyStatus(): Optional = - Optional.ofNullable(occupancyStatus.getNullable("occupancyStatus")) - - fun phase(): Optional = Optional.ofNullable(phase.getNullable("phase")) - - fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - @JsonProperty("location") - @ExcludeMissing - fun _location(): JsonField = location - - @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId - - @JsonProperty("tripStatus") - @ExcludeMissing - fun _tripStatus(): JsonField = tripStatus - - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity(): JsonField = occupancyCapacity - - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount(): JsonField = occupancyCount - - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - lastLocationUpdateTime() - lastUpdateTime() - location().validate() - tripId() - tripStatus().validate() - vehicleId() - occupancyCapacity() - occupancyCount() - occupancyStatus() - phase() - status() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal 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 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 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 - occupancyCapacity = list.occupancyCapacity - occupancyCount = list.occupancyCount - occupancyStatus = list.occupancyStatus - phase = list.phase - status = list.status - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun lastLocationUpdateTime(lastLocationUpdateTime: Long) = - lastLocationUpdateTime(JsonField.of(lastLocationUpdateTime)) - - fun lastLocationUpdateTime(lastLocationUpdateTime: JsonField) = apply { - this.lastLocationUpdateTime = lastLocationUpdateTime - } - - fun lastUpdateTime(lastUpdateTime: Long) = - lastUpdateTime(JsonField.of(lastUpdateTime)) - - fun lastUpdateTime(lastUpdateTime: JsonField) = apply { - this.lastUpdateTime = lastUpdateTime - } - - fun location(location: Location) = location(JsonField.of(location)) - - fun location(location: JsonField) = apply { this.location = location } - - fun tripId(tripId: String) = tripId(JsonField.of(tripId)) - - fun tripId(tripId: JsonField) = apply { this.tripId = tripId } - - fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) - - fun tripStatus(tripStatus: JsonField) = apply { - this.tripStatus = tripStatus - } - - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - fun vehicleId(vehicleId: JsonField) = apply { this.vehicleId = vehicleId } - - fun occupancyCapacity(occupancyCapacity: Long) = - occupancyCapacity(JsonField.of(occupancyCapacity)) - - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - fun phase(phase: String) = phase(JsonField.of(phase)) - - fun phase(phase: JsonField) = apply { this.phase = phase } - - fun status(status: String) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - 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) - } - - fun build(): List = - List( - checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), - checkRequired("lastUpdateTime", lastUpdateTime), - checkRequired("location", location), - checkRequired("tripId", tripId), - checkRequired("tripStatus", tripStatus), - checkRequired("vehicleId", vehicleId), - occupancyCapacity, - occupancyCount, - occupancyStatus, - phase, - status, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Location - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Location = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Location]. */ - 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(location: Location) = apply { - lat = location.lat - lon = location.lon - additionalProperties = location.additionalProperties.toMutableMap() - } - - fun lat(lat: Double) = lat(JsonField.of(lat)) - - fun lat(lat: JsonField) = apply { this.lat = lat } - - fun lon(lon: Double) = lon(JsonField.of(lon)) - - 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) - } - - fun build(): Location = - Location( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Location && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Location{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class TripStatus - @JsonCreator - private constructor( - @JsonProperty("activeTripId") - @ExcludeMissing - private val activeTripId: JsonField = JsonMissing.of(), - @JsonProperty("blockTripSequence") - @ExcludeMissing - private val blockTripSequence: JsonField = JsonMissing.of(), - @JsonProperty("closestStop") - @ExcludeMissing - private val closestStop: JsonField = JsonMissing.of(), - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - private val distanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - private val lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - private val lastLocationUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("lastUpdateTime") - @ExcludeMissing - private val lastUpdateTime: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCapacity") - @ExcludeMissing - private val occupancyCapacity: JsonField = JsonMissing.of(), - @JsonProperty("occupancyCount") - @ExcludeMissing - private val occupancyCount: JsonField = JsonMissing.of(), - @JsonProperty("occupancyStatus") - @ExcludeMissing - private val occupancyStatus: JsonField = JsonMissing.of(), - @JsonProperty("phase") - @ExcludeMissing - private val phase: JsonField = JsonMissing.of(), - @JsonProperty("predicted") - @ExcludeMissing - private val predicted: JsonField = JsonMissing.of(), - @JsonProperty("scheduleDeviation") - @ExcludeMissing - private val scheduleDeviation: JsonField = JsonMissing.of(), - @JsonProperty("serviceDate") - @ExcludeMissing - private val serviceDate: JsonField = JsonMissing.of(), - @JsonProperty("situationIds") - @ExcludeMissing - private val situationIds: JsonField> = - JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - private val totalDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - private val closestStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - private val frequency: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownLocation") - @ExcludeMissing - private val lastKnownLocation: JsonField = JsonMissing.of(), - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - private val lastKnownOrientation: JsonField = JsonMissing.of(), - @JsonProperty("nextStop") - @ExcludeMissing - private val nextStop: JsonField = JsonMissing.of(), - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - private val nextStopTimeOffset: JsonField = JsonMissing.of(), - @JsonProperty("orientation") - @ExcludeMissing - private val orientation: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - private val scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), - @JsonProperty("vehicleId") - @ExcludeMissing - private val vehicleId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Trip ID of the trip the vehicle is actively serving. */ - fun activeTripId(): String = activeTripId.getRequired("activeTripId") - - /** Index of the active trip into the sequence of trips for the active block. */ - fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") - - /** ID of the closest stop to the current location of the transit vehicle. */ - fun closestStop(): String = closestStop.getRequired("closestStop") - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - fun lastKnownDistanceAlongTrip(): Double = - lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - fun lastLocationUpdateTime(): Long = - lastLocationUpdateTime.getRequired("lastLocationUpdateTime") - - /** Timestamp of the last known real-time update from the transit vehicle. */ - fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") - - /** Current journey phase of the trip. */ - fun phase(): String = phase.getRequired("phase") - - /** Indicates if real-time arrival info is available for this trip. */ - fun predicted(): Boolean = predicted.getRequired("predicted") - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - 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. - */ - fun serviceDate(): Long = serviceDate.getRequired("serviceDate") - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(): Optional> = - Optional.ofNullable(situationIds.getNullable("situationIds")) - - /** Current status modifiers for the trip. */ - fun status(): String = status.getRequired("status") - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(): Double = - totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - fun closestStopTimeOffset(): Optional = - Optional.ofNullable(closestStopTimeOffset.getNullable("closestStopTimeOffset")) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(): Optional = - Optional.ofNullable(frequency.getNullable("frequency")) - - /** Last known location of the transit vehicle. */ - fun lastKnownLocation(): Optional = - Optional.ofNullable(lastKnownLocation.getNullable("lastKnownLocation")) - - /** Last known orientation value received in real-time from the transit vehicle. */ - fun lastKnownOrientation(): Optional = - Optional.ofNullable(lastKnownOrientation.getNullable("lastKnownOrientation")) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - fun nextStop(): Optional = - Optional.ofNullable(nextStop.getNullable("nextStop")) - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - fun nextStopTimeOffset(): Optional = - Optional.ofNullable(nextStopTimeOffset.getNullable("nextStopTimeOffset")) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(): Optional = - Optional.ofNullable(orientation.getNullable("orientation")) - - /** Current position of the transit vehicle. */ - fun position(): Optional = - Optional.ofNullable(position.getNullable("position")) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - fun scheduledDistanceAlongTrip(): Optional = - Optional.ofNullable( - scheduledDistanceAlongTrip.getNullable("scheduledDistanceAlongTrip") - ) - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(): Optional = - Optional.ofNullable(vehicleId.getNullable("vehicleId")) - - /** Trip ID of the trip the vehicle is actively serving. */ - @JsonProperty("activeTripId") - @ExcludeMissing - fun _activeTripId(): JsonField = activeTripId - - /** Index of the active trip into the sequence of trips for the active block. */ - @JsonProperty("blockTripSequence") - @ExcludeMissing - fun _blockTripSequence(): JsonField = blockTripSequence - - /** ID of the closest stop to the current location of the transit vehicle. */ - @JsonProperty("closestStop") - @ExcludeMissing - fun _closestStop(): JsonField = closestStop - - /** - * Distance, in meters, the transit vehicle has progressed along the active trip. - */ - @JsonProperty("distanceAlongTrip") - @ExcludeMissing - fun _distanceAlongTrip(): JsonField = distanceAlongTrip - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - @JsonProperty("lastKnownDistanceAlongTrip") - @ExcludeMissing - fun _lastKnownDistanceAlongTrip(): JsonField = lastKnownDistanceAlongTrip - - /** - * Timestamp of the last known real-time location update from the transit vehicle. - */ - @JsonProperty("lastLocationUpdateTime") - @ExcludeMissing - fun _lastLocationUpdateTime(): JsonField = lastLocationUpdateTime - - /** Timestamp of the last known real-time update from the transit vehicle. */ - @JsonProperty("lastUpdateTime") - @ExcludeMissing - fun _lastUpdateTime(): JsonField = lastUpdateTime - - /** Capacity of the transit vehicle in terms of occupancy. */ - @JsonProperty("occupancyCapacity") - @ExcludeMissing - fun _occupancyCapacity(): JsonField = occupancyCapacity - - /** Current count of occupants in the transit vehicle. */ - @JsonProperty("occupancyCount") - @ExcludeMissing - fun _occupancyCount(): JsonField = occupancyCount - - /** Current occupancy status of the transit vehicle. */ - @JsonProperty("occupancyStatus") - @ExcludeMissing - fun _occupancyStatus(): JsonField = occupancyStatus - - /** Current journey phase of the trip. */ - @JsonProperty("phase") @ExcludeMissing fun _phase(): JsonField = phase - - /** Indicates if real-time arrival info is available for this trip. */ - @JsonProperty("predicted") - @ExcludeMissing - fun _predicted(): JsonField = predicted - - /** - * Deviation from the schedule in seconds (positive for late, negative for early). - */ - @JsonProperty("scheduleDeviation") - @ExcludeMissing - fun _scheduleDeviation(): JsonField = scheduleDeviation - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - @JsonProperty("serviceDate") - @ExcludeMissing - fun _serviceDate(): JsonField = serviceDate - - /** Current status modifiers for the trip. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** Total length of the trip, in meters. */ - @JsonProperty("totalDistanceAlongTrip") - @ExcludeMissing - fun _totalDistanceAlongTrip(): JsonField = totalDistanceAlongTrip - - /** - * Time offset from the closest stop to the current position of the transit vehicle - * (in seconds). - */ - @JsonProperty("closestStopTimeOffset") - @ExcludeMissing - fun _closestStopTimeOffset(): JsonField = closestStopTimeOffset - - /** Information about frequency-based scheduling, if applicable to the trip. */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** Last known location of the transit vehicle. */ - @JsonProperty("lastKnownLocation") - @ExcludeMissing - fun _lastKnownLocation(): JsonField = lastKnownLocation - - /** Last known orientation value received in real-time from the transit vehicle. */ - @JsonProperty("lastKnownOrientation") - @ExcludeMissing - fun _lastKnownOrientation(): JsonField = lastKnownOrientation - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - @JsonProperty("nextStop") - @ExcludeMissing - fun _nextStop(): JsonField = nextStop - - /** - * Time offset from the next stop to the current position of the transit vehicle (in - * seconds). - */ - @JsonProperty("nextStopTimeOffset") - @ExcludeMissing - fun _nextStopTimeOffset(): JsonField = nextStopTimeOffset - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - @JsonProperty("orientation") - @ExcludeMissing - fun _orientation(): JsonField = orientation - - /** Current position of the transit vehicle. */ - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed along - * the active trip. - */ - @JsonProperty("scheduledDistanceAlongTrip") - @ExcludeMissing - fun _scheduledDistanceAlongTrip(): JsonField = scheduledDistanceAlongTrip - - /** References to situation elements (if any) applicable to this trip. */ - @JsonProperty("situationIds") - @ExcludeMissing - fun _situationIds(): JsonField> = situationIds - - /** ID of the transit vehicle currently serving the trip. */ - @JsonProperty("vehicleId") - @ExcludeMissing - fun _vehicleId(): JsonField = vehicleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - 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 toBuilder() = Builder().from(this) - - companion object { - - @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 situationIds: 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 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)) - - /** Trip ID of the trip the vehicle is actively serving. */ - 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)) - - /** Index of the active trip into the sequence of trips for the active block. */ - 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)) - - /** ID of the closest stop to the current location of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle has progressed along the active - * trip. - */ - 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)) - - /** - * Last known distance along the trip received in real-time from the transit - * vehicle. - */ - 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)) - - /** - * Timestamp of the last known real-time location update from the transit - * vehicle. - */ - 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)) - - /** Timestamp of the last known real-time update from the transit vehicle. */ - 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)) - - /** Capacity of the transit vehicle in terms of occupancy. */ - fun occupancyCapacity(occupancyCapacity: JsonField) = apply { - this.occupancyCapacity = occupancyCapacity - } - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: Long) = - occupancyCount(JsonField.of(occupancyCount)) - - /** Current count of occupants in the transit vehicle. */ - fun occupancyCount(occupancyCount: JsonField) = apply { - this.occupancyCount = occupancyCount - } - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: String) = - occupancyStatus(JsonField.of(occupancyStatus)) - - /** Current occupancy status of the transit vehicle. */ - fun occupancyStatus(occupancyStatus: JsonField) = apply { - this.occupancyStatus = occupancyStatus - } - - /** Current journey phase of the trip. */ - fun phase(phase: String) = phase(JsonField.of(phase)) - - /** Current journey phase of the trip. */ - 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)) - - /** Indicates if real-time arrival info is available for this trip. */ - 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)) - - /** - * Deviation from the schedule in seconds (positive for late, negative for - * early). - */ - 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)) - - /** - * Time, in milliseconds since the Unix epoch, of midnight for the start of the - * service date for the trip. - */ - fun serviceDate(serviceDate: JsonField) = apply { - this.serviceDate = serviceDate - } - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: kotlin.collections.List) = - situationIds(JsonField.of(situationIds)) - - /** References to situation elements (if any) applicable to this trip. */ - fun situationIds(situationIds: JsonField>) = - apply { - this.situationIds = situationIds.map { it.toMutableList() } - } - - /** Current status modifiers for the trip. */ - fun status(status: String) = status(JsonField.of(status)) - - /** Current status modifiers for the trip. */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total length of the trip, in meters. */ - fun totalDistanceAlongTrip(totalDistanceAlongTrip: Double) = - totalDistanceAlongTrip(JsonField.of(totalDistanceAlongTrip)) - - /** Total length of the trip, in meters. */ - 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)) - - /** - * Time offset from the closest stop to the current position of the transit - * vehicle (in seconds). - */ - 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)) - - /** Information about frequency-based scheduling, if applicable to the trip. */ - fun frequency(frequency: JsonField) = apply { - 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. */ - 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)) - - /** - * Last known orientation value received in real-time from the transit vehicle. - */ - 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)) - - /** ID of the next stop the transit vehicle is scheduled to arrive at. */ - 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)) - - /** - * Time offset from the next stop to the current position of the transit vehicle - * (in seconds). - */ - 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)) - - /** Orientation of the transit vehicle, represented as an angle in degrees. */ - fun orientation(orientation: JsonField) = apply { - this.orientation = orientation - } - - /** Current position of the transit vehicle. */ - fun position(position: Position) = position(JsonField.of(position)) - - /** Current position of the transit vehicle. */ - 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)) - - /** - * Distance, in meters, the transit vehicle is scheduled to have progressed - * along the active trip. - */ - fun scheduledDistanceAlongTrip(scheduledDistanceAlongTrip: JsonField) = - apply { - this.scheduledDistanceAlongTrip = scheduledDistanceAlongTrip - } - - /** References to situation elements (if any) applicable to this trip. */ - fun addSituationId(situationId: String) = apply { - situationIds = - (situationIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(situationId) - } - } - - /** ID of the transit vehicle currently serving the trip. */ - fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) - - /** ID of the transit vehicle currently serving the trip. */ - 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) - } - - 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), - (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, - checkRequired("status", status), - checkRequired("totalDistanceAlongTrip", totalDistanceAlongTrip), - closestStopTimeOffset, - frequency, - lastKnownLocation, - lastKnownOrientation, - nextStop, - nextStopTimeOffset, - orientation, - position, - scheduledDistanceAlongTrip, - vehicleId, - additionalProperties.toImmutable(), - ) - } - - /** Last known location of the transit vehicle. */ - @NoAutoDetect - class LastKnownLocation - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the last known location of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the last known location of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the last known location of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the last known location of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LastKnownLocation = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the last known location of the transit vehicle. */ - 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)) - - /** Longitude of the last known location of the transit vehicle. */ - 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) - } - - fun build(): LastKnownLocation = - LastKnownLocation( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" - } - - /** Current position of the transit vehicle. */ - @NoAutoDetect - class Position - @JsonCreator - private constructor( - @JsonProperty("lat") - @ExcludeMissing - private val lat: JsonField = JsonMissing.of(), - @JsonProperty("lon") - @ExcludeMissing - private val lon: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Latitude of the current position of the transit vehicle. */ - fun lat(): Optional = Optional.ofNullable(lat.getNullable("lat")) - - /** Longitude of the current position of the transit vehicle. */ - fun lon(): Optional = Optional.ofNullable(lon.getNullable("lon")) - - /** Latitude of the current position of the transit vehicle. */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** Longitude of the current position of the transit vehicle. */ - @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Position = apply { - if (validated) { - return@apply - } - - lat() - lon() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** Latitude of the current position of the transit vehicle. */ - 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)) - - /** Longitude of the current position of the transit vehicle. */ - 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) - } - - fun build(): Position = - Position( - lat, - lon, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } - /* spotless:on */ - - 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 /* spotless:off */ 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 /* spotless:on */ - } - - /* spotless:off */ - 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) } - /* spotless:on */ - - 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 /* spotless:off */ other is List && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && location == other.location && tripId == other.tripId && tripStatus == other.tripStatus && vehicleId == other.vehicleId && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(lastLocationUpdateTime, lastUpdateTime, location, tripId, tripStatus, vehicleId, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, additionalProperties) } - /* spotless:on */ - - 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}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VehiclesForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VehiclesForAgencyListResponse{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/AgenciesWithCoverageListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParams.kt similarity index 92% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParams.kt index ed0199c..be2370c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgenciesWithCoverageListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParams.kt @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.agencieswithcoverage import java.util.Objects -import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.Params import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams @@ -22,19 +21,20 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): AgenciesWithCoverageListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [AgenciesWithCoverageListParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [AgenciesWithCoverageListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() @@ -144,10 +144,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AgenciesWithCoverageListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): AgenciesWithCoverageListParams = AgenciesWithCoverageListParams(additionalHeaders.build(), additionalQueryParams.build()) } + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..a0ae167 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt @@ -0,0 +1,876 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agencieswithcoverage + +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 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 AgenciesWithCoverageListResponse +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 + * [AgenciesWithCoverageListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgenciesWithCoverageListResponse]. */ + 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(agenciesWithCoverageListResponse: AgenciesWithCoverageListResponse) = + apply { + code = agenciesWithCoverageListResponse.code + currentTime = agenciesWithCoverageListResponse.currentTime + text = agenciesWithCoverageListResponse.text + version = agenciesWithCoverageListResponse.version + data = agenciesWithCoverageListResponse.data + additionalProperties = + agenciesWithCoverageListResponse.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 [AgenciesWithCoverageListResponse]. + * + * 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(): AgenciesWithCoverageListResponse = + AgenciesWithCoverageListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AgenciesWithCoverageListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: 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") + + /** + * @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") + + /** + * 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 + + @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 + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val agencyId: JsonField, + private val lat: JsonField, + private val latSpan: JsonField, + private val lon: JsonField, + private val lonSpan: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("latSpan") + @ExcludeMissing + latSpan: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("lonSpan") + @ExcludeMissing + lonSpan: JsonField = JsonMissing.of(), + ) : this(agencyId, lat, latSpan, lon, lonSpan, 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 agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @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 latSpan(): Double = latSpan.getRequired("latSpan") + + /** + * @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 lonSpan(): Double = lonSpan.getRequired("lonSpan") + + /** + * Returns the raw JSON value of [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * 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 [latSpan]. + * + * Unlike [latSpan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latSpan") @ExcludeMissing fun _latSpan(): JsonField = latSpan + + /** + * 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 [lonSpan]. + * + * Unlike [lonSpan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lonSpan") @ExcludeMissing fun _lonSpan(): JsonField = lonSpan + + @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 + * .agencyId() + * .lat() + * .latSpan() + * .lon() + * .lonSpan() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var agencyId: JsonField? = null + private var lat: JsonField? = null + private var latSpan: JsonField? = null + private var lon: JsonField? = null + private var lonSpan: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + agencyId = list.agencyId + lat = list.lat + latSpan = list.latSpan + lon = list.lon + lonSpan = list.lonSpan + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + 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 latSpan(latSpan: Double) = latSpan(JsonField.of(latSpan)) + + /** + * Sets [Builder.latSpan] to an arbitrary JSON value. + * + * You should usually call [Builder.latSpan] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun latSpan(latSpan: JsonField) = apply { this.latSpan = latSpan } + + 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 lonSpan(lonSpan: Double) = lonSpan(JsonField.of(lonSpan)) + + /** + * Sets [Builder.lonSpan] to an arbitrary JSON value. + * + * You should usually call [Builder.lonSpan] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lonSpan(lonSpan: JsonField) = apply { this.lonSpan = lonSpan } + + 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 + * .agencyId() + * .lat() + * .latSpan() + * .lon() + * .lonSpan() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("agencyId", agencyId), + checkRequired("lat", lat), + checkRequired("latSpan", latSpan), + checkRequired("lon", lon), + checkRequired("lonSpan", lonSpan), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + agencyId() + lat() + latSpan() + lon() + lonSpan() + 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 (agencyId.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (latSpan.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (lonSpan.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && agencyId == other.agencyId && lat == other.lat && latSpan == other.latSpan && lon == other.lon && lonSpan == other.lonSpan && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(agencyId, lat, latSpan, lon, lonSpan, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{agencyId=$agencyId, lat=$lat, latSpan=$latSpan, lon=$lon, lonSpan=$lonSpan, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AgenciesWithCoverageListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgenciesWithCoverageListResponse{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/AgencyRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveParams.kt similarity index 85% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveParams.kt index 3dbe375..e36ef5a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/AgencyRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveParams.kt @@ -1,48 +1,39 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.agency import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Retrieve information for a specific transit agency identified by its unique ID. */ class AgencyRetrieveParams private constructor( - private val agencyId: String, + private val agencyId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun agencyId(): String = agencyId + fun agencyId(): Optional = Optional.ofNullable(agencyId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): AgencyRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AgencyRetrieveParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [AgencyRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var agencyId: String? = null @@ -56,7 +47,10 @@ private constructor( additionalQueryParams = agencyRetrieveParams.additionalQueryParams.toBuilder() } - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun agencyId(agencyId: String?) = apply { this.agencyId = agencyId } + + /** Alias for calling [Builder.agencyId] with `agencyId.orElse(null)`. */ + fun agencyId(agencyId: Optional) = agencyId(agencyId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +150,25 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AgencyRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): AgencyRetrieveParams = - AgencyRetrieveParams( - checkRequired("agencyId", agencyId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + AgencyRetrieveParams(agencyId, additionalHeaders.build(), additionalQueryParams.build()) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> agencyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..7211fe4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt @@ -0,0 +1,1031 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agency + +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.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class AgencyRetrieveResponse +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 [AgencyRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgencyRetrieveResponse]. */ + 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(agencyRetrieveResponse: AgencyRetrieveResponse) = apply { + code = agencyRetrieveResponse.code + currentTime = agencyRetrieveResponse.currentTime + text = agencyRetrieveResponse.text + version = agencyRetrieveResponse.version + data = agencyRetrieveResponse.data + additionalProperties = agencyRetrieveResponse.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 [AgencyRetrieveResponse]. + * + * 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(): AgencyRetrieveResponse = + AgencyRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AgencyRetrieveResponse = 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 + private constructor( + private val entry: JsonField, + private val limitExceeded: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @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()) + + /** + * @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 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 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 [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]. + * + * 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() + * .limitExceeded() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + 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() + } + + 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 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)) + + /** + * 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() + * .limitExceeded() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("limitExceeded", limitExceeded), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + limitExceeded() + 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) + + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + private constructor( + private val id: JsonField, + private val name: JsonField, + private val timezone: JsonField, + private val url: JsonField, + private val disclaimer: JsonField, + private val email: JsonField, + private val fareUrl: JsonField, + private val lang: JsonField, + private val phone: JsonField, + private val privateService: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + timezone: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("disclaimer") + @ExcludeMissing + disclaimer: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("fareUrl") + @ExcludeMissing + fareUrl: JsonField = JsonMissing.of(), + @JsonProperty("lang") @ExcludeMissing lang: JsonField = JsonMissing.of(), + @JsonProperty("phone") @ExcludeMissing phone: JsonField = JsonMissing.of(), + @JsonProperty("privateService") + @ExcludeMissing + privateService: JsonField = JsonMissing.of(), + ) : this( + id, + name, + timezone, + url, + disclaimer, + email, + fareUrl, + lang, + phone, + privateService, + 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 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 timezone(): String = timezone.getRequired("timezone") + + /** + * @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 url(): String = url.getRequired("url") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun disclaimer(): Optional = disclaimer.getOptional("disclaimer") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun fareUrl(): Optional = fareUrl.getOptional("fareUrl") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun lang(): Optional = lang.getOptional("lang") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun phone(): Optional = phone.getOptional("phone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun privateService(): Optional = privateService.getOptional("privateService") + + /** + * 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 [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [disclaimer]. + * + * Unlike [disclaimer], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("disclaimer") + @ExcludeMissing + fun _disclaimer(): JsonField = disclaimer + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [fareUrl]. + * + * Unlike [fareUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fareUrl") @ExcludeMissing fun _fareUrl(): JsonField = fareUrl + + /** + * Returns the raw JSON value of [lang]. + * + * Unlike [lang], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang + + /** + * Returns the raw JSON value of [phone]. + * + * Unlike [phone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone + + /** + * Returns the raw JSON value of [privateService]. + * + * Unlike [privateService], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("privateService") + @ExcludeMissing + fun _privateService(): JsonField = privateService + + @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 + * .id() + * .name() + * .timezone() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var timezone: JsonField? = null + private var url: JsonField? = null + private var disclaimer: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var fareUrl: JsonField = JsonMissing.of() + private var lang: JsonField = JsonMissing.of() + private var phone: JsonField = JsonMissing.of() + private var privateService: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + name = entry.name + timezone = entry.timezone + url = entry.url + disclaimer = entry.disclaimer + email = entry.email + fareUrl = entry.fareUrl + lang = entry.lang + phone = entry.phone + privateService = entry.privateService + additionalProperties = entry.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: 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 timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * 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 } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun disclaimer(disclaimer: String) = disclaimer(JsonField.of(disclaimer)) + + /** + * Sets [Builder.disclaimer] to an arbitrary JSON value. + * + * You should usually call [Builder.disclaimer] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun disclaimer(disclaimer: JsonField) = apply { + this.disclaimer = disclaimer + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun fareUrl(fareUrl: String) = fareUrl(JsonField.of(fareUrl)) + + /** + * Sets [Builder.fareUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.fareUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fareUrl(fareUrl: JsonField) = apply { this.fareUrl = fareUrl } + + fun lang(lang: String) = lang(JsonField.of(lang)) + + /** + * Sets [Builder.lang] to an arbitrary JSON value. + * + * You should usually call [Builder.lang] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lang(lang: JsonField) = apply { this.lang = lang } + + fun phone(phone: String) = phone(JsonField.of(phone)) + + /** + * Sets [Builder.phone] to an arbitrary JSON value. + * + * You should usually call [Builder.phone] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phone(phone: JsonField) = apply { this.phone = phone } + + fun privateService(privateService: Boolean) = + privateService(JsonField.of(privateService)) + + /** + * Sets [Builder.privateService] to an arbitrary JSON value. + * + * You should usually call [Builder.privateService] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun privateService(privateService: JsonField) = apply { + this.privateService = privateService + } + + 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 + * .id() + * .name() + * .timezone() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("timezone", timezone), + checkRequired("url", url), + disclaimer, + email, + fareUrl, + lang, + phone, + privateService, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + name() + timezone() + url() + disclaimer() + email() + fareUrl() + lang() + phone() + privateService() + 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 (name.asKnown().isPresent) 1 else 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (disclaimer.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (fareUrl.asKnown().isPresent) 1 else 0) + + (if (lang.asKnown().isPresent) 1 else 0) + + (if (phone.asKnown().isPresent) 1 else 0) + + (if (privateService.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && name == other.name && timezone == other.timezone && url == other.url && disclaimer == other.disclaimer && email == other.email && fareUrl == other.fareUrl && lang == other.lang && phone == other.phone && privateService == other.privateService && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, timezone, url, disclaimer, email, fareUrl, lang, phone, privateService, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, name=$name, timezone=$timezone, url=$url, disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, lang=$lang, phone=$phone, privateService=$privateService, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && limitExceeded == other.limitExceeded && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, limitExceeded, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, limitExceeded=$limitExceeded, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AgencyRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AgencyRetrieveResponse{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/ArrivalAndDepartureListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParams.kt similarity index 78% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParams.kt index 8264ee2..8a09c9b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParams.kt @@ -1,21 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.arrivalanddeparture import java.time.OffsetDateTime import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +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 /** arrivals-and-departures-for-stop */ class ArrivalAndDepartureListParams private constructor( - private val stopId: String, + private val stopId: String?, private val minutesAfter: Long?, private val minutesBefore: Long?, private val time: OffsetDateTime?, @@ -23,7 +22,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun stopId(): String = stopId + fun stopId(): Optional = Optional.ofNullable(stopId) /** Include vehicles arriving or departing in the next n minutes. */ fun minutesAfter(): Optional = Optional.ofNullable(minutesAfter) @@ -38,35 +37,20 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.minutesAfter?.let { queryParams.put("minutesAfter", listOf(it.toString())) } - this.minutesBefore?.let { queryParams.put("minutesBefore", listOf(it.toString())) } - this.time?.let { - queryParams.put("time", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): ArrivalAndDepartureListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalAndDepartureListParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [ArrivalAndDepartureListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var stopId: String? = null @@ -86,35 +70,42 @@ private constructor( additionalQueryParams = arrivalAndDepartureListParams.additionalQueryParams.toBuilder() } - fun stopId(stopId: String) = apply { this.stopId = stopId } + fun stopId(stopId: String?) = apply { this.stopId = stopId } + + /** Alias for calling [Builder.stopId] with `stopId.orElse(null)`. */ + fun stopId(stopId: Optional) = stopId(stopId.getOrNull()) /** Include vehicles arriving or departing in the next n minutes. */ fun minutesAfter(minutesAfter: Long?) = apply { this.minutesAfter = minutesAfter } - /** Include vehicles arriving or departing in the next n minutes. */ + /** + * Alias for [Builder.minutesAfter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun minutesAfter(minutesAfter: Long) = minutesAfter(minutesAfter as Long?) - /** Include vehicles arriving or departing in the next n minutes. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun minutesAfter(minutesAfter: Optional) = - minutesAfter(minutesAfter.orElse(null) as Long?) + /** Alias for calling [Builder.minutesAfter] with `minutesAfter.orElse(null)`. */ + fun minutesAfter(minutesAfter: Optional) = minutesAfter(minutesAfter.getOrNull()) /** Include vehicles having arrived or departed in the previous n minutes. */ fun minutesBefore(minutesBefore: Long?) = apply { this.minutesBefore = minutesBefore } - /** Include vehicles having arrived or departed in the previous n minutes. */ + /** + * Alias for [Builder.minutesBefore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun minutesBefore(minutesBefore: Long) = minutesBefore(minutesBefore as Long?) - /** Include vehicles having arrived or departed in the previous n minutes. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun minutesBefore(minutesBefore: Optional) = - minutesBefore(minutesBefore.orElse(null) as Long?) + /** Alias for calling [Builder.minutesBefore] with `minutesBefore.orElse(null)`. */ + fun minutesBefore(minutesBefore: Optional) = minutesBefore(minutesBefore.getOrNull()) /** The specific time for querying the system status. */ fun time(time: OffsetDateTime?) = apply { this.time = time } - /** The specific time for querying the system status. */ - fun time(time: Optional) = time(time.orElse(null)) + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -214,9 +205,14 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ArrivalAndDepartureListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ArrivalAndDepartureListParams = ArrivalAndDepartureListParams( - checkRequired("stopId", stopId), + stopId, minutesAfter, minutesBefore, time, @@ -225,6 +221,24 @@ private constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> stopId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + minutesAfter?.let { put("minutesAfter", it.toString()) } + minutesBefore?.let { put("minutesBefore", it.toString()) } + time?.let { put("time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..7ffbe8f --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt @@ -0,0 +1,4174 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +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 ArrivalAndDepartureListResponse +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 + * [ArrivalAndDepartureListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalAndDepartureListResponse]. */ + 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(arrivalAndDepartureListResponse: ArrivalAndDepartureListResponse) = + apply { + code = arrivalAndDepartureListResponse.code + currentTime = arrivalAndDepartureListResponse.currentTime + text = arrivalAndDepartureListResponse.text + version = arrivalAndDepartureListResponse.version + data = arrivalAndDepartureListResponse.data + additionalProperties = + arrivalAndDepartureListResponse.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 [ArrivalAndDepartureListResponse]. + * + * 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(): ArrivalAndDepartureListResponse = + ArrivalAndDepartureListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ArrivalAndDepartureListResponse = 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 + 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 + private constructor( + private val arrivalsAndDepartures: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalsAndDepartures") + @ExcludeMissing + arrivalsAndDepartures: JsonField> = JsonMissing.of() + ) : this(arrivalsAndDepartures, 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") + + /** + * 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 + + @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() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var arrivalsAndDepartures: JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + arrivalsAndDepartures = entry.arrivalsAndDepartures.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 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() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("arrivalsAndDepartures", arrivalsAndDepartures).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + arrivalsAndDepartures().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 = + (arrivalsAndDepartures.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ArrivalsAndDeparture + 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 + 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. + * + * @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. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * 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. */ + class LastKnownLocation + 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 /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + 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 /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + 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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + 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}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && arrivalsAndDepartures == other.arrivalsAndDepartures && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalsAndDepartures, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{arrivalsAndDepartures=$arrivalsAndDepartures, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is ArrivalAndDepartureListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ArrivalAndDepartureListResponse{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/ArrivalAndDepartureRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt similarity index 77% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt index 2ce93d0..2d86a66 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.arrivalanddeparture import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Params import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers @@ -13,7 +13,7 @@ import org.onebusaway.core.http.QueryParams /** arrival-and-departure-for-stop */ class ArrivalAndDepartureRetrieveParams private constructor( - private val stopId: String, + private val stopId: String?, private val serviceDate: Long, private val tripId: String, private val stopSequence: Long?, @@ -23,7 +23,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun stopId(): String = stopId + fun stopId(): Optional = Optional.ofNullable(stopId) fun serviceDate(): Long = serviceDate @@ -39,35 +39,24 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.serviceDate.let { queryParams.put("serviceDate", listOf(it.toString())) } - this.tripId.let { queryParams.put("tripId", listOf(it.toString())) } - this.stopSequence?.let { queryParams.put("stopSequence", listOf(it.toString())) } - this.time?.let { queryParams.put("time", listOf(it.toString())) } - this.vehicleId?.let { queryParams.put("vehicleId", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalAndDepartureRetrieveParams]. + * + * The following fields are required: + * ```java + * .serviceDate() + * .tripId() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [ArrivalAndDepartureRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var stopId: String? = null @@ -93,7 +82,10 @@ private constructor( arrivalAndDepartureRetrieveParams.additionalQueryParams.toBuilder() } - fun stopId(stopId: String) = apply { this.stopId = stopId } + fun stopId(stopId: String?) = apply { this.stopId = stopId } + + /** Alias for calling [Builder.stopId] with `stopId.orElse(null)`. */ + fun stopId(stopId: Optional) = stopId(stopId.getOrNull()) fun serviceDate(serviceDate: Long) = apply { this.serviceDate = serviceDate } @@ -101,22 +93,32 @@ private constructor( fun stopSequence(stopSequence: Long?) = apply { this.stopSequence = stopSequence } + /** + * Alias for [Builder.stopSequence]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun stopSequence(stopSequence: Long) = stopSequence(stopSequence as Long?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun stopSequence(stopSequence: Optional) = - stopSequence(stopSequence.orElse(null) as Long?) + /** Alias for calling [Builder.stopSequence] with `stopSequence.orElse(null)`. */ + fun stopSequence(stopSequence: Optional) = stopSequence(stopSequence.getOrNull()) 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?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun time(time: Optional) = time(time.orElse(null) as Long?) + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) fun vehicleId(vehicleId: String?) = apply { this.vehicleId = vehicleId } - fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.orElse(null)) + /** Alias for calling [Builder.vehicleId] with `vehicleId.orElse(null)`. */ + fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -216,9 +218,22 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ArrivalAndDepartureRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceDate() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ArrivalAndDepartureRetrieveParams = ArrivalAndDepartureRetrieveParams( - checkRequired("stopId", stopId), + stopId, checkRequired("serviceDate", serviceDate), checkRequired("tripId", tripId), stopSequence, @@ -229,6 +244,26 @@ private constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> stopId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("serviceDate", serviceDate.toString()) + put("tripId", tripId) + stopSequence?.let { put("stopSequence", it.toString()) } + time?.let { put("time", it.toString()) } + vehicleId?.let { put("vehicleId", it) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..2a83e0a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt @@ -0,0 +1,3922 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +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 ArrivalAndDepartureRetrieveResponse +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 + * [ArrivalAndDepartureRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalAndDepartureRetrieveResponse]. */ + 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( + arrivalAndDepartureRetrieveResponse: ArrivalAndDepartureRetrieveResponse + ) = apply { + code = arrivalAndDepartureRetrieveResponse.code + currentTime = arrivalAndDepartureRetrieveResponse.currentTime + text = arrivalAndDepartureRetrieveResponse.text + version = arrivalAndDepartureRetrieveResponse.version + data = arrivalAndDepartureRetrieveResponse.data + additionalProperties = + arrivalAndDepartureRetrieveResponse.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 [ArrivalAndDepartureRetrieveResponse]. + * + * 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(): ArrivalAndDepartureRetrieveResponse = + ArrivalAndDepartureRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ArrivalAndDepartureRetrieveResponse = 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 + 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 + 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 [Entry]. + * + * 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 [Entry]. */ + 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(entry: Entry) = apply { + arrivalEnabled = entry.arrivalEnabled + blockTripSequence = entry.blockTripSequence + departureEnabled = entry.departureEnabled + numberOfStopsAway = entry.numberOfStopsAway + predictedArrivalTime = entry.predictedArrivalTime + predictedDepartureTime = entry.predictedDepartureTime + routeId = entry.routeId + scheduledArrivalTime = entry.scheduledArrivalTime + scheduledDepartureTime = entry.scheduledDepartureTime + serviceDate = entry.serviceDate + stopId = entry.stopId + stopSequence = entry.stopSequence + totalStopsInTrip = entry.totalStopsInTrip + tripHeadsign = entry.tripHeadsign + tripId = entry.tripId + vehicleId = entry.vehicleId + actualTrack = entry.actualTrack + distanceFromStop = entry.distanceFromStop + frequency = entry.frequency + historicalOccupancy = entry.historicalOccupancy + lastUpdateTime = entry.lastUpdateTime + occupancyStatus = entry.occupancyStatus + predicted = entry.predicted + predictedArrivalInterval = entry.predictedArrivalInterval + predictedDepartureInterval = entry.predictedDepartureInterval + predictedOccupancy = entry.predictedOccupancy + routeLongName = entry.routeLongName + routeShortName = entry.routeShortName + scheduledArrivalInterval = entry.scheduledArrivalInterval + scheduledDepartureInterval = entry.scheduledDepartureInterval + scheduledTrack = entry.scheduledTrack + situationIds = entry.situationIds.map { it.toMutableList() } + status = entry.status + tripStatus = entry.tripStatus + additionalProperties = entry.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 [Entry]. + * + * 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(): Entry = + Entry( + 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(): Entry = 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 + 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. + * + * @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. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * 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. */ + class LastKnownLocation + 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 /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + 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 /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + 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 /* spotless:off */ other is Entry && 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{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}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is ArrivalAndDepartureRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ArrivalAndDepartureRetrieveResponse{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/BlockRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveParams.kt similarity index 85% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveParams.kt index 3acfe8b..9f940f7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/BlockRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveParams.kt @@ -1,48 +1,39 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.block import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Get details of a specific block by ID */ class BlockRetrieveParams private constructor( - private val blockId: String, + private val blockId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun blockId(): String = blockId + fun blockId(): Optional = Optional.ofNullable(blockId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> blockId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): BlockRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BlockRetrieveParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [BlockRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var blockId: String? = null @@ -56,7 +47,10 @@ private constructor( additionalQueryParams = blockRetrieveParams.additionalQueryParams.toBuilder() } - fun blockId(blockId: String) = apply { this.blockId = blockId } + fun blockId(blockId: String?) = apply { this.blockId = blockId } + + /** Alias for calling [Builder.blockId] with `blockId.orElse(null)`. */ + fun blockId(blockId: Optional) = blockId(blockId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +150,25 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [BlockRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): BlockRetrieveParams = - BlockRetrieveParams( - checkRequired("blockId", blockId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + BlockRetrieveParams(blockId, additionalHeaders.build(), additionalQueryParams.build()) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> blockId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..e7dfe35 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt @@ -0,0 +1,1985 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.block + +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 BlockRetrieveResponse +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 [BlockRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BlockRetrieveResponse]. */ + 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(blockRetrieveResponse: BlockRetrieveResponse) = apply { + code = blockRetrieveResponse.code + currentTime = blockRetrieveResponse.currentTime + text = blockRetrieveResponse.text + version = blockRetrieveResponse.version + data = blockRetrieveResponse.data + additionalProperties = blockRetrieveResponse.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 [BlockRetrieveResponse]. + * + * 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(): BlockRetrieveResponse = + BlockRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BlockRetrieveResponse = 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 + 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 + private constructor( + private val id: JsonField, + private val configurations: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("configurations") + @ExcludeMissing + configurations: JsonField> = JsonMissing.of(), + ) : this(id, configurations, 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 configurations(): List = configurations.getRequired("configurations") + + /** + * 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 [configurations]. + * + * Unlike [configurations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("configurations") + @ExcludeMissing + fun _configurations(): JsonField> = configurations + + @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 + * .id() + * .configurations() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var configurations: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + configurations = entry.configurations.map { it.toMutableList() } + additionalProperties = entry.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 configurations(configurations: List) = + configurations(JsonField.of(configurations)) + + /** + * Sets [Builder.configurations] to an arbitrary JSON value. + * + * You should usually call [Builder.configurations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun configurations(configurations: JsonField>) = apply { + this.configurations = configurations.map { it.toMutableList() } + } + + /** + * Adds a single [Configuration] to [configurations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConfiguration(configuration: Configuration) = apply { + configurations = + (configurations ?: JsonField.of(mutableListOf())).also { + checkKnown("configurations", it).add(configuration) + } + } + + 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 + * .id() + * .configurations() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("configurations", configurations).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + configurations().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 (id.asKnown().isPresent) 1 else 0) + + (configurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Configuration + private constructor( + private val activeServiceIds: JsonField>, + private val trips: JsonField>, + private val inactiveServiceIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeServiceIds") + @ExcludeMissing + activeServiceIds: JsonField> = JsonMissing.of(), + @JsonProperty("trips") + @ExcludeMissing + trips: JsonField> = JsonMissing.of(), + @JsonProperty("inactiveServiceIds") + @ExcludeMissing + inactiveServiceIds: JsonField> = JsonMissing.of(), + ) : this(activeServiceIds, trips, inactiveServiceIds, 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 activeServiceIds(): List = + activeServiceIds.getRequired("activeServiceIds") + + /** + * @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") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun inactiveServiceIds(): Optional> = + inactiveServiceIds.getOptional("inactiveServiceIds") + + /** + * Returns the raw JSON value of [activeServiceIds]. + * + * Unlike [activeServiceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("activeServiceIds") + @ExcludeMissing + fun _activeServiceIds(): JsonField> = activeServiceIds + + /** + * 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 + + /** + * Returns the raw JSON value of [inactiveServiceIds]. + * + * Unlike [inactiveServiceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inactiveServiceIds") + @ExcludeMissing + fun _inactiveServiceIds(): JsonField> = inactiveServiceIds + + @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 [Configuration]. + * + * The following fields are required: + * ```java + * .activeServiceIds() + * .trips() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Configuration]. */ + class Builder internal constructor() { + + private var activeServiceIds: JsonField>? = null + private var trips: JsonField>? = null + private var inactiveServiceIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(configuration: Configuration) = apply { + activeServiceIds = configuration.activeServiceIds.map { it.toMutableList() } + trips = configuration.trips.map { it.toMutableList() } + inactiveServiceIds = + configuration.inactiveServiceIds.map { it.toMutableList() } + additionalProperties = configuration.additionalProperties.toMutableMap() + } + + fun activeServiceIds(activeServiceIds: List) = + activeServiceIds(JsonField.of(activeServiceIds)) + + /** + * Sets [Builder.activeServiceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.activeServiceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun activeServiceIds(activeServiceIds: JsonField>) = apply { + this.activeServiceIds = activeServiceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [activeServiceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addActiveServiceId(activeServiceId: String) = apply { + activeServiceIds = + (activeServiceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("activeServiceIds", it).add(activeServiceId) + } + } + + 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 inactiveServiceIds(inactiveServiceIds: List) = + inactiveServiceIds(JsonField.of(inactiveServiceIds)) + + /** + * Sets [Builder.inactiveServiceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.inactiveServiceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun inactiveServiceIds(inactiveServiceIds: JsonField>) = apply { + this.inactiveServiceIds = inactiveServiceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [inactiveServiceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInactiveServiceId(inactiveServiceId: String) = apply { + inactiveServiceIds = + (inactiveServiceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("inactiveServiceIds", it).add(inactiveServiceId) + } + } + + 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 [Configuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .activeServiceIds() + * .trips() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Configuration = + Configuration( + checkRequired("activeServiceIds", activeServiceIds).map { + it.toImmutable() + }, + checkRequired("trips", trips).map { it.toImmutable() }, + (inactiveServiceIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Configuration = apply { + if (validated) { + return@apply + } + + activeServiceIds() + trips().forEach { it.validate() } + inactiveServiceIds() + 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 = + (activeServiceIds.asKnown().getOrNull()?.size ?: 0) + + (trips.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (inactiveServiceIds.asKnown().getOrNull()?.size ?: 0) + + class Trip + private constructor( + private val accumulatedSlackTime: JsonField, + private val blockStopTimes: JsonField>, + private val distanceAlongBlock: JsonField, + private val tripId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + accumulatedSlackTime: JsonField = JsonMissing.of(), + @JsonProperty("blockStopTimes") + @ExcludeMissing + blockStopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + distanceAlongBlock: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + ) : this( + accumulatedSlackTime, + blockStopTimes, + distanceAlongBlock, + 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 accumulatedSlackTime(): Float = + accumulatedSlackTime.getRequired("accumulatedSlackTime") + + /** + * @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 blockStopTimes(): List = + blockStopTimes.getRequired("blockStopTimes") + + /** + * @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 distanceAlongBlock(): Float = + distanceAlongBlock.getRequired("distanceAlongBlock") + + /** + * @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 [accumulatedSlackTime]. + * + * Unlike [accumulatedSlackTime], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + fun _accumulatedSlackTime(): JsonField = accumulatedSlackTime + + /** + * Returns the raw JSON value of [blockStopTimes]. + * + * Unlike [blockStopTimes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockStopTimes") + @ExcludeMissing + fun _blockStopTimes(): JsonField> = blockStopTimes + + /** + * Returns the raw JSON value of [distanceAlongBlock]. + * + * Unlike [distanceAlongBlock], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + fun _distanceAlongBlock(): JsonField = distanceAlongBlock + + /** + * 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) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Trip]. + * + * The following fields are required: + * ```java + * .accumulatedSlackTime() + * .blockStopTimes() + * .distanceAlongBlock() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Trip]. */ + class Builder internal constructor() { + + private var accumulatedSlackTime: JsonField? = null + private var blockStopTimes: JsonField>? = null + private var distanceAlongBlock: JsonField? = null + private var tripId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(trip: Trip) = apply { + accumulatedSlackTime = trip.accumulatedSlackTime + blockStopTimes = trip.blockStopTimes.map { it.toMutableList() } + distanceAlongBlock = trip.distanceAlongBlock + tripId = trip.tripId + additionalProperties = trip.additionalProperties.toMutableMap() + } + + fun accumulatedSlackTime(accumulatedSlackTime: Float) = + accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) + + /** + * Sets [Builder.accumulatedSlackTime] to an arbitrary JSON value. + * + * You should usually call [Builder.accumulatedSlackTime] with a well-typed + * [Float] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = apply { + this.accumulatedSlackTime = accumulatedSlackTime + } + + fun blockStopTimes(blockStopTimes: List) = + blockStopTimes(JsonField.of(blockStopTimes)) + + /** + * Sets [Builder.blockStopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.blockStopTimes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun blockStopTimes(blockStopTimes: JsonField>) = apply { + this.blockStopTimes = blockStopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [BlockStopTime] to [blockStopTimes]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addBlockStopTime(blockStopTime: BlockStopTime) = apply { + blockStopTimes = + (blockStopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("blockStopTimes", it).add(blockStopTime) + } + } + + fun distanceAlongBlock(distanceAlongBlock: Float) = + distanceAlongBlock(JsonField.of(distanceAlongBlock)) + + /** + * Sets [Builder.distanceAlongBlock] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongBlock] with a well-typed + * [Float] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { + this.distanceAlongBlock = distanceAlongBlock + } + + 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 [Trip]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accumulatedSlackTime() + * .blockStopTimes() + * .distanceAlongBlock() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Trip = + Trip( + checkRequired("accumulatedSlackTime", accumulatedSlackTime), + checkRequired("blockStopTimes", blockStopTimes).map { + it.toImmutable() + }, + checkRequired("distanceAlongBlock", distanceAlongBlock), + checkRequired("tripId", tripId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Trip = apply { + if (validated) { + return@apply + } + + accumulatedSlackTime() + blockStopTimes().forEach { it.validate() } + distanceAlongBlock() + 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 = + (if (accumulatedSlackTime.asKnown().isPresent) 1 else 0) + + (blockStopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (distanceAlongBlock.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + class BlockStopTime + private constructor( + private val accumulatedSlackTime: JsonField, + private val blockSequence: JsonField, + private val distanceAlongBlock: JsonField, + private val stopTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + accumulatedSlackTime: JsonField = JsonMissing.of(), + @JsonProperty("blockSequence") + @ExcludeMissing + blockSequence: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + distanceAlongBlock: JsonField = JsonMissing.of(), + @JsonProperty("stopTime") + @ExcludeMissing + stopTime: JsonField = JsonMissing.of(), + ) : this( + accumulatedSlackTime, + blockSequence, + distanceAlongBlock, + stopTime, + 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 accumulatedSlackTime(): Float = + accumulatedSlackTime.getRequired("accumulatedSlackTime") + + /** + * @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 blockSequence(): Long = blockSequence.getRequired("blockSequence") + + /** + * @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 distanceAlongBlock(): Float = + distanceAlongBlock.getRequired("distanceAlongBlock") + + /** + * @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 stopTime(): StopTime = stopTime.getRequired("stopTime") + + /** + * Returns the raw JSON value of [accumulatedSlackTime]. + * + * Unlike [accumulatedSlackTime], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("accumulatedSlackTime") + @ExcludeMissing + fun _accumulatedSlackTime(): JsonField = accumulatedSlackTime + + /** + * Returns the raw JSON value of [blockSequence]. + * + * Unlike [blockSequence], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("blockSequence") + @ExcludeMissing + fun _blockSequence(): JsonField = blockSequence + + /** + * Returns the raw JSON value of [distanceAlongBlock]. + * + * Unlike [distanceAlongBlock], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("distanceAlongBlock") + @ExcludeMissing + fun _distanceAlongBlock(): JsonField = distanceAlongBlock + + /** + * Returns the raw JSON value of [stopTime]. + * + * Unlike [stopTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopTime") + @ExcludeMissing + fun _stopTime(): JsonField = stopTime + + @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 + * [BlockStopTime]. + * + * The following fields are required: + * ```java + * .accumulatedSlackTime() + * .blockSequence() + * .distanceAlongBlock() + * .stopTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BlockStopTime]. */ + class Builder internal constructor() { + + private var accumulatedSlackTime: JsonField? = null + private var blockSequence: JsonField? = null + private var distanceAlongBlock: JsonField? = null + private var stopTime: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(blockStopTime: BlockStopTime) = apply { + accumulatedSlackTime = blockStopTime.accumulatedSlackTime + blockSequence = blockStopTime.blockSequence + distanceAlongBlock = blockStopTime.distanceAlongBlock + stopTime = blockStopTime.stopTime + additionalProperties = + blockStopTime.additionalProperties.toMutableMap() + } + + fun accumulatedSlackTime(accumulatedSlackTime: Float) = + accumulatedSlackTime(JsonField.of(accumulatedSlackTime)) + + /** + * Sets [Builder.accumulatedSlackTime] to an arbitrary JSON value. + * + * You should usually call [Builder.accumulatedSlackTime] with a + * well-typed [Float] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun accumulatedSlackTime(accumulatedSlackTime: JsonField) = + apply { + this.accumulatedSlackTime = accumulatedSlackTime + } + + fun blockSequence(blockSequence: Long) = + blockSequence(JsonField.of(blockSequence)) + + /** + * Sets [Builder.blockSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockSequence] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun blockSequence(blockSequence: JsonField) = apply { + this.blockSequence = blockSequence + } + + fun distanceAlongBlock(distanceAlongBlock: Float) = + distanceAlongBlock(JsonField.of(distanceAlongBlock)) + + /** + * Sets [Builder.distanceAlongBlock] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceAlongBlock] with a + * well-typed [Float] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun distanceAlongBlock(distanceAlongBlock: JsonField) = apply { + this.distanceAlongBlock = distanceAlongBlock + } + + fun stopTime(stopTime: StopTime) = stopTime(JsonField.of(stopTime)) + + /** + * Sets [Builder.stopTime] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTime] with a well-typed + * [StopTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTime(stopTime: JsonField) = apply { + this.stopTime = stopTime + } + + 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 [BlockStopTime]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .accumulatedSlackTime() + * .blockSequence() + * .distanceAlongBlock() + * .stopTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BlockStopTime = + BlockStopTime( + checkRequired("accumulatedSlackTime", accumulatedSlackTime), + checkRequired("blockSequence", blockSequence), + checkRequired("distanceAlongBlock", distanceAlongBlock), + checkRequired("stopTime", stopTime), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BlockStopTime = apply { + if (validated) { + return@apply + } + + accumulatedSlackTime() + blockSequence() + distanceAlongBlock() + stopTime().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 (accumulatedSlackTime.asKnown().isPresent) 1 else 0) + + (if (blockSequence.asKnown().isPresent) 1 else 0) + + (if (distanceAlongBlock.asKnown().isPresent) 1 else 0) + + (stopTime.asKnown().getOrNull()?.validity() ?: 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val stopId: JsonField, + private val dropOffType: JsonField, + private val pickupType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("dropOffType") + @ExcludeMissing + dropOffType: JsonField = JsonMissing.of(), + @JsonProperty("pickupType") + @ExcludeMissing + pickupType: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + stopId, + dropOffType, + pickupType, + 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 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 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 (e.g. if the server responded with an unexpected + * value). + */ + fun dropOffType(): Optional = + dropOffType.getOptional("dropOffType") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun pickupType(): Optional = pickupType.getOptional("pickupType") + + /** + * 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 [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 [dropOffType]. + * + * Unlike [dropOffType], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dropOffType") + @ExcludeMissing + fun _dropOffType(): JsonField = dropOffType + + /** + * Returns the raw JSON value of [pickupType]. + * + * Unlike [pickupType], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("pickupType") + @ExcludeMissing + fun _pickupType(): JsonField = pickupType + + @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 + * .arrivalTime() + * .departureTime() + * .stopId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField? = null + private var departureTime: JsonField? = null + private var stopId: JsonField? = null + private var dropOffType: JsonField = JsonMissing.of() + private var pickupType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + stopId = stopTime.stopId + dropOffType = stopTime.dropOffType + pickupType = stopTime.pickupType + additionalProperties = + stopTime.additionalProperties.toMutableMap() + } + + 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 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 dropOffType(dropOffType: Long) = + dropOffType(JsonField.of(dropOffType)) + + /** + * Sets [Builder.dropOffType] to an arbitrary JSON value. + * + * You should usually call [Builder.dropOffType] with a well-typed + * [Long] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dropOffType(dropOffType: JsonField) = apply { + this.dropOffType = dropOffType + } + + fun pickupType(pickupType: Long) = + pickupType(JsonField.of(pickupType)) + + /** + * Sets [Builder.pickupType] to an arbitrary JSON value. + * + * You should usually call [Builder.pickupType] with a well-typed + * [Long] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pickupType(pickupType: JsonField) = apply { + this.pickupType = pickupType + } + + 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 + * .arrivalTime() + * .departureTime() + * .stopId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopTime = + StopTime( + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureTime", departureTime), + checkRequired("stopId", stopId), + dropOffType, + pickupType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + stopId() + dropOffType() + pickupType() + 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 (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (dropOffType.asKnown().isPresent) 1 else 0) + + (if (pickupType.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && stopId == other.stopId && dropOffType == other.dropOffType && pickupType == other.pickupType && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, stopId, dropOffType, pickupType, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, stopId=$stopId, dropOffType=$dropOffType, pickupType=$pickupType, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BlockStopTime && accumulatedSlackTime == other.accumulatedSlackTime && blockSequence == other.blockSequence && distanceAlongBlock == other.distanceAlongBlock && stopTime == other.stopTime && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accumulatedSlackTime, blockSequence, distanceAlongBlock, stopTime, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BlockStopTime{accumulatedSlackTime=$accumulatedSlackTime, blockSequence=$blockSequence, distanceAlongBlock=$distanceAlongBlock, stopTime=$stopTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Trip && accumulatedSlackTime == other.accumulatedSlackTime && blockStopTimes == other.blockStopTimes && distanceAlongBlock == other.distanceAlongBlock && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accumulatedSlackTime, blockStopTimes, distanceAlongBlock, tripId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Trip{accumulatedSlackTime=$accumulatedSlackTime, blockStopTimes=$blockStopTimes, distanceAlongBlock=$distanceAlongBlock, tripId=$tripId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Configuration && activeServiceIds == other.activeServiceIds && trips == other.trips && inactiveServiceIds == other.inactiveServiceIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(activeServiceIds, trips, inactiveServiceIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Configuration{activeServiceIds=$activeServiceIds, trips=$trips, inactiveServiceIds=$inactiveServiceIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && configurations == other.configurations && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, configurations, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, configurations=$configurations, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is BlockRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BlockRetrieveResponse{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/ConfigRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveParams.kt similarity index 93% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveParams.kt index 45d12c5..628f517 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ConfigRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveParams.kt @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.config import java.util.Objects -import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.Params import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams @@ -19,19 +18,17 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): ConfigRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ConfigRetrieveParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [ConfigRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() @@ -141,10 +138,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ConfigRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ConfigRetrieveParams = ConfigRetrieveParams(additionalHeaders.build(), additionalQueryParams.build()) } + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..ab640a3 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt @@ -0,0 +1,1731 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.config + +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.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class ConfigRetrieveResponse +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 [ConfigRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigRetrieveResponse]. */ + 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(configRetrieveResponse: ConfigRetrieveResponse) = apply { + code = configRetrieveResponse.code + currentTime = configRetrieveResponse.currentTime + text = configRetrieveResponse.text + version = configRetrieveResponse.version + data = configRetrieveResponse.data + additionalProperties = configRetrieveResponse.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 [ConfigRetrieveResponse]. + * + * 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(): ConfigRetrieveResponse = + ConfigRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConfigRetrieveResponse = 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 + 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 + private constructor( + private val id: JsonField, + private val gitProperties: JsonField, + private val name: JsonField, + private val serviceDateFrom: JsonField, + private val serviceDateTo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("gitProperties") + @ExcludeMissing + gitProperties: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("serviceDateFrom") + @ExcludeMissing + serviceDateFrom: JsonField = JsonMissing.of(), + @JsonProperty("serviceDateTo") + @ExcludeMissing + serviceDateTo: JsonField = JsonMissing.of(), + ) : this(id, gitProperties, name, serviceDateFrom, serviceDateTo, 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 gitProperties(): Optional = + gitProperties.getOptional("gitProperties") + + /** + * @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 serviceDateFrom(): Optional = serviceDateFrom.getOptional("serviceDateFrom") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDateTo(): Optional = serviceDateTo.getOptional("serviceDateTo") + + /** + * 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 [gitProperties]. + * + * Unlike [gitProperties], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitProperties") + @ExcludeMissing + fun _gitProperties(): JsonField = gitProperties + + /** + * 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 [serviceDateFrom]. + * + * Unlike [serviceDateFrom], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDateFrom") + @ExcludeMissing + fun _serviceDateFrom(): JsonField = serviceDateFrom + + /** + * Returns the raw JSON value of [serviceDateTo]. + * + * Unlike [serviceDateTo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceDateTo") + @ExcludeMissing + fun _serviceDateTo(): JsonField = serviceDateTo + + @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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var gitProperties: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var serviceDateFrom: JsonField = JsonMissing.of() + private var serviceDateTo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + gitProperties = entry.gitProperties + name = entry.name + serviceDateFrom = entry.serviceDateFrom + serviceDateTo = entry.serviceDateTo + additionalProperties = entry.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 gitProperties(gitProperties: GitProperties) = + gitProperties(JsonField.of(gitProperties)) + + /** + * Sets [Builder.gitProperties] to an arbitrary JSON value. + * + * You should usually call [Builder.gitProperties] with a well-typed [GitProperties] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun gitProperties(gitProperties: JsonField) = apply { + this.gitProperties = gitProperties + } + + 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 serviceDateFrom(serviceDateFrom: String) = + serviceDateFrom(JsonField.of(serviceDateFrom)) + + /** + * Sets [Builder.serviceDateFrom] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDateFrom] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun serviceDateFrom(serviceDateFrom: JsonField) = apply { + this.serviceDateFrom = serviceDateFrom + } + + fun serviceDateTo(serviceDateTo: String) = + serviceDateTo(JsonField.of(serviceDateTo)) + + /** + * Sets [Builder.serviceDateTo] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDateTo] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceDateTo(serviceDateTo: JsonField) = apply { + this.serviceDateTo = serviceDateTo + } + + 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. + */ + fun build(): Entry = + Entry( + id, + gitProperties, + name, + serviceDateFrom, + serviceDateTo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + gitProperties().ifPresent { it.validate() } + name() + serviceDateFrom() + serviceDateTo() + 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) + + (gitProperties.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (serviceDateFrom.asKnown().isPresent) 1 else 0) + + (if (serviceDateTo.asKnown().isPresent) 1 else 0) + + class GitProperties + private constructor( + private val gitBranch: JsonField, + private val gitBuildHost: JsonField, + private val gitBuildTime: JsonField, + private val gitBuildUserEmail: JsonField, + private val gitBuildUserName: JsonField, + private val gitBuildVersion: JsonField, + private val gitClosestTagCommitCount: JsonField, + private val gitClosestTagName: JsonField, + private val gitCommitId: JsonField, + private val gitCommitIdAbbrev: JsonField, + private val gitCommitIdDescribe: JsonField, + private val gitCommitIdDescribeShort: JsonField, + private val gitCommitMessageFull: JsonField, + private val gitCommitMessageShort: JsonField, + private val gitCommitTime: JsonField, + private val gitCommitUserEmail: JsonField, + private val gitCommitUserName: JsonField, + private val gitDirty: JsonField, + private val gitRemoteOriginUrl: JsonField, + private val gitTags: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("git.branch") + @ExcludeMissing + gitBranch: JsonField = JsonMissing.of(), + @JsonProperty("git.build.host") + @ExcludeMissing + gitBuildHost: JsonField = JsonMissing.of(), + @JsonProperty("git.build.time") + @ExcludeMissing + gitBuildTime: JsonField = JsonMissing.of(), + @JsonProperty("git.build.user.email") + @ExcludeMissing + gitBuildUserEmail: JsonField = JsonMissing.of(), + @JsonProperty("git.build.user.name") + @ExcludeMissing + gitBuildUserName: JsonField = JsonMissing.of(), + @JsonProperty("git.build.version") + @ExcludeMissing + gitBuildVersion: JsonField = JsonMissing.of(), + @JsonProperty("git.closest.tag.commit.count") + @ExcludeMissing + gitClosestTagCommitCount: JsonField = JsonMissing.of(), + @JsonProperty("git.closest.tag.name") + @ExcludeMissing + gitClosestTagName: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id") + @ExcludeMissing + gitCommitId: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.abbrev") + @ExcludeMissing + gitCommitIdAbbrev: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.describe") + @ExcludeMissing + gitCommitIdDescribe: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.id.describe-short") + @ExcludeMissing + gitCommitIdDescribeShort: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.message.full") + @ExcludeMissing + gitCommitMessageFull: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.message.short") + @ExcludeMissing + gitCommitMessageShort: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.time") + @ExcludeMissing + gitCommitTime: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.user.email") + @ExcludeMissing + gitCommitUserEmail: JsonField = JsonMissing.of(), + @JsonProperty("git.commit.user.name") + @ExcludeMissing + gitCommitUserName: JsonField = JsonMissing.of(), + @JsonProperty("git.dirty") + @ExcludeMissing + gitDirty: JsonField = JsonMissing.of(), + @JsonProperty("git.remote.origin.url") + @ExcludeMissing + gitRemoteOriginUrl: JsonField = JsonMissing.of(), + @JsonProperty("git.tags") + @ExcludeMissing + gitTags: JsonField = JsonMissing.of(), + ) : this( + gitBranch, + gitBuildHost, + gitBuildTime, + gitBuildUserEmail, + gitBuildUserName, + gitBuildVersion, + gitClosestTagCommitCount, + gitClosestTagName, + gitCommitId, + gitCommitIdAbbrev, + gitCommitIdDescribe, + gitCommitIdDescribeShort, + gitCommitMessageFull, + gitCommitMessageShort, + gitCommitTime, + gitCommitUserEmail, + gitCommitUserName, + gitDirty, + gitRemoteOriginUrl, + gitTags, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBranch(): Optional = gitBranch.getOptional("git.branch") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildHost(): Optional = gitBuildHost.getOptional("git.build.host") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildTime(): Optional = gitBuildTime.getOptional("git.build.time") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildUserEmail(): Optional = + gitBuildUserEmail.getOptional("git.build.user.email") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildUserName(): Optional = + gitBuildUserName.getOptional("git.build.user.name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitBuildVersion(): Optional = + gitBuildVersion.getOptional("git.build.version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitClosestTagCommitCount(): Optional = + gitClosestTagCommitCount.getOptional("git.closest.tag.commit.count") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitClosestTagName(): Optional = + gitClosestTagName.getOptional("git.closest.tag.name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitId(): Optional = gitCommitId.getOptional("git.commit.id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitIdAbbrev(): Optional = + gitCommitIdAbbrev.getOptional("git.commit.id.abbrev") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitIdDescribe(): Optional = + gitCommitIdDescribe.getOptional("git.commit.id.describe") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitIdDescribeShort(): Optional = + gitCommitIdDescribeShort.getOptional("git.commit.id.describe-short") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitMessageFull(): Optional = + gitCommitMessageFull.getOptional("git.commit.message.full") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitMessageShort(): Optional = + gitCommitMessageShort.getOptional("git.commit.message.short") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitTime(): Optional = gitCommitTime.getOptional("git.commit.time") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitUserEmail(): Optional = + gitCommitUserEmail.getOptional("git.commit.user.email") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitCommitUserName(): Optional = + gitCommitUserName.getOptional("git.commit.user.name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitDirty(): Optional = gitDirty.getOptional("git.dirty") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitRemoteOriginUrl(): Optional = + gitRemoteOriginUrl.getOptional("git.remote.origin.url") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun gitTags(): Optional = gitTags.getOptional("git.tags") + + /** + * Returns the raw JSON value of [gitBranch]. + * + * Unlike [gitBranch], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("git.branch") + @ExcludeMissing + fun _gitBranch(): JsonField = gitBranch + + /** + * Returns the raw JSON value of [gitBuildHost]. + * + * Unlike [gitBuildHost], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.host") + @ExcludeMissing + fun _gitBuildHost(): JsonField = gitBuildHost + + /** + * Returns the raw JSON value of [gitBuildTime]. + * + * Unlike [gitBuildTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.time") + @ExcludeMissing + fun _gitBuildTime(): JsonField = gitBuildTime + + /** + * Returns the raw JSON value of [gitBuildUserEmail]. + * + * Unlike [gitBuildUserEmail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.user.email") + @ExcludeMissing + fun _gitBuildUserEmail(): JsonField = gitBuildUserEmail + + /** + * Returns the raw JSON value of [gitBuildUserName]. + * + * Unlike [gitBuildUserName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.user.name") + @ExcludeMissing + fun _gitBuildUserName(): JsonField = gitBuildUserName + + /** + * Returns the raw JSON value of [gitBuildVersion]. + * + * Unlike [gitBuildVersion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.build.version") + @ExcludeMissing + fun _gitBuildVersion(): JsonField = gitBuildVersion + + /** + * Returns the raw JSON value of [gitClosestTagCommitCount]. + * + * Unlike [gitClosestTagCommitCount], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("git.closest.tag.commit.count") + @ExcludeMissing + fun _gitClosestTagCommitCount(): JsonField = gitClosestTagCommitCount + + /** + * Returns the raw JSON value of [gitClosestTagName]. + * + * Unlike [gitClosestTagName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.closest.tag.name") + @ExcludeMissing + fun _gitClosestTagName(): JsonField = gitClosestTagName + + /** + * Returns the raw JSON value of [gitCommitId]. + * + * Unlike [gitCommitId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.id") + @ExcludeMissing + fun _gitCommitId(): JsonField = gitCommitId + + /** + * Returns the raw JSON value of [gitCommitIdAbbrev]. + * + * Unlike [gitCommitIdAbbrev], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.id.abbrev") + @ExcludeMissing + fun _gitCommitIdAbbrev(): JsonField = gitCommitIdAbbrev + + /** + * Returns the raw JSON value of [gitCommitIdDescribe]. + * + * Unlike [gitCommitIdDescribe], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.id.describe") + @ExcludeMissing + fun _gitCommitIdDescribe(): JsonField = gitCommitIdDescribe + + /** + * Returns the raw JSON value of [gitCommitIdDescribeShort]. + * + * Unlike [gitCommitIdDescribeShort], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("git.commit.id.describe-short") + @ExcludeMissing + fun _gitCommitIdDescribeShort(): JsonField = gitCommitIdDescribeShort + + /** + * Returns the raw JSON value of [gitCommitMessageFull]. + * + * Unlike [gitCommitMessageFull], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.message.full") + @ExcludeMissing + fun _gitCommitMessageFull(): JsonField = gitCommitMessageFull + + /** + * Returns the raw JSON value of [gitCommitMessageShort]. + * + * Unlike [gitCommitMessageShort], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("git.commit.message.short") + @ExcludeMissing + fun _gitCommitMessageShort(): JsonField = gitCommitMessageShort + + /** + * Returns the raw JSON value of [gitCommitTime]. + * + * Unlike [gitCommitTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.time") + @ExcludeMissing + fun _gitCommitTime(): JsonField = gitCommitTime + + /** + * Returns the raw JSON value of [gitCommitUserEmail]. + * + * Unlike [gitCommitUserEmail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.user.email") + @ExcludeMissing + fun _gitCommitUserEmail(): JsonField = gitCommitUserEmail + + /** + * Returns the raw JSON value of [gitCommitUserName]. + * + * Unlike [gitCommitUserName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.commit.user.name") + @ExcludeMissing + fun _gitCommitUserName(): JsonField = gitCommitUserName + + /** + * Returns the raw JSON value of [gitDirty]. + * + * Unlike [gitDirty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("git.dirty") + @ExcludeMissing + fun _gitDirty(): JsonField = gitDirty + + /** + * Returns the raw JSON value of [gitRemoteOriginUrl]. + * + * Unlike [gitRemoteOriginUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("git.remote.origin.url") + @ExcludeMissing + fun _gitRemoteOriginUrl(): JsonField = gitRemoteOriginUrl + + /** + * Returns the raw JSON value of [gitTags]. + * + * Unlike [gitTags], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("git.tags") + @ExcludeMissing + fun _gitTags(): JsonField = gitTags + + @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 [GitProperties]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitProperties]. */ + class Builder internal constructor() { + + private var gitBranch: JsonField = JsonMissing.of() + private var gitBuildHost: JsonField = JsonMissing.of() + private var gitBuildTime: JsonField = JsonMissing.of() + private var gitBuildUserEmail: JsonField = JsonMissing.of() + private var gitBuildUserName: JsonField = JsonMissing.of() + private var gitBuildVersion: JsonField = JsonMissing.of() + private var gitClosestTagCommitCount: JsonField = JsonMissing.of() + private var gitClosestTagName: JsonField = JsonMissing.of() + private var gitCommitId: JsonField = JsonMissing.of() + private var gitCommitIdAbbrev: JsonField = JsonMissing.of() + private var gitCommitIdDescribe: JsonField = JsonMissing.of() + private var gitCommitIdDescribeShort: JsonField = JsonMissing.of() + private var gitCommitMessageFull: JsonField = JsonMissing.of() + private var gitCommitMessageShort: JsonField = JsonMissing.of() + private var gitCommitTime: JsonField = JsonMissing.of() + private var gitCommitUserEmail: JsonField = JsonMissing.of() + private var gitCommitUserName: JsonField = JsonMissing.of() + private var gitDirty: JsonField = JsonMissing.of() + private var gitRemoteOriginUrl: JsonField = JsonMissing.of() + private var gitTags: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitProperties: GitProperties) = apply { + gitBranch = gitProperties.gitBranch + gitBuildHost = gitProperties.gitBuildHost + gitBuildTime = gitProperties.gitBuildTime + gitBuildUserEmail = gitProperties.gitBuildUserEmail + gitBuildUserName = gitProperties.gitBuildUserName + gitBuildVersion = gitProperties.gitBuildVersion + gitClosestTagCommitCount = gitProperties.gitClosestTagCommitCount + gitClosestTagName = gitProperties.gitClosestTagName + gitCommitId = gitProperties.gitCommitId + gitCommitIdAbbrev = gitProperties.gitCommitIdAbbrev + gitCommitIdDescribe = gitProperties.gitCommitIdDescribe + gitCommitIdDescribeShort = gitProperties.gitCommitIdDescribeShort + gitCommitMessageFull = gitProperties.gitCommitMessageFull + gitCommitMessageShort = gitProperties.gitCommitMessageShort + gitCommitTime = gitProperties.gitCommitTime + gitCommitUserEmail = gitProperties.gitCommitUserEmail + gitCommitUserName = gitProperties.gitCommitUserName + gitDirty = gitProperties.gitDirty + gitRemoteOriginUrl = gitProperties.gitRemoteOriginUrl + gitTags = gitProperties.gitTags + additionalProperties = gitProperties.additionalProperties.toMutableMap() + } + + fun gitBranch(gitBranch: String) = gitBranch(JsonField.of(gitBranch)) + + /** + * Sets [Builder.gitBranch] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBranch] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun gitBranch(gitBranch: JsonField) = apply { + this.gitBranch = gitBranch + } + + fun gitBuildHost(gitBuildHost: String) = + gitBuildHost(JsonField.of(gitBuildHost)) + + /** + * Sets [Builder.gitBuildHost] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildHost] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildHost(gitBuildHost: JsonField) = apply { + this.gitBuildHost = gitBuildHost + } + + fun gitBuildTime(gitBuildTime: String) = + gitBuildTime(JsonField.of(gitBuildTime)) + + /** + * Sets [Builder.gitBuildTime] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildTime] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildTime(gitBuildTime: JsonField) = apply { + this.gitBuildTime = gitBuildTime + } + + fun gitBuildUserEmail(gitBuildUserEmail: String) = + gitBuildUserEmail(JsonField.of(gitBuildUserEmail)) + + /** + * Sets [Builder.gitBuildUserEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildUserEmail] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildUserEmail(gitBuildUserEmail: JsonField) = apply { + this.gitBuildUserEmail = gitBuildUserEmail + } + + fun gitBuildUserName(gitBuildUserName: String) = + gitBuildUserName(JsonField.of(gitBuildUserName)) + + /** + * Sets [Builder.gitBuildUserName] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildUserName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildUserName(gitBuildUserName: JsonField) = apply { + this.gitBuildUserName = gitBuildUserName + } + + fun gitBuildVersion(gitBuildVersion: String) = + gitBuildVersion(JsonField.of(gitBuildVersion)) + + /** + * Sets [Builder.gitBuildVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.gitBuildVersion] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitBuildVersion(gitBuildVersion: JsonField) = apply { + this.gitBuildVersion = gitBuildVersion + } + + fun gitClosestTagCommitCount(gitClosestTagCommitCount: String) = + gitClosestTagCommitCount(JsonField.of(gitClosestTagCommitCount)) + + /** + * Sets [Builder.gitClosestTagCommitCount] to an arbitrary JSON value. + * + * You should usually call [Builder.gitClosestTagCommitCount] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitClosestTagCommitCount(gitClosestTagCommitCount: JsonField) = + apply { + this.gitClosestTagCommitCount = gitClosestTagCommitCount + } + + fun gitClosestTagName(gitClosestTagName: String) = + gitClosestTagName(JsonField.of(gitClosestTagName)) + + /** + * Sets [Builder.gitClosestTagName] to an arbitrary JSON value. + * + * You should usually call [Builder.gitClosestTagName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitClosestTagName(gitClosestTagName: JsonField) = apply { + this.gitClosestTagName = gitClosestTagName + } + + fun gitCommitId(gitCommitId: String) = gitCommitId(JsonField.of(gitCommitId)) + + /** + * Sets [Builder.gitCommitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitId(gitCommitId: JsonField) = apply { + this.gitCommitId = gitCommitId + } + + fun gitCommitIdAbbrev(gitCommitIdAbbrev: String) = + gitCommitIdAbbrev(JsonField.of(gitCommitIdAbbrev)) + + /** + * Sets [Builder.gitCommitIdAbbrev] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitIdAbbrev] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitIdAbbrev(gitCommitIdAbbrev: JsonField) = apply { + this.gitCommitIdAbbrev = gitCommitIdAbbrev + } + + fun gitCommitIdDescribe(gitCommitIdDescribe: String) = + gitCommitIdDescribe(JsonField.of(gitCommitIdDescribe)) + + /** + * Sets [Builder.gitCommitIdDescribe] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitIdDescribe] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitIdDescribe(gitCommitIdDescribe: JsonField) = apply { + this.gitCommitIdDescribe = gitCommitIdDescribe + } + + fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: String) = + gitCommitIdDescribeShort(JsonField.of(gitCommitIdDescribeShort)) + + /** + * Sets [Builder.gitCommitIdDescribeShort] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitIdDescribeShort] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitIdDescribeShort(gitCommitIdDescribeShort: JsonField) = + apply { + this.gitCommitIdDescribeShort = gitCommitIdDescribeShort + } + + fun gitCommitMessageFull(gitCommitMessageFull: String) = + gitCommitMessageFull(JsonField.of(gitCommitMessageFull)) + + /** + * Sets [Builder.gitCommitMessageFull] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitMessageFull] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitMessageFull(gitCommitMessageFull: JsonField) = apply { + this.gitCommitMessageFull = gitCommitMessageFull + } + + fun gitCommitMessageShort(gitCommitMessageShort: String) = + gitCommitMessageShort(JsonField.of(gitCommitMessageShort)) + + /** + * Sets [Builder.gitCommitMessageShort] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitMessageShort] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitMessageShort(gitCommitMessageShort: JsonField) = apply { + this.gitCommitMessageShort = gitCommitMessageShort + } + + fun gitCommitTime(gitCommitTime: String) = + gitCommitTime(JsonField.of(gitCommitTime)) + + /** + * Sets [Builder.gitCommitTime] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitTime] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitTime(gitCommitTime: JsonField) = apply { + this.gitCommitTime = gitCommitTime + } + + fun gitCommitUserEmail(gitCommitUserEmail: String) = + gitCommitUserEmail(JsonField.of(gitCommitUserEmail)) + + /** + * Sets [Builder.gitCommitUserEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitUserEmail] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitUserEmail(gitCommitUserEmail: JsonField) = apply { + this.gitCommitUserEmail = gitCommitUserEmail + } + + fun gitCommitUserName(gitCommitUserName: String) = + gitCommitUserName(JsonField.of(gitCommitUserName)) + + /** + * Sets [Builder.gitCommitUserName] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitUserName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitCommitUserName(gitCommitUserName: JsonField) = apply { + this.gitCommitUserName = gitCommitUserName + } + + fun gitDirty(gitDirty: String) = gitDirty(JsonField.of(gitDirty)) + + /** + * Sets [Builder.gitDirty] to an arbitrary JSON value. + * + * You should usually call [Builder.gitDirty] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun gitDirty(gitDirty: JsonField) = apply { this.gitDirty = gitDirty } + + fun gitRemoteOriginUrl(gitRemoteOriginUrl: String) = + gitRemoteOriginUrl(JsonField.of(gitRemoteOriginUrl)) + + /** + * Sets [Builder.gitRemoteOriginUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRemoteOriginUrl] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitRemoteOriginUrl(gitRemoteOriginUrl: JsonField) = apply { + this.gitRemoteOriginUrl = gitRemoteOriginUrl + } + + fun gitTags(gitTags: String) = gitTags(JsonField.of(gitTags)) + + /** + * Sets [Builder.gitTags] to an arbitrary JSON value. + * + * You should usually call [Builder.gitTags] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun gitTags(gitTags: JsonField) = apply { this.gitTags = gitTags } + + 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 [GitProperties]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GitProperties = + GitProperties( + gitBranch, + gitBuildHost, + gitBuildTime, + gitBuildUserEmail, + gitBuildUserName, + gitBuildVersion, + gitClosestTagCommitCount, + gitClosestTagName, + gitCommitId, + gitCommitIdAbbrev, + gitCommitIdDescribe, + gitCommitIdDescribeShort, + gitCommitMessageFull, + gitCommitMessageShort, + gitCommitTime, + gitCommitUserEmail, + gitCommitUserName, + gitDirty, + gitRemoteOriginUrl, + gitTags, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitProperties = apply { + if (validated) { + return@apply + } + + gitBranch() + gitBuildHost() + gitBuildTime() + gitBuildUserEmail() + gitBuildUserName() + gitBuildVersion() + gitClosestTagCommitCount() + gitClosestTagName() + gitCommitId() + gitCommitIdAbbrev() + gitCommitIdDescribe() + gitCommitIdDescribeShort() + gitCommitMessageFull() + gitCommitMessageShort() + gitCommitTime() + gitCommitUserEmail() + gitCommitUserName() + gitDirty() + gitRemoteOriginUrl() + gitTags() + 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 (gitBranch.asKnown().isPresent) 1 else 0) + + (if (gitBuildHost.asKnown().isPresent) 1 else 0) + + (if (gitBuildTime.asKnown().isPresent) 1 else 0) + + (if (gitBuildUserEmail.asKnown().isPresent) 1 else 0) + + (if (gitBuildUserName.asKnown().isPresent) 1 else 0) + + (if (gitBuildVersion.asKnown().isPresent) 1 else 0) + + (if (gitClosestTagCommitCount.asKnown().isPresent) 1 else 0) + + (if (gitClosestTagName.asKnown().isPresent) 1 else 0) + + (if (gitCommitId.asKnown().isPresent) 1 else 0) + + (if (gitCommitIdAbbrev.asKnown().isPresent) 1 else 0) + + (if (gitCommitIdDescribe.asKnown().isPresent) 1 else 0) + + (if (gitCommitIdDescribeShort.asKnown().isPresent) 1 else 0) + + (if (gitCommitMessageFull.asKnown().isPresent) 1 else 0) + + (if (gitCommitMessageShort.asKnown().isPresent) 1 else 0) + + (if (gitCommitTime.asKnown().isPresent) 1 else 0) + + (if (gitCommitUserEmail.asKnown().isPresent) 1 else 0) + + (if (gitCommitUserName.asKnown().isPresent) 1 else 0) + + (if (gitDirty.asKnown().isPresent) 1 else 0) + + (if (gitRemoteOriginUrl.asKnown().isPresent) 1 else 0) + + (if (gitTags.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitProperties && gitBranch == other.gitBranch && gitBuildHost == other.gitBuildHost && gitBuildTime == other.gitBuildTime && gitBuildUserEmail == other.gitBuildUserEmail && gitBuildUserName == other.gitBuildUserName && gitBuildVersion == other.gitBuildVersion && gitClosestTagCommitCount == other.gitClosestTagCommitCount && gitClosestTagName == other.gitClosestTagName && gitCommitId == other.gitCommitId && gitCommitIdAbbrev == other.gitCommitIdAbbrev && gitCommitIdDescribe == other.gitCommitIdDescribe && gitCommitIdDescribeShort == other.gitCommitIdDescribeShort && gitCommitMessageFull == other.gitCommitMessageFull && gitCommitMessageShort == other.gitCommitMessageShort && gitCommitTime == other.gitCommitTime && gitCommitUserEmail == other.gitCommitUserEmail && gitCommitUserName == other.gitCommitUserName && gitDirty == other.gitDirty && gitRemoteOriginUrl == other.gitRemoteOriginUrl && gitTags == other.gitTags && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(gitBranch, gitBuildHost, gitBuildTime, gitBuildUserEmail, gitBuildUserName, gitBuildVersion, gitClosestTagCommitCount, gitClosestTagName, gitCommitId, gitCommitIdAbbrev, gitCommitIdDescribe, gitCommitIdDescribeShort, gitCommitMessageFull, gitCommitMessageShort, gitCommitTime, gitCommitUserEmail, gitCommitUserName, gitDirty, gitRemoteOriginUrl, gitTags, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitProperties{gitBranch=$gitBranch, gitBuildHost=$gitBuildHost, gitBuildTime=$gitBuildTime, gitBuildUserEmail=$gitBuildUserEmail, gitBuildUserName=$gitBuildUserName, gitBuildVersion=$gitBuildVersion, gitClosestTagCommitCount=$gitClosestTagCommitCount, gitClosestTagName=$gitClosestTagName, gitCommitId=$gitCommitId, gitCommitIdAbbrev=$gitCommitIdAbbrev, gitCommitIdDescribe=$gitCommitIdDescribe, gitCommitIdDescribeShort=$gitCommitIdDescribeShort, gitCommitMessageFull=$gitCommitMessageFull, gitCommitMessageShort=$gitCommitMessageShort, gitCommitTime=$gitCommitTime, gitCommitUserEmail=$gitCommitUserEmail, gitCommitUserName=$gitCommitUserName, gitDirty=$gitDirty, gitRemoteOriginUrl=$gitRemoteOriginUrl, gitTags=$gitTags, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && gitProperties == other.gitProperties && name == other.name && serviceDateFrom == other.serviceDateFrom && serviceDateTo == other.serviceDateTo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, gitProperties, name, serviceDateFrom, serviceDateTo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, gitProperties=$gitProperties, name=$name, serviceDateFrom=$serviceDateFrom, serviceDateTo=$serviceDateTo, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is ConfigRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConfigRetrieveResponse{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/CurrentTimeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParams.kt similarity index 93% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParams.kt index dfc8416..807bd94 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/CurrentTimeRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParams.kt @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.currenttime import java.util.Objects -import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.Params import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams @@ -19,19 +18,19 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): CurrentTimeRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CurrentTimeRetrieveParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [CurrentTimeRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() @@ -141,10 +140,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [CurrentTimeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): CurrentTimeRetrieveParams = CurrentTimeRetrieveParams(additionalHeaders.build(), additionalQueryParams.build()) } + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..c95fdac --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt @@ -0,0 +1,689 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.currenttime + +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.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class CurrentTimeRetrieveResponse +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 [CurrentTimeRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentTimeRetrieveResponse]. */ + 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(currentTimeRetrieveResponse: CurrentTimeRetrieveResponse) = apply { + code = currentTimeRetrieveResponse.code + currentTime = currentTimeRetrieveResponse.currentTime + text = currentTimeRetrieveResponse.text + version = currentTimeRetrieveResponse.version + data = currentTimeRetrieveResponse.data + additionalProperties = currentTimeRetrieveResponse.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 [CurrentTimeRetrieveResponse]. + * + * 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(): CurrentTimeRetrieveResponse = + CurrentTimeRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CurrentTimeRetrieveResponse = 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 + 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 + private constructor( + private val readableTime: JsonField, + private val time: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("readableTime") + @ExcludeMissing + readableTime: JsonField = JsonMissing.of(), + @JsonProperty("time") @ExcludeMissing time: JsonField = JsonMissing.of(), + ) : this(readableTime, time, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun readableTime(): Optional = readableTime.getOptional("readableTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun time(): Optional = time.getOptional("time") + + /** + * Returns the raw JSON value of [readableTime]. + * + * Unlike [readableTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("readableTime") + @ExcludeMissing + fun _readableTime(): JsonField = readableTime + + /** + * Returns the raw JSON value of [time]. + * + * Unlike [time], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("time") @ExcludeMissing fun _time(): JsonField = time + + @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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var readableTime: JsonField = JsonMissing.of() + private var time: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + readableTime = entry.readableTime + time = entry.time + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun readableTime(readableTime: String) = readableTime(JsonField.of(readableTime)) + + /** + * Sets [Builder.readableTime] to an arbitrary JSON value. + * + * You should usually call [Builder.readableTime] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun readableTime(readableTime: JsonField) = apply { + this.readableTime = readableTime + } + + fun time(time: Long) = time(JsonField.of(time)) + + /** + * Sets [Builder.time] to an arbitrary JSON value. + * + * You should usually call [Builder.time] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun time(time: JsonField) = apply { this.time = time } + + 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. + */ + fun build(): Entry = Entry(readableTime, time, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + readableTime() + time() + 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 (readableTime.asKnown().isPresent) 1 else 0) + + (if (time.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && readableTime == other.readableTime && time == other.time && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(readableTime, time, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{readableTime=$readableTime, time=$time, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is CurrentTimeRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentTimeRetrieveResponse{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/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt similarity index 71% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt index 9e9afca..65126fe 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt @@ -1,15 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.reportproblemwithstop import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Enum import org.onebusaway.core.JsonField -import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.Params -import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams import org.onebusaway.errors.OnebusawaySdkInvalidDataException @@ -17,17 +16,17 @@ import org.onebusaway.errors.OnebusawaySdkInvalidDataException /** Submit a user-generated problem report for a stop */ class ReportProblemWithStopRetrieveParams private constructor( - private val stopId: String, + private val stopId: String?, private val code: Code?, private val userComment: String?, - private val userLat: Double?, - private val userLocationAccuracy: Double?, - private val userLon: Double?, + private val userLat: Float?, + private val userLocationAccuracy: Float?, + private val userLon: Float?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun stopId(): String = stopId + fun stopId(): Optional = Optional.ofNullable(stopId) /** A string code identifying the nature of the problem */ fun code(): Optional = Optional.ofNullable(code) @@ -36,57 +35,40 @@ private constructor( fun userComment(): Optional = Optional.ofNullable(userComment) /** The reporting user’s current latitude */ - fun userLat(): Optional = Optional.ofNullable(userLat) + fun userLat(): Optional = Optional.ofNullable(userLat) /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(): Optional = Optional.ofNullable(userLocationAccuracy) + fun userLocationAccuracy(): Optional = Optional.ofNullable(userLocationAccuracy) /** The reporting user’s current longitude */ - fun userLon(): Optional = Optional.ofNullable(userLon) + fun userLon(): Optional = Optional.ofNullable(userLon) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.code?.let { queryParams.put("code", listOf(it.toString())) } - this.userComment?.let { queryParams.put("userComment", listOf(it.toString())) } - this.userLat?.let { queryParams.put("userLat", listOf(it.toString())) } - this.userLocationAccuracy?.let { - queryParams.put("userLocationAccuracy", listOf(it.toString())) - } - this.userLon?.let { queryParams.put("userLon", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): ReportProblemWithStopRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ReportProblemWithStopRetrieveParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [ReportProblemWithStopRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var stopId: String? = null private var code: Code? = null private var userComment: String? = null - private var userLat: Double? = null - private var userLocationAccuracy: Double? = null - private var userLon: Double? = null + private var userLat: Float? = null + private var userLocationAccuracy: Float? = null + private var userLon: Float? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -105,53 +87,68 @@ private constructor( reportProblemWithStopRetrieveParams.additionalQueryParams.toBuilder() } - fun stopId(stopId: String) = apply { this.stopId = stopId } + fun stopId(stopId: String?) = apply { this.stopId = stopId } + + /** Alias for calling [Builder.stopId] with `stopId.orElse(null)`. */ + fun stopId(stopId: Optional) = stopId(stopId.getOrNull()) /** A string code identifying the nature of the problem */ fun code(code: Code?) = apply { this.code = code } - /** A string code identifying the nature of the problem */ - fun code(code: Optional) = code(code.orElse(null)) + /** Alias for calling [Builder.code] with `code.orElse(null)`. */ + fun code(code: Optional) = code(code.getOrNull()) /** Additional comment text supplied by the user describing the problem */ fun userComment(userComment: String?) = apply { this.userComment = userComment } - /** Additional comment text supplied by the user describing the problem */ - fun userComment(userComment: Optional) = userComment(userComment.orElse(null)) + /** Alias for calling [Builder.userComment] with `userComment.orElse(null)`. */ + fun userComment(userComment: Optional) = userComment(userComment.getOrNull()) /** The reporting user’s current latitude */ - fun userLat(userLat: Double?) = apply { this.userLat = userLat } + fun userLat(userLat: Float?) = apply { this.userLat = userLat } - /** The reporting user’s current latitude */ - fun userLat(userLat: Double) = userLat(userLat as Double?) + /** + * Alias for [Builder.userLat]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLat(userLat: Float) = userLat(userLat as Float?) - /** The reporting user’s current latitude */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun userLat(userLat: Optional) = userLat(userLat.orElse(null) as Double?) + /** Alias for calling [Builder.userLat] with `userLat.orElse(null)`. */ + fun userLat(userLat: Optional) = userLat(userLat.getOrNull()) /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(userLocationAccuracy: Double?) = apply { + fun userLocationAccuracy(userLocationAccuracy: Float?) = apply { this.userLocationAccuracy = userLocationAccuracy } - /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(userLocationAccuracy: Double) = - userLocationAccuracy(userLocationAccuracy as Double?) + /** + * Alias for [Builder.userLocationAccuracy]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLocationAccuracy(userLocationAccuracy: Float) = + userLocationAccuracy(userLocationAccuracy as Float?) - /** The reporting user’s location accuracy, in meters */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun userLocationAccuracy(userLocationAccuracy: Optional) = - userLocationAccuracy(userLocationAccuracy.orElse(null) as Double?) + /** + * Alias for calling [Builder.userLocationAccuracy] with + * `userLocationAccuracy.orElse(null)`. + */ + fun userLocationAccuracy(userLocationAccuracy: Optional) = + userLocationAccuracy(userLocationAccuracy.getOrNull()) /** The reporting user’s current longitude */ - fun userLon(userLon: Double?) = apply { this.userLon = userLon } + fun userLon(userLon: Float?) = apply { this.userLon = userLon } - /** The reporting user’s current longitude */ - fun userLon(userLon: Double) = userLon(userLon as Double?) + /** + * Alias for [Builder.userLon]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLon(userLon: Float) = userLon(userLon as Float?) - /** The reporting user’s current longitude */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun userLon(userLon: Optional) = userLon(userLon.orElse(null) as Double?) + /** Alias for calling [Builder.userLon] with `userLon.orElse(null)`. */ + fun userLon(userLon: Optional) = userLon(userLon.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -251,9 +248,14 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ReportProblemWithStopRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams( - checkRequired("stopId", stopId), + stopId, code, userComment, userLat, @@ -264,12 +266,28 @@ private constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> stopId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + code?.let { put("code", it.toString()) } + userComment?.let { put("userComment", it) } + userLat?.let { put("userLat", it.toString()) } + userLocationAccuracy?.let { put("userLocationAccuracy", it.toString()) } + userLon?.let { put("userLon", it.toString()) } + putAll(additionalQueryParams) + } + .build() + /** A string code identifying the nature of the problem */ - class Code - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Code @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -360,7 +378,46 @@ private constructor( else -> throw OnebusawaySdkInvalidDataException("Unknown Code: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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(): Code = 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) { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt similarity index 71% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt index 213acd1..beba906 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt @@ -1,15 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.reportproblemwithtrip import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Enum import org.onebusaway.core.JsonField -import org.onebusaway.core.NoAutoDetect import org.onebusaway.core.Params -import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers import org.onebusaway.core.http.QueryParams import org.onebusaway.errors.OnebusawaySdkInvalidDataException @@ -17,14 +16,14 @@ import org.onebusaway.errors.OnebusawaySdkInvalidDataException /** Submit a user-generated problem report for a particular trip. */ class ReportProblemWithTripRetrieveParams private constructor( - private val tripId: String, + private val tripId: String?, private val code: Code?, private val serviceDate: Long?, private val stopId: String?, private val userComment: String?, - private val userLat: Double?, - private val userLocationAccuracy: Double?, - private val userLon: Double?, + private val userLat: Float?, + private val userLocationAccuracy: Float?, + private val userLon: Float?, private val userOnVehicle: Boolean?, private val userVehicleNumber: String?, private val vehicleId: String?, @@ -32,7 +31,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun tripId(): String = tripId + fun tripId(): Optional = Optional.ofNullable(tripId) /** A string code identifying the nature of the problem */ fun code(): Optional = Optional.ofNullable(code) @@ -47,13 +46,13 @@ private constructor( fun userComment(): Optional = Optional.ofNullable(userComment) /** The reporting user’s current latitude */ - fun userLat(): Optional = Optional.ofNullable(userLat) + fun userLat(): Optional = Optional.ofNullable(userLat) /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(): Optional = Optional.ofNullable(userLocationAccuracy) + fun userLocationAccuracy(): Optional = Optional.ofNullable(userLocationAccuracy) /** The reporting user’s current longitude */ - fun userLon(): Optional = Optional.ofNullable(userLon) + fun userLon(): Optional = Optional.ofNullable(userLon) /** Indicator if the user is on the transit vehicle experiencing the problem */ fun userOnVehicle(): Optional = Optional.ofNullable(userOnVehicle) @@ -68,42 +67,20 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.code?.let { queryParams.put("code", listOf(it.toString())) } - this.serviceDate?.let { queryParams.put("serviceDate", listOf(it.toString())) } - this.stopId?.let { queryParams.put("stopID", listOf(it.toString())) } - this.userComment?.let { queryParams.put("userComment", listOf(it.toString())) } - this.userLat?.let { queryParams.put("userLat", listOf(it.toString())) } - this.userLocationAccuracy?.let { - queryParams.put("userLocationAccuracy", listOf(it.toString())) - } - this.userLon?.let { queryParams.put("userLon", listOf(it.toString())) } - this.userOnVehicle?.let { queryParams.put("userOnVehicle", listOf(it.toString())) } - this.userVehicleNumber?.let { queryParams.put("userVehicleNumber", listOf(it.toString())) } - this.vehicleId?.let { queryParams.put("vehicleID", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> tripId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): ReportProblemWithTripRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ReportProblemWithTripRetrieveParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [ReportProblemWithTripRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var tripId: String? = null @@ -111,9 +88,9 @@ private constructor( private var serviceDate: Long? = null private var stopId: String? = null private var userComment: String? = null - private var userLat: Double? = null - private var userLocationAccuracy: Double? = null - private var userLon: Double? = null + private var userLat: Float? = null + private var userLocationAccuracy: Float? = null + private var userLon: Float? = null private var userOnVehicle: Boolean? = null private var userVehicleNumber: String? = null private var vehicleId: String? = null @@ -140,96 +117,116 @@ private constructor( reportProblemWithTripRetrieveParams.additionalQueryParams.toBuilder() } - fun tripId(tripId: String) = apply { this.tripId = tripId } + fun tripId(tripId: String?) = apply { this.tripId = tripId } + + /** Alias for calling [Builder.tripId] with `tripId.orElse(null)`. */ + fun tripId(tripId: Optional) = tripId(tripId.getOrNull()) /** A string code identifying the nature of the problem */ fun code(code: Code?) = apply { this.code = code } - /** A string code identifying the nature of the problem */ - fun code(code: Optional) = code(code.orElse(null)) + /** Alias for calling [Builder.code] with `code.orElse(null)`. */ + fun code(code: Optional) = code(code.getOrNull()) /** The service date of the trip */ fun serviceDate(serviceDate: Long?) = apply { this.serviceDate = serviceDate } - /** The service date of the trip */ + /** + * Alias for [Builder.serviceDate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun serviceDate(serviceDate: Long) = serviceDate(serviceDate as Long?) - /** The service date of the trip */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun serviceDate(serviceDate: Optional) = - serviceDate(serviceDate.orElse(null) as Long?) + /** Alias for calling [Builder.serviceDate] with `serviceDate.orElse(null)`. */ + fun serviceDate(serviceDate: Optional) = serviceDate(serviceDate.getOrNull()) /** A stop ID indicating where the user is experiencing the problem */ fun stopId(stopId: String?) = apply { this.stopId = stopId } - /** A stop ID indicating where the user is experiencing the problem */ - fun stopId(stopId: Optional) = stopId(stopId.orElse(null)) + /** Alias for calling [Builder.stopId] with `stopId.orElse(null)`. */ + fun stopId(stopId: Optional) = stopId(stopId.getOrNull()) /** Additional comment text supplied by the user describing the problem */ fun userComment(userComment: String?) = apply { this.userComment = userComment } - /** Additional comment text supplied by the user describing the problem */ - fun userComment(userComment: Optional) = userComment(userComment.orElse(null)) + /** Alias for calling [Builder.userComment] with `userComment.orElse(null)`. */ + fun userComment(userComment: Optional) = userComment(userComment.getOrNull()) /** The reporting user’s current latitude */ - fun userLat(userLat: Double?) = apply { this.userLat = userLat } + fun userLat(userLat: Float?) = apply { this.userLat = userLat } - /** The reporting user’s current latitude */ - fun userLat(userLat: Double) = userLat(userLat as Double?) + /** + * Alias for [Builder.userLat]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLat(userLat: Float) = userLat(userLat as Float?) - /** The reporting user’s current latitude */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun userLat(userLat: Optional) = userLat(userLat.orElse(null) as Double?) + /** Alias for calling [Builder.userLat] with `userLat.orElse(null)`. */ + fun userLat(userLat: Optional) = userLat(userLat.getOrNull()) /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(userLocationAccuracy: Double?) = apply { + fun userLocationAccuracy(userLocationAccuracy: Float?) = apply { this.userLocationAccuracy = userLocationAccuracy } - /** The reporting user’s location accuracy, in meters */ - fun userLocationAccuracy(userLocationAccuracy: Double) = - userLocationAccuracy(userLocationAccuracy as Double?) + /** + * Alias for [Builder.userLocationAccuracy]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLocationAccuracy(userLocationAccuracy: Float) = + userLocationAccuracy(userLocationAccuracy as Float?) - /** The reporting user’s location accuracy, in meters */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun userLocationAccuracy(userLocationAccuracy: Optional) = - userLocationAccuracy(userLocationAccuracy.orElse(null) as Double?) + /** + * Alias for calling [Builder.userLocationAccuracy] with + * `userLocationAccuracy.orElse(null)`. + */ + fun userLocationAccuracy(userLocationAccuracy: Optional) = + userLocationAccuracy(userLocationAccuracy.getOrNull()) /** The reporting user’s current longitude */ - fun userLon(userLon: Double?) = apply { this.userLon = userLon } + fun userLon(userLon: Float?) = apply { this.userLon = userLon } - /** The reporting user’s current longitude */ - fun userLon(userLon: Double) = userLon(userLon as Double?) + /** + * Alias for [Builder.userLon]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLon(userLon: Float) = userLon(userLon as Float?) - /** The reporting user’s current longitude */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun userLon(userLon: Optional) = userLon(userLon.orElse(null) as Double?) + /** Alias for calling [Builder.userLon] with `userLon.orElse(null)`. */ + fun userLon(userLon: Optional) = userLon(userLon.getOrNull()) /** Indicator if the user is on the transit vehicle experiencing the problem */ fun userOnVehicle(userOnVehicle: Boolean?) = apply { this.userOnVehicle = userOnVehicle } - /** Indicator if the user is on the transit vehicle experiencing the problem */ + /** + * Alias for [Builder.userOnVehicle]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun userOnVehicle(userOnVehicle: Boolean) = userOnVehicle(userOnVehicle as Boolean?) - /** Indicator if the user is on the transit vehicle experiencing the problem */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.userOnVehicle] with `userOnVehicle.orElse(null)`. */ fun userOnVehicle(userOnVehicle: Optional) = - userOnVehicle(userOnVehicle.orElse(null) as Boolean?) + userOnVehicle(userOnVehicle.getOrNull()) /** The vehicle number, as reported by the user */ fun userVehicleNumber(userVehicleNumber: String?) = apply { this.userVehicleNumber = userVehicleNumber } - /** The vehicle number, as reported by the user */ + /** Alias for calling [Builder.userVehicleNumber] with `userVehicleNumber.orElse(null)`. */ fun userVehicleNumber(userVehicleNumber: Optional) = - userVehicleNumber(userVehicleNumber.orElse(null)) + userVehicleNumber(userVehicleNumber.getOrNull()) /** The vehicle actively serving the trip */ fun vehicleId(vehicleId: String?) = apply { this.vehicleId = vehicleId } - /** The vehicle actively serving the trip */ - fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.orElse(null)) + /** Alias for calling [Builder.vehicleId] with `vehicleId.orElse(null)`. */ + fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -329,9 +326,14 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ReportProblemWithTripRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams( - checkRequired("tripId", tripId), + tripId, code, serviceDate, stopId, @@ -347,12 +349,33 @@ private constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> tripId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + code?.let { put("code", it.toString()) } + serviceDate?.let { put("serviceDate", it.toString()) } + stopId?.let { put("stopID", it) } + userComment?.let { put("userComment", it) } + userLat?.let { put("userLat", it.toString()) } + userLocationAccuracy?.let { put("userLocationAccuracy", it.toString()) } + userLon?.let { put("userLon", it.toString()) } + userOnVehicle?.let { put("userOnVehicle", it.toString()) } + userVehicleNumber?.let { put("userVehicleNumber", it) } + vehicleId?.let { put("vehicleID", it) } + putAll(additionalQueryParams) + } + .build() + /** A string code identifying the nature of the problem */ - class Code - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Code @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -449,7 +472,46 @@ private constructor( else -> throw OnebusawaySdkInvalidDataException("Unknown Code: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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(): Code = 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) { diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveParams.kt similarity index 85% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveParams.kt index 3f67683..dd999b1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveParams.kt @@ -1,48 +1,39 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.route import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Retrieve information for a specific route identified by its unique ID. */ class RouteRetrieveParams private constructor( - private val routeId: String, + private val routeId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun routeId(): String = routeId + fun routeId(): Optional = Optional.ofNullable(routeId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> routeId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): RouteRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RouteRetrieveParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [RouteRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var routeId: String? = null @@ -56,7 +47,10 @@ private constructor( additionalQueryParams = routeRetrieveParams.additionalQueryParams.toBuilder() } - fun routeId(routeId: String) = apply { this.routeId = routeId } + fun routeId(routeId: String?) = apply { this.routeId = routeId } + + /** Alias for calling [Builder.routeId] with `routeId.orElse(null)`. */ + fun routeId(routeId: Optional) = routeId(routeId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +150,25 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RouteRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): RouteRetrieveParams = - RouteRetrieveParams( - checkRequired("routeId", routeId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + RouteRetrieveParams(routeId, additionalHeaders.build(), additionalQueryParams.build()) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> routeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..6a07eea --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt @@ -0,0 +1,1000 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.route + +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.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class RouteRetrieveResponse +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 [RouteRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouteRetrieveResponse]. */ + 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(routeRetrieveResponse: RouteRetrieveResponse) = apply { + code = routeRetrieveResponse.code + currentTime = routeRetrieveResponse.currentTime + text = routeRetrieveResponse.text + version = routeRetrieveResponse.version + data = routeRetrieveResponse.data + additionalProperties = routeRetrieveResponse.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 [RouteRetrieveResponse]. + * + * 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(): RouteRetrieveResponse = + RouteRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RouteRetrieveResponse = 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 + 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 + private constructor( + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + 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 agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @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 type(): Long = type.getRequired("type") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * 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 [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * 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 + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nullSafeShortName") + @ExcludeMissing + fun _nullSafeShortName(): JsonField = nullSafeShortName + + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName + + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 + * .id() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var longName: JsonField = JsonMissing.of() + private var nullSafeShortName: JsonField = JsonMissing.of() + private var shortName: JsonField = JsonMissing.of() + private var textColor: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + agencyId = entry.agencyId + type = entry.type + color = entry.color + description = entry.description + longName = entry.longName + nullSafeShortName = entry.nullSafeShortName + shortName = entry.shortName + textColor = entry.textColor + url = entry.url + additionalProperties = entry.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 agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun type(type: Long) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] 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 color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun longName(longName: String) = longName(JsonField.of(longName)) + + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun longName(longName: JsonField) = apply { this.longName = longName } + + fun nullSafeShortName(nullSafeShortName: String) = + nullSafeShortName(JsonField.of(nullSafeShortName)) + + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nullSafeShortName(nullSafeShortName: JsonField) = apply { + this.nullSafeShortName = nullSafeShortName + } + + fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shortName(shortName: JsonField) = apply { this.shortName = shortName } + + fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColor(textColor: JsonField) = apply { this.textColor = textColor } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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 + * .id() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + 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 (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is RouteRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouteRetrieveResponse{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/RouteIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParams.kt similarity index 86% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParams.kt index df3aead..f599b99 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RouteIdsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParams.kt @@ -1,48 +1,41 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.routeidsforagency import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Get route IDs for a specific agency */ class RouteIdsForAgencyListParams private constructor( - private val agencyId: String, + private val agencyId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun agencyId(): String = agencyId + fun agencyId(): Optional = Optional.ofNullable(agencyId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): RouteIdsForAgencyListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [RouteIdsForAgencyListParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [RouteIdsForAgencyListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var agencyId: String? = null @@ -56,7 +49,10 @@ private constructor( additionalQueryParams = routeIdsForAgencyListParams.additionalQueryParams.toBuilder() } - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun agencyId(agencyId: String?) = apply { this.agencyId = agencyId } + + /** Alias for calling [Builder.agencyId] with `agencyId.orElse(null)`. */ + fun agencyId(agencyId: Optional) = agencyId(agencyId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +152,29 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RouteIdsForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): RouteIdsForAgencyListParams = RouteIdsForAgencyListParams( - checkRequired("agencyId", agencyId), + agencyId, additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> agencyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..f1077e5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt @@ -0,0 +1,566 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routeidsforagency + +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 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 RouteIdsForAgencyListResponse +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 + * [RouteIdsForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouteIdsForAgencyListResponse]. */ + 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(routeIdsForAgencyListResponse: RouteIdsForAgencyListResponse) = apply { + code = routeIdsForAgencyListResponse.code + currentTime = routeIdsForAgencyListResponse.currentTime + text = routeIdsForAgencyListResponse.text + version = routeIdsForAgencyListResponse.version + data = routeIdsForAgencyListResponse.data + additionalProperties = routeIdsForAgencyListResponse.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 [RouteIdsForAgencyListResponse]. + * + * 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(): RouteIdsForAgencyListResponse = + RouteIdsForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RouteIdsForAgencyListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: 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") + + /** + * @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") + + /** + * @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 [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 + + @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 + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: String) = 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 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 + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list() + 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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.size ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RouteIdsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RouteIdsForAgencyListResponse{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/RoutesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParams.kt similarity index 86% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParams.kt index 1f6cb50..4f0bb91 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParams.kt @@ -1,48 +1,41 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.routesforagency import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Retrieve the list of all routes for a particular agency by id */ class RoutesForAgencyListParams private constructor( - private val agencyId: String, + private val agencyId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun agencyId(): String = agencyId + fun agencyId(): Optional = Optional.ofNullable(agencyId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): RoutesForAgencyListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [RoutesForAgencyListParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [RoutesForAgencyListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var agencyId: String? = null @@ -56,7 +49,10 @@ private constructor( additionalQueryParams = routesForAgencyListParams.additionalQueryParams.toBuilder() } - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun agencyId(agencyId: String?) = apply { this.agencyId = agencyId } + + /** Alias for calling [Builder.agencyId] with `agencyId.orElse(null)`. */ + fun agencyId(agencyId: Optional) = agencyId(agencyId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +152,29 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RoutesForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): RoutesForAgencyListParams = RoutesForAgencyListParams( - checkRequired("agencyId", agencyId), + agencyId, additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> agencyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..ff092f7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt @@ -0,0 +1,1060 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforagency + +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 RoutesForAgencyListResponse +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 [RoutesForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutesForAgencyListResponse]. */ + 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(routesForAgencyListResponse: RoutesForAgencyListResponse) = apply { + code = routesForAgencyListResponse.code + currentTime = routesForAgencyListResponse.currentTime + text = routesForAgencyListResponse.text + version = routesForAgencyListResponse.version + data = routesForAgencyListResponse.data + additionalProperties = routesForAgencyListResponse.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 [RoutesForAgencyListResponse]. + * + * 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(): RoutesForAgencyListResponse = + RoutesForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RoutesForAgencyListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: 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") + + /** + * @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") + + /** + * 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 + + @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 + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + 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 agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @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 type(): Long = type.getRequired("type") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * 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 [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * 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 + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nullSafeShortName") + @ExcludeMissing + fun _nullSafeShortName(): JsonField = nullSafeShortName + + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName + + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var longName: JsonField = JsonMissing.of() + private var nullSafeShortName: JsonField = JsonMissing.of() + private var shortName: JsonField = JsonMissing.of() + private var textColor: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + agencyId = list.agencyId + type = list.type + color = list.color + description = list.description + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + url = list.url + 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 agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun type(type: Long) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] 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 color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun longName(longName: String) = longName(JsonField.of(longName)) + + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun longName(longName: JsonField) = apply { this.longName = longName } + + fun nullSafeShortName(nullSafeShortName: String) = + nullSafeShortName(JsonField.of(nullSafeShortName)) + + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nullSafeShortName(nullSafeShortName: JsonField) = apply { + this.nullSafeShortName = nullSafeShortName + } + + fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shortName(shortName: JsonField) = apply { this.shortName = shortName } + + fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColor(textColor: JsonField) = apply { this.textColor = textColor } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + 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 (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoutesForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutesForAgencyListResponse{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/RoutesForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParams.kt similarity index 78% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParams.kt index 69461ad..73bc6d9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/RoutesForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.routesforlocation import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Params import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers @@ -39,29 +39,23 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.lat.let { queryParams.put("lat", listOf(it.toString())) } - this.lon.let { queryParams.put("lon", listOf(it.toString())) } - this.latSpan?.let { queryParams.put("latSpan", listOf(it.toString())) } - this.lonSpan?.let { queryParams.put("lonSpan", listOf(it.toString())) } - this.query?.let { queryParams.put("query", listOf(it.toString())) } - this.radius?.let { queryParams.put("radius", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [RoutesForLocationListParams]. + * + * The following fields are required: + * ```java + * .lat() + * .lon() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [RoutesForLocationListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var lat: Double? = null @@ -91,28 +85,44 @@ private constructor( 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?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun latSpan(latSpan: Optional) = latSpan(latSpan.orElse(null) as Double?) + /** Alias for calling [Builder.latSpan] with `latSpan.orElse(null)`. */ + fun latSpan(latSpan: Optional) = latSpan(latSpan.getOrNull()) 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?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.orElse(null) as Double?) + /** Alias for calling [Builder.lonSpan] with `lonSpan.orElse(null)`. */ + fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.getOrNull()) fun query(query: String?) = apply { this.query = query } - fun query(query: Optional) = query(query.orElse(null)) + /** Alias for calling [Builder.query] with `query.orElse(null)`. */ + fun query(query: Optional) = query(query.getOrNull()) 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?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun radius(radius: Optional) = radius(radius.orElse(null) as Double?) + /** Alias for calling [Builder.radius] with `radius.orElse(null)`. */ + fun radius(radius: Optional) = radius(radius.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -212,6 +222,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RoutesForLocationListParams]. + * + * 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(): RoutesForLocationListParams = RoutesForLocationListParams( checkRequired("lat", lat), @@ -225,6 +248,21 @@ private constructor( ) } + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("lat", lat.toString()) + put("lon", lon.toString()) + latSpan?.let { put("latSpan", it.toString()) } + lonSpan?.let { put("lonSpan", it.toString()) } + query?.let { put("query", it) } + radius?.let { put("radius", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..3aab1b2 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt @@ -0,0 +1,1098 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforlocation + +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 RoutesForLocationListResponse +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 + * [RoutesForLocationListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutesForLocationListResponse]. */ + 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(routesForLocationListResponse: RoutesForLocationListResponse) = apply { + code = routesForLocationListResponse.code + currentTime = routesForLocationListResponse.currentTime + text = routesForLocationListResponse.text + version = routesForLocationListResponse.version + data = routesForLocationListResponse.data + additionalProperties = routesForLocationListResponse.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 [RoutesForLocationListResponse]. + * + * 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(): RoutesForLocationListResponse = + RoutesForLocationListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RoutesForLocationListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + @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") + + /** + * @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 outOfRange(): Boolean = outOfRange.getRequired("outOfRange") + + /** + * @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 [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 [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + /** + * 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 + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 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 + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 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 + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + 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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + 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 agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @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 type(): Long = type.getRequired("type") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * 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 [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * 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 + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nullSafeShortName") + @ExcludeMissing + fun _nullSafeShortName(): JsonField = nullSafeShortName + + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName + + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var longName: JsonField = JsonMissing.of() + private var nullSafeShortName: JsonField = JsonMissing.of() + private var shortName: JsonField = JsonMissing.of() + private var textColor: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + agencyId = list.agencyId + type = list.type + color = list.color + description = list.description + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + url = list.url + 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 agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun type(type: Long) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] 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 color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun longName(longName: String) = longName(JsonField.of(longName)) + + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun longName(longName: JsonField) = apply { this.longName = longName } + + fun nullSafeShortName(nullSafeShortName: String) = + nullSafeShortName(JsonField.of(nullSafeShortName)) + + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nullSafeShortName(nullSafeShortName: JsonField) = apply { + this.nullSafeShortName = nullSafeShortName + } + + fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shortName(shortName: JsonField) = apply { this.shortName = shortName } + + fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColor(textColor: JsonField) = apply { this.textColor = textColor } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + 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 (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoutesForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutesForLocationListResponse{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/ScheduleForRouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParams.kt similarity index 83% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParams.kt index 288fae3..510aa18 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParams.kt @@ -1,26 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.scheduleforroute import java.time.LocalDate import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +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 /** Retrieve the full schedule for a route on a particular day */ class ScheduleForRouteRetrieveParams private constructor( - private val routeId: String, + private val routeId: String?, private val date: LocalDate?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun routeId(): String = routeId + fun routeId(): Optional = Optional.ofNullable(routeId) /** * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, @@ -32,31 +31,20 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.date?.let { queryParams.put("date", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> routeId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): ScheduleForRouteRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleForRouteRetrieveParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [ScheduleForRouteRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var routeId: String? = null @@ -72,7 +60,10 @@ private constructor( additionalQueryParams = scheduleForRouteRetrieveParams.additionalQueryParams.toBuilder() } - fun routeId(routeId: String) = apply { this.routeId = routeId } + fun routeId(routeId: String?) = apply { this.routeId = routeId } + + /** Alias for calling [Builder.routeId] with `routeId.orElse(null)`. */ + fun routeId(routeId: Optional) = routeId(routeId.getOrNull()) /** * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, @@ -80,11 +71,8 @@ private constructor( */ fun date(date: LocalDate?) = apply { this.date = date } - /** - * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, - * defaults to current date) - */ - fun date(date: Optional) = date(date.orElse(null)) + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -184,15 +172,36 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ScheduleForRouteRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams( - checkRequired("routeId", routeId), + routeId, date, additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> routeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + date?.let { put("date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..85a3f93 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt @@ -0,0 +1,3102 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforroute + +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.ResponseWrapper + +class ScheduleForRouteRetrieveResponse +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 + * [ScheduleForRouteRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleForRouteRetrieveResponse]. */ + 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(scheduleForRouteRetrieveResponse: ScheduleForRouteRetrieveResponse) = + apply { + code = scheduleForRouteRetrieveResponse.code + currentTime = scheduleForRouteRetrieveResponse.currentTime + text = scheduleForRouteRetrieveResponse.text + version = scheduleForRouteRetrieveResponse.version + data = scheduleForRouteRetrieveResponse.data + additionalProperties = + scheduleForRouteRetrieveResponse.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 [ScheduleForRouteRetrieveResponse]. + * + * 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(): ScheduleForRouteRetrieveResponse = + ScheduleForRouteRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScheduleForRouteRetrieveResponse = 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 + private constructor( + private val entry: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of() + ) : this(entry, 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") + + /** + * 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 + + @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() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + 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 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() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data(checkRequired("entry", entry), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().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) + + class Entry + 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, + ) { + + @JsonCreator + private constructor( + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDate") + @ExcludeMissing + scheduleDate: JsonField = JsonMissing.of(), + @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(), + ) + + /** + * @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 scheduleDate(): Long = scheduleDate.getRequired("scheduleDate") + + /** + * @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 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 + * value). + */ + 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]. + * + * 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 [scheduleDate]. + * + * Unlike [scheduleDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scheduleDate") + @ExcludeMissing + fun _scheduleDate(): JsonField = scheduleDate + + /** + * Returns the raw JSON value of [serviceIds]. + * + * Unlike [serviceIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("serviceIds") + @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]. + * + * Unlike [stopTripGroupings], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopTripGroupings") + @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) + } + + @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 + * .routeId() + * .scheduleDate() + * .serviceIds() + * .stops() + * .stopTripGroupings() + * .trips() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal 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 + internal fun from(entry: Entry) = apply { + 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() + } + + 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 scheduleDate(scheduleDate: Long) = scheduleDate(JsonField.of(scheduleDate)) + + /** + * Sets [Builder.scheduleDate] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scheduleDate(scheduleDate: JsonField) = apply { + this.scheduleDate = scheduleDate + } + + fun serviceIds(serviceIds: List) = serviceIds(JsonField.of(serviceIds)) + + /** + * Sets [Builder.serviceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun serviceIds(serviceIds: JsonField>) = apply { + this.serviceIds = serviceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [serviceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addServiceId(serviceId: String) = apply { + serviceIds = + (serviceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("serviceIds", it).add(serviceId) + } + } + + 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)) + + /** + * Sets [Builder.stopTripGroupings] to an arbitrary JSON value. + * + * You should usually call [Builder.stopTripGroupings] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopTripGroupings(stopTripGroupings: JsonField>) = + apply { + this.stopTripGroupings = stopTripGroupings.map { it.toMutableList() } + } + + /** + * Adds a single [StopTripGrouping] to [stopTripGroupings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopTripGrouping(stopTripGrouping: StopTripGrouping) = apply { + stopTripGroupings = + (stopTripGroupings ?: JsonField.of(mutableListOf())).also { + checkKnown("stopTripGroupings", it).add(stopTripGrouping) + } + } + + 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) + } + + 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 + * .routeId() + * .scheduleDate() + * .serviceIds() + * .stops() + * .stopTripGroupings() + * .trips() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + 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(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + routeId() + scheduleDate() + serviceIds() + stops().forEach { it.validate() } + stopTripGroupings().forEach { it.validate() } + trips().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 (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) + + class Stop + 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, + 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") + + /** + * @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(): 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(): 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 [Stop]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Stop]. */ + 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(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() + } + + 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: 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: 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 [Stop]. + * + * 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(): 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, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Stop = 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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + 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}" + } + + class StopTripGrouping + 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, + ) { + + @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") + @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") + + /** + * @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 or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + 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 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 tripsWithStopTimes(): Optional> = + tripsWithStopTimes.getOptional("tripsWithStopTimes") + + /** + * 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 [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 [tripHeadsigns]. + * + * Unlike [tripHeadsigns], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripHeadsigns") + @ExcludeMissing + fun _tripHeadsigns(): JsonField> = tripHeadsigns + + /** + * 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 + + /** + * 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 + + @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 [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() + + @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() + } + + fun directionId(directionId: String) = directionId(JsonField.of(directionId)) + + /** + * 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 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 tripHeadsigns(tripHeadsigns: List) = + tripHeadsigns(JsonField.of(tripHeadsigns)) + + /** + * 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() } + } + + /** + * 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) + } + } + + fun tripIds(tripIds: List) = tripIds(JsonField.of(tripIds)) + + /** + * 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() } + } + + /** + * 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) + } + } + + 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() } + } + + /** + * Adds a single [TripsWithStopTime] to [tripsWithStopTimes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + 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) + } + + 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 [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(), + ) + } + + 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 + 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) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TripsWithStopTime]. + * + * The following fields are required: + * ```java + * .stopTimes() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripsWithStopTime]. */ + class Builder internal constructor() { + + private var stopTimes: JsonField>? = null + private var tripId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tripsWithStopTime: TripsWithStopTime) = apply { + stopTimes = tripsWithStopTime.stopTimes.map { it.toMutableList() } + tripId = tripsWithStopTime.tripId + additionalProperties = + tripsWithStopTime.additionalProperties.toMutableMap() + } + + fun stopTimes(stopTimes: List) = + stopTimes(JsonField.of(stopTimes)) + + /** + * 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() } + } + + /** + * 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 + 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]. + * + * 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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, stopId, tripId, serviceId, stopHeadsign, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is TripsWithStopTime && stopTimes == other.stopTimes && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(stopTimes, tripId, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is StopTripGrouping && directionId == other.directionId && stopIds == other.stopIds && tripHeadsigns == other.tripHeadsigns && tripIds == other.tripIds && tripsWithStopTimes == other.tripsWithStopTimes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(directionId, stopIds, tripHeadsigns, tripIds, tripsWithStopTimes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" + } + + class Trip + 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") + + /** + * 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 [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 [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 [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 [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 [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 [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 [shapeId]. + * + * Unlike [shapeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId + + /** + * 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 + + /** + * 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 [tripShortName]. + * + * Unlike [tripShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripShortName") + @ExcludeMissing + fun _tripShortName(): JsonField = tripShortName + + @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 [Trip]. + * + * The following fields are required: + * ```java + * .id() + * .routeId() + * .serviceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Trip]. */ + class Builder internal constructor() { + + 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() + + @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 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 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 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 blockId(blockId: String) = blockId(JsonField.of(blockId)) + + /** + * 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 directionId(directionId: String) = directionId(JsonField.of(directionId)) + + /** + * 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 peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) + + /** + * 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 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 + } + + fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) + + /** + * 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 timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * 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 } + + 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 + } + + fun tripShortName(tripShortName: String) = + tripShortName(JsonField.of(tripShortName)) + + /** + * 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 + } + + 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 [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 + + fun validate(): Trip = apply { + if (validated) { + return@apply + } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + 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 (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 equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Trip && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + /* spotless:on */ + + 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}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && routeId == other.routeId && scheduleDate == other.scheduleDate && serviceIds == other.serviceIds && stops == other.stops && stopTripGroupings == other.stopTripGroupings && trips == other.trips && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(routeId, scheduleDate, serviceIds, stops, stopTripGroupings, trips, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{routeId=$routeId, scheduleDate=$scheduleDate, serviceIds=$serviceIds, stops=$stops, stopTripGroupings=$stopTripGroupings, trips=$trips, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{entry=$entry, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleForRouteRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleForRouteRetrieveResponse{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/ScheduleForStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParams.kt similarity index 84% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParams.kt index 5ec1ae9..9500f26 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParams.kt @@ -1,26 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.scheduleforstop import java.time.LocalDate import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +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 /** Get schedule for a specific stop */ class ScheduleForStopRetrieveParams private constructor( - private val stopId: String, + private val stopId: String?, private val date: LocalDate?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun stopId(): String = stopId + fun stopId(): Optional = Optional.ofNullable(stopId) /** * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, @@ -32,31 +31,20 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.date?.let { queryParams.put("date", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): ScheduleForStopRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleForStopRetrieveParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [ScheduleForStopRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var stopId: String? = null @@ -72,7 +60,10 @@ private constructor( additionalQueryParams = scheduleForStopRetrieveParams.additionalQueryParams.toBuilder() } - fun stopId(stopId: String) = apply { this.stopId = stopId } + fun stopId(stopId: String?) = apply { this.stopId = stopId } + + /** Alias for calling [Builder.stopId] with `stopId.orElse(null)`. */ + fun stopId(stopId: Optional) = stopId(stopId.getOrNull()) /** * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, @@ -80,11 +71,8 @@ private constructor( */ fun date(date: LocalDate?) = apply { this.date = date } - /** - * The date for which you want to request a schedule in the format YYYY-MM-DD (optional, - * defaults to the current date) - */ - fun date(date: Optional) = date(date.orElse(null)) + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -184,15 +172,36 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ScheduleForStopRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams( - checkRequired("stopId", stopId), + stopId, date, additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> stopId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + date?.let { put("date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..d9e6767 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt @@ -0,0 +1,2122 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforstop + +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 ScheduleForStopRetrieveResponse +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 + * [ScheduleForStopRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleForStopRetrieveResponse]. */ + 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(scheduleForStopRetrieveResponse: ScheduleForStopRetrieveResponse) = + apply { + code = scheduleForStopRetrieveResponse.code + currentTime = scheduleForStopRetrieveResponse.currentTime + text = scheduleForStopRetrieveResponse.text + version = scheduleForStopRetrieveResponse.version + data = scheduleForStopRetrieveResponse.data + additionalProperties = + scheduleForStopRetrieveResponse.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 [ScheduleForStopRetrieveResponse]. + * + * 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(): ScheduleForStopRetrieveResponse = + ScheduleForStopRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScheduleForStopRetrieveResponse = 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 + 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 + private constructor( + private val date: JsonField, + private val stopId: JsonField, + private val stopRouteSchedules: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopRouteSchedules") + @ExcludeMissing + stopRouteSchedules: JsonField> = JsonMissing.of(), + ) : this(date, stopId, stopRouteSchedules, 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 date(): Long = date.getRequired("date") + + /** + * @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 stopRouteSchedules(): List = + stopRouteSchedules.getRequired("stopRouteSchedules") + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * 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 [stopRouteSchedules]. + * + * Unlike [stopRouteSchedules], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopRouteSchedules") + @ExcludeMissing + fun _stopRouteSchedules(): JsonField> = stopRouteSchedules + + @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 + * .date() + * .stopId() + * .stopRouteSchedules() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var date: JsonField? = null + private var stopId: JsonField? = null + private var stopRouteSchedules: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + date = entry.date + stopId = entry.stopId + stopRouteSchedules = entry.stopRouteSchedules.map { it.toMutableList() } + additionalProperties = entry.additionalProperties.toMutableMap() + } + + fun date(date: Long) = date(JsonField.of(date)) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun date(date: JsonField) = apply { this.date = date } + + 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 stopRouteSchedules(stopRouteSchedules: List) = + stopRouteSchedules(JsonField.of(stopRouteSchedules)) + + /** + * Sets [Builder.stopRouteSchedules] to an arbitrary JSON value. + * + * You should usually call [Builder.stopRouteSchedules] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopRouteSchedules(stopRouteSchedules: JsonField>) = + apply { + this.stopRouteSchedules = stopRouteSchedules.map { it.toMutableList() } + } + + /** + * Adds a single [StopRouteSchedule] to [stopRouteSchedules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopRouteSchedule(stopRouteSchedule: StopRouteSchedule) = apply { + stopRouteSchedules = + (stopRouteSchedules ?: JsonField.of(mutableListOf())).also { + checkKnown("stopRouteSchedules", it).add(stopRouteSchedule) + } + } + + 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 + * .date() + * .stopId() + * .stopRouteSchedules() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("date", date), + checkRequired("stopId", stopId), + checkRequired("stopRouteSchedules", stopRouteSchedules).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + date() + stopId() + stopRouteSchedules().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 (date.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (stopRouteSchedules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class StopRouteSchedule + private constructor( + private val routeId: JsonField, + private val stopRouteDirectionSchedules: + JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("stopRouteDirectionSchedules") + @ExcludeMissing + stopRouteDirectionSchedules: JsonField> = + JsonMissing.of(), + ) : this(routeId, stopRouteDirectionSchedules, 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 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 stopRouteDirectionSchedules(): List = + stopRouteDirectionSchedules.getRequired("stopRouteDirectionSchedules") + + /** + * 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 [stopRouteDirectionSchedules]. + * + * Unlike [stopRouteDirectionSchedules], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("stopRouteDirectionSchedules") + @ExcludeMissing + fun _stopRouteDirectionSchedules(): JsonField> = + stopRouteDirectionSchedules + + @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 + * [StopRouteSchedule]. + * + * The following fields are required: + * ```java + * .routeId() + * .stopRouteDirectionSchedules() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopRouteSchedule]. */ + class Builder internal constructor() { + + private var routeId: JsonField? = null + private var stopRouteDirectionSchedules: + JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stopRouteSchedule: StopRouteSchedule) = apply { + routeId = stopRouteSchedule.routeId + stopRouteDirectionSchedules = + stopRouteSchedule.stopRouteDirectionSchedules.map { it.toMutableList() } + additionalProperties = stopRouteSchedule.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 stopRouteDirectionSchedules( + stopRouteDirectionSchedules: List + ) = stopRouteDirectionSchedules(JsonField.of(stopRouteDirectionSchedules)) + + /** + * Sets [Builder.stopRouteDirectionSchedules] to an arbitrary JSON value. + * + * You should usually call [Builder.stopRouteDirectionSchedules] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun stopRouteDirectionSchedules( + stopRouteDirectionSchedules: JsonField> + ) = apply { + this.stopRouteDirectionSchedules = + stopRouteDirectionSchedules.map { it.toMutableList() } + } + + /** + * Adds a single [StopRouteDirectionSchedule] to [stopRouteDirectionSchedules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStopRouteDirectionSchedule( + stopRouteDirectionSchedule: StopRouteDirectionSchedule + ) = apply { + stopRouteDirectionSchedules = + (stopRouteDirectionSchedules ?: JsonField.of(mutableListOf())).also { + checkKnown("stopRouteDirectionSchedules", it) + .add(stopRouteDirectionSchedule) + } + } + + 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 [StopRouteSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .routeId() + * .stopRouteDirectionSchedules() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopRouteSchedule = + StopRouteSchedule( + checkRequired("routeId", routeId), + checkRequired( + "stopRouteDirectionSchedules", + stopRouteDirectionSchedules, + ) + .map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopRouteSchedule = apply { + if (validated) { + return@apply + } + + routeId() + stopRouteDirectionSchedules().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 (routeId.asKnown().isPresent) 1 else 0) + + (stopRouteDirectionSchedules.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class StopRouteDirectionSchedule + private constructor( + private val scheduleStopTimes: JsonField>, + private val tripHeadsign: JsonField, + private val scheduleFrequencies: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scheduleStopTimes") + @ExcludeMissing + scheduleStopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("scheduleFrequencies") + @ExcludeMissing + scheduleFrequencies: JsonField> = JsonMissing.of(), + ) : this(scheduleStopTimes, tripHeadsign, scheduleFrequencies, 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 scheduleStopTimes(): List = + scheduleStopTimes.getRequired("scheduleStopTimes") + + /** + * @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") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduleFrequencies(): Optional> = + scheduleFrequencies.getOptional("scheduleFrequencies") + + /** + * Returns the raw JSON value of [scheduleStopTimes]. + * + * Unlike [scheduleStopTimes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduleStopTimes") + @ExcludeMissing + fun _scheduleStopTimes(): JsonField> = scheduleStopTimes + + /** + * 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 [scheduleFrequencies]. + * + * Unlike [scheduleFrequencies], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduleFrequencies") + @ExcludeMissing + fun _scheduleFrequencies(): JsonField> = + scheduleFrequencies + + @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 + * [StopRouteDirectionSchedule]. + * + * The following fields are required: + * ```java + * .scheduleStopTimes() + * .tripHeadsign() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopRouteDirectionSchedule]. */ + class Builder internal constructor() { + + private var scheduleStopTimes: JsonField>? = + null + private var tripHeadsign: JsonField? = null + private var scheduleFrequencies: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopRouteDirectionSchedule: StopRouteDirectionSchedule) = + apply { + scheduleStopTimes = + stopRouteDirectionSchedule.scheduleStopTimes.map { + it.toMutableList() + } + tripHeadsign = stopRouteDirectionSchedule.tripHeadsign + scheduleFrequencies = + stopRouteDirectionSchedule.scheduleFrequencies.map { + it.toMutableList() + } + additionalProperties = + stopRouteDirectionSchedule.additionalProperties.toMutableMap() + } + + fun scheduleStopTimes(scheduleStopTimes: List) = + scheduleStopTimes(JsonField.of(scheduleStopTimes)) + + /** + * Sets [Builder.scheduleStopTimes] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleStopTimes] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun scheduleStopTimes( + scheduleStopTimes: JsonField> + ) = apply { + this.scheduleStopTimes = scheduleStopTimes.map { it.toMutableList() } + } + + /** + * Adds a single [ScheduleStopTime] to [scheduleStopTimes]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScheduleStopTime(scheduleStopTime: ScheduleStopTime) = apply { + scheduleStopTimes = + (scheduleStopTimes ?: JsonField.of(mutableListOf())).also { + checkKnown("scheduleStopTimes", it).add(scheduleStopTime) + } + } + + 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 + } + + fun scheduleFrequencies(scheduleFrequencies: List) = + scheduleFrequencies(JsonField.of(scheduleFrequencies)) + + /** + * Sets [Builder.scheduleFrequencies] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleFrequencies] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun scheduleFrequencies( + scheduleFrequencies: JsonField> + ) = apply { + this.scheduleFrequencies = + scheduleFrequencies.map { it.toMutableList() } + } + + /** + * Adds a single [ScheduleFrequency] to [scheduleFrequencies]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScheduleFrequency(scheduleFrequency: ScheduleFrequency) = apply { + scheduleFrequencies = + (scheduleFrequencies ?: JsonField.of(mutableListOf())).also { + checkKnown("scheduleFrequencies", it).add(scheduleFrequency) + } + } + + 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 [StopRouteDirectionSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .scheduleStopTimes() + * .tripHeadsign() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopRouteDirectionSchedule = + StopRouteDirectionSchedule( + checkRequired("scheduleStopTimes", scheduleStopTimes).map { + it.toImmutable() + }, + checkRequired("tripHeadsign", tripHeadsign), + (scheduleFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopRouteDirectionSchedule = apply { + if (validated) { + return@apply + } + + scheduleStopTimes().forEach { it.validate() } + tripHeadsign() + scheduleFrequencies().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 = + (scheduleStopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (scheduleFrequencies.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class ScheduleStopTime + private constructor( + private val arrivalEnabled: JsonField, + private val arrivalTime: JsonField, + private val departureEnabled: JsonField, + private val departureTime: JsonField, + private val serviceId: JsonField, + private val tripId: 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("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + arrivalTime, + departureEnabled, + departureTime, + serviceId, + tripId, + 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 serviceId(): String = serviceId.getRequired("serviceId") + + /** + * @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 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]. + * + * 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 [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 [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 [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 + * [ScheduleStopTime]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .serviceId() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleStopTime]. */ + 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 serviceId: JsonField? = null + private var tripId: JsonField? = null + private var stopHeadsign: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scheduleStopTime: ScheduleStopTime) = apply { + arrivalEnabled = scheduleStopTime.arrivalEnabled + arrivalTime = scheduleStopTime.arrivalTime + departureEnabled = scheduleStopTime.departureEnabled + departureTime = scheduleStopTime.departureTime + serviceId = scheduleStopTime.serviceId + tripId = scheduleStopTime.tripId + stopHeadsign = scheduleStopTime.stopHeadsign + additionalProperties = + scheduleStopTime.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 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 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 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 [ScheduleStopTime]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .serviceId() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScheduleStopTime = + ScheduleStopTime( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureEnabled", departureEnabled), + checkRequired("departureTime", departureTime), + checkRequired("serviceId", serviceId), + checkRequired("tripId", tripId), + stopHeadsign, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScheduleStopTime = apply { + if (validated) { + return@apply + } + + arrivalEnabled() + arrivalTime() + departureEnabled() + departureTime() + serviceId() + tripId() + 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 (serviceId.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleStopTime && arrivalEnabled == other.arrivalEnabled && arrivalTime == other.arrivalTime && departureEnabled == other.departureEnabled && departureTime == other.departureTime && serviceId == other.serviceId && tripId == other.tripId && stopHeadsign == other.stopHeadsign && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalEnabled, arrivalTime, departureEnabled, departureTime, serviceId, tripId, stopHeadsign, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleStopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, serviceId=$serviceId, tripId=$tripId, stopHeadsign=$stopHeadsign, additionalProperties=$additionalProperties}" + } + + class ScheduleFrequency + private constructor( + private val endTime: JsonField, + private val headway: JsonField, + private val serviceDate: JsonField, + private val serviceId: JsonField, + private val startTime: JsonField, + private val tripId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("endTime") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("headway") + @ExcludeMissing + headway: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("startTime") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + ) : this( + endTime, + headway, + serviceDate, + serviceId, + startTime, + 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 endTime(): Long = endTime.getRequired("endTime") + + /** + * @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 headway(): Int = headway.getRequired("headway") + + /** + * @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") + + /** + * @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 or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun startTime(): Long = startTime.getRequired("startTime") + + /** + * @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 [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("endTime") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [headway]. + * + * Unlike [headway], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("headway") + @ExcludeMissing + fun _headway(): JsonField = headway + + /** + * 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 [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 [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("startTime") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + /** + * 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) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleFrequency]. + * + * The following fields are required: + * ```java + * .endTime() + * .headway() + * .serviceDate() + * .serviceId() + * .startTime() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleFrequency]. */ + class Builder internal constructor() { + + private var endTime: JsonField? = null + private var headway: JsonField? = null + private var serviceDate: JsonField? = null + private var serviceId: JsonField? = null + private var startTime: JsonField? = null + private var tripId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scheduleFrequency: ScheduleFrequency) = apply { + endTime = scheduleFrequency.endTime + headway = scheduleFrequency.headway + serviceDate = scheduleFrequency.serviceDate + serviceId = scheduleFrequency.serviceId + startTime = scheduleFrequency.startTime + tripId = scheduleFrequency.tripId + additionalProperties = + scheduleFrequency.additionalProperties.toMutableMap() + } + + fun endTime(endTime: Long) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun headway(headway: Int) = headway(JsonField.of(headway)) + + /** + * Sets [Builder.headway] to an arbitrary JSON value. + * + * You should usually call [Builder.headway] with a well-typed [Int] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun headway(headway: JsonField) = apply { this.headway = headway } + + 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 + } + + 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 startTime(startTime: Long) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + 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 [ScheduleFrequency]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .endTime() + * .headway() + * .serviceDate() + * .serviceId() + * .startTime() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScheduleFrequency = + ScheduleFrequency( + checkRequired("endTime", endTime), + checkRequired("headway", headway), + checkRequired("serviceDate", serviceDate), + checkRequired("serviceId", serviceId), + checkRequired("startTime", startTime), + checkRequired("tripId", tripId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScheduleFrequency = apply { + if (validated) { + return@apply + } + + endTime() + headway() + serviceDate() + serviceId() + startTime() + 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 = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (headway.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScheduleFrequency && endTime == other.endTime && headway == other.headway && serviceDate == other.serviceDate && serviceId == other.serviceId && startTime == other.startTime && tripId == other.tripId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endTime, headway, serviceDate, serviceId, startTime, tripId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleFrequency{endTime=$endTime, headway=$headway, serviceDate=$serviceDate, serviceId=$serviceId, startTime=$startTime, tripId=$tripId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopRouteDirectionSchedule && scheduleStopTimes == other.scheduleStopTimes && tripHeadsign == other.tripHeadsign && scheduleFrequencies == other.scheduleFrequencies && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(scheduleStopTimes, tripHeadsign, scheduleFrequencies, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopRouteDirectionSchedule{scheduleStopTimes=$scheduleStopTimes, tripHeadsign=$tripHeadsign, scheduleFrequencies=$scheduleFrequencies, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopRouteSchedule && routeId == other.routeId && stopRouteDirectionSchedules == other.stopRouteDirectionSchedules && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(routeId, stopRouteDirectionSchedules, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopRouteSchedule{routeId=$routeId, stopRouteDirectionSchedules=$stopRouteDirectionSchedules, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && date == other.date && stopId == other.stopId && stopRouteSchedules == other.stopRouteSchedules && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(date, stopId, stopRouteSchedules, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{date=$date, stopId=$stopId, stopRouteSchedules=$stopRouteSchedules, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is ScheduleForStopRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleForStopRetrieveResponse{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/SearchForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParams.kt similarity index 84% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParams.kt index 2d08c20..20bceac 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.searchforroute import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Params import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers @@ -29,25 +29,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.input.let { queryParams.put("input", listOf(it.toString())) } - this.maxCount?.let { queryParams.put("maxCount", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [SearchForRouteListParams]. + * + * The following fields are required: + * ```java + * .input() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [SearchForRouteListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var input: String? = null @@ -69,12 +66,15 @@ private constructor( /** The max number of results to return. Defaults to 20. */ fun maxCount(maxCount: Long?) = apply { this.maxCount = maxCount } - /** The max number of results to return. Defaults to 20. */ + /** + * Alias for [Builder.maxCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun maxCount(maxCount: Long) = maxCount(maxCount as Long?) - /** The max number of results to return. Defaults to 20. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maxCount(maxCount: Optional) = maxCount(maxCount.orElse(null) as Long?) + /** Alias for calling [Builder.maxCount] with `maxCount.orElse(null)`. */ + fun maxCount(maxCount: Optional) = maxCount(maxCount.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -174,6 +174,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [SearchForRouteListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SearchForRouteListParams = SearchForRouteListParams( checkRequired("input", input), @@ -183,6 +195,17 @@ private constructor( ) } + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("input", input) + maxCount?.let { put("maxCount", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..36fe683 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt @@ -0,0 +1,1095 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforroute + +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 SearchForRouteListResponse +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 (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("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 [SearchForRouteListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SearchForRouteListResponse]. */ + 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 = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(searchForRouteListResponse: SearchForRouteListResponse) = apply { + code = searchForRouteListResponse.code + currentTime = searchForRouteListResponse.currentTime + text = searchForRouteListResponse.text + version = searchForRouteListResponse.version + data = searchForRouteListResponse.data + additionalProperties = searchForRouteListResponse.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 [SearchForRouteListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SearchForRouteListResponse = + SearchForRouteListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + data, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SearchForRouteListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().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 (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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + @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") + + /** + * @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 outOfRange(): Boolean = outOfRange.getRequired("outOfRange") + + /** + * @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 [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 [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + /** + * 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 + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 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 + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 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 + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + 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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val id: JsonField, + private val agencyId: JsonField, + private val type: JsonField, + private val color: JsonField, + private val description: JsonField, + private val longName: JsonField, + private val nullSafeShortName: JsonField, + private val shortName: JsonField, + private val textColor: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("agencyId") + @ExcludeMissing + agencyId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("longName") + @ExcludeMissing + longName: JsonField = JsonMissing.of(), + @JsonProperty("nullSafeShortName") + @ExcludeMissing + nullSafeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shortName") + @ExcludeMissing + shortName: JsonField = JsonMissing.of(), + @JsonProperty("textColor") + @ExcludeMissing + textColor: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + 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 agencyId(): String = agencyId.getRequired("agencyId") + + /** + * @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 type(): Long = type.getRequired("type") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun longName(): Optional = longName.getOptional("longName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nullSafeShortName(): Optional = + nullSafeShortName.getOptional("nullSafeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun shortName(): Optional = shortName.getOptional("shortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textColor(): Optional = textColor.getOptional("textColor") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * 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 [agencyId]. + * + * Unlike [agencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agencyId") @ExcludeMissing fun _agencyId(): JsonField = agencyId + + /** + * 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 + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [longName]. + * + * Unlike [longName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("longName") @ExcludeMissing fun _longName(): JsonField = longName + + /** + * Returns the raw JSON value of [nullSafeShortName]. + * + * Unlike [nullSafeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nullSafeShortName") + @ExcludeMissing + fun _nullSafeShortName(): JsonField = nullSafeShortName + + /** + * Returns the raw JSON value of [shortName]. + * + * Unlike [shortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shortName") + @ExcludeMissing + fun _shortName(): JsonField = shortName + + /** + * Returns the raw JSON value of [textColor]. + * + * Unlike [textColor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("textColor") + @ExcludeMissing + fun _textColor(): JsonField = textColor + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var agencyId: JsonField? = null + private var type: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var longName: JsonField = JsonMissing.of() + private var nullSafeShortName: JsonField = JsonMissing.of() + private var shortName: JsonField = JsonMissing.of() + private var textColor: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + agencyId = list.agencyId + type = list.type + color = list.color + description = list.description + longName = list.longName + nullSafeShortName = list.nullSafeShortName + shortName = list.shortName + textColor = list.textColor + url = list.url + 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 agencyId(agencyId: String) = agencyId(JsonField.of(agencyId)) + + /** + * Sets [Builder.agencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.agencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agencyId(agencyId: JsonField) = apply { this.agencyId = agencyId } + + fun type(type: Long) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Long] 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 color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun longName(longName: String) = longName(JsonField.of(longName)) + + /** + * Sets [Builder.longName] to an arbitrary JSON value. + * + * You should usually call [Builder.longName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun longName(longName: JsonField) = apply { this.longName = longName } + + fun nullSafeShortName(nullSafeShortName: String) = + nullSafeShortName(JsonField.of(nullSafeShortName)) + + /** + * Sets [Builder.nullSafeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.nullSafeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nullSafeShortName(nullSafeShortName: JsonField) = apply { + this.nullSafeShortName = nullSafeShortName + } + + fun shortName(shortName: String) = shortName(JsonField.of(shortName)) + + /** + * Sets [Builder.shortName] to an arbitrary JSON value. + * + * You should usually call [Builder.shortName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shortName(shortName: JsonField) = apply { this.shortName = shortName } + + fun textColor(textColor: String) = textColor(JsonField.of(textColor)) + + /** + * Sets [Builder.textColor] to an arbitrary JSON value. + * + * You should usually call [Builder.textColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColor(textColor: JsonField) = apply { this.textColor = textColor } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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() + * .agencyId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + agencyId() + type() + color() + description() + longName() + nullSafeShortName() + shortName() + textColor() + url() + 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 (agencyId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (longName.asKnown().isPresent) 1 else 0) + + (if (nullSafeShortName.asKnown().isPresent) 1 else 0) + + (if (shortName.asKnown().isPresent) 1 else 0) + + (if (textColor.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is List && id == other.id && agencyId == other.agencyId && type == other.type && color == other.color && description == other.description && longName == other.longName && nullSafeShortName == other.nullSafeShortName && shortName == other.shortName && textColor == other.textColor && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, agencyId, type, color, description, longName, nullSafeShortName, shortName, textColor, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SearchForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SearchForRouteListResponse{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/SearchForStopListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParams.kt similarity index 84% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParams.kt index 0c20584..8c3093a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/SearchForStopListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.searchforstop import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Params import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers @@ -29,25 +29,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.input.let { queryParams.put("input", listOf(it.toString())) } - this.maxCount?.let { queryParams.put("maxCount", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [SearchForStopListParams]. + * + * The following fields are required: + * ```java + * .input() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [SearchForStopListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var input: String? = null @@ -69,12 +66,15 @@ private constructor( /** The max number of results to return. Defaults to 20. */ fun maxCount(maxCount: Long?) = apply { this.maxCount = maxCount } - /** The max number of results to return. Defaults to 20. */ + /** + * Alias for [Builder.maxCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun maxCount(maxCount: Long) = maxCount(maxCount as Long?) - /** The max number of results to return. Defaults to 20. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maxCount(maxCount: Optional) = maxCount(maxCount.orElse(null) as Long?) + /** Alias for calling [Builder.maxCount] with `maxCount.orElse(null)`. */ + fun maxCount(maxCount: Optional) = maxCount(maxCount.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -174,6 +174,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [SearchForStopListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SearchForStopListParams = SearchForStopListParams( checkRequired("input", input), @@ -183,6 +195,17 @@ private constructor( ) } + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("input", input) + maxCount?.let { put("maxCount", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..946d49e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt @@ -0,0 +1,1175 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforstop + +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 SearchForStopListResponse +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 (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("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 [SearchForStopListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SearchForStopListResponse]. */ + 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 = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(searchForStopListResponse: SearchForStopListResponse) = apply { + code = searchForStopListResponse.code + currentTime = searchForStopListResponse.currentTime + text = searchForStopListResponse.text + version = searchForStopListResponse.version + data = searchForStopListResponse.data + additionalProperties = searchForStopListResponse.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 [SearchForStopListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SearchForStopListResponse = + SearchForStopListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + data, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SearchForStopListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + data().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 (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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limitExceeded") + @ExcludeMissing + limitExceeded: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField> = JsonMissing.of(), + @JsonProperty("outOfRange") + @ExcludeMissing + outOfRange: JsonField = JsonMissing.of(), + @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") + + /** + * @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 outOfRange(): Boolean = outOfRange.getRequired("outOfRange") + + /** + * @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 [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 [outOfRange]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + /** + * 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 + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 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 + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 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 + * .limitExceeded() + * .list() + * .outOfRange() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("outOfRange", outOfRange), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + outOfRange() + 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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (outOfRange.asKnown().isPresent) 1 else 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + 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, + 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") + + /** + * @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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && outOfRange == other.outOfRange && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, outOfRange=$outOfRange, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SearchForStopListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SearchForStopListResponse{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/ShapeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveParams.kt similarity index 85% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveParams.kt index 83b1125..e92363c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ShapeRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveParams.kt @@ -1,48 +1,39 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.shape import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ class ShapeRetrieveParams private constructor( - private val shapeId: String, + private val shapeId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun shapeId(): String = shapeId + fun shapeId(): Optional = Optional.ofNullable(shapeId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> shapeId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): ShapeRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ShapeRetrieveParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [ShapeRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var shapeId: String? = null @@ -56,7 +47,10 @@ private constructor( additionalQueryParams = shapeRetrieveParams.additionalQueryParams.toBuilder() } - fun shapeId(shapeId: String) = apply { this.shapeId = shapeId } + fun shapeId(shapeId: String?) = apply { this.shapeId = shapeId } + + /** Alias for calling [Builder.shapeId] with `shapeId.orElse(null)`. */ + fun shapeId(shapeId: Optional) = shapeId(shapeId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +150,25 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ShapeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ShapeRetrieveParams = - ShapeRetrieveParams( - checkRequired("shapeId", shapeId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + ShapeRetrieveParams(shapeId, additionalHeaders.build(), additionalQueryParams.build()) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> shapeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..66447f0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt @@ -0,0 +1,741 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.shape + +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.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class ShapeRetrieveResponse +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 [ShapeRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShapeRetrieveResponse]. */ + 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(shapeRetrieveResponse: ShapeRetrieveResponse) = apply { + code = shapeRetrieveResponse.code + currentTime = shapeRetrieveResponse.currentTime + text = shapeRetrieveResponse.text + version = shapeRetrieveResponse.version + data = shapeRetrieveResponse.data + additionalProperties = shapeRetrieveResponse.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 [ShapeRetrieveResponse]. + * + * 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(): ShapeRetrieveResponse = + ShapeRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ShapeRetrieveResponse = 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 + 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 + private constructor( + private val length: JsonField, + private val points: JsonField, + private val levels: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("length") @ExcludeMissing length: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + @JsonProperty("levels") @ExcludeMissing levels: JsonField = JsonMissing.of(), + ) : this(length, points, levels, 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 length(): Long = length.getRequired("length") + + /** + * Encoded polyline format representing the shape of the path + * + * @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 points(): String = points.getRequired("points") + + /** + * @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") + + /** + * 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 [points]. + * + * Unlike [points], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points + + /** + * 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 + + @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 + * .length() + * .points() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var length: JsonField? = null + private var points: JsonField? = null + private var levels: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + length = entry.length + points = entry.points + levels = entry.levels + additionalProperties = entry.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 } + + /** Encoded polyline format representing the shape of the path */ + 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 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 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 + * .length() + * .points() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("length", length), + checkRequired("points", points), + levels, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + length() + points() + levels() + 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 (points.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && length == other.length && points == other.points && levels == other.levels && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, points, levels, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{length=$length, points=$points, levels=$levels, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is ShapeRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ShapeRetrieveResponse{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/StopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveParams.kt similarity index 85% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveParams.kt index 2f25115..c734e7b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveParams.kt @@ -1,48 +1,39 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stop import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Get details of a specific stop */ class StopRetrieveParams private constructor( - private val stopId: String, + private val stopId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun stopId(): String = stopId + fun stopId(): Optional = Optional.ofNullable(stopId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> stopId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): StopRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [StopRetrieveParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [StopRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var stopId: String? = null @@ -56,7 +47,10 @@ private constructor( additionalQueryParams = stopRetrieveParams.additionalQueryParams.toBuilder() } - fun stopId(stopId: String) = apply { this.stopId = stopId } + fun stopId(stopId: String?) = apply { this.stopId = stopId } + + /** Alias for calling [Builder.stopId] with `stopId.orElse(null)`. */ + fun stopId(stopId: Optional) = stopId(stopId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +150,25 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [StopRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): StopRetrieveParams = - StopRetrieveParams( - checkRequired("stopId", stopId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + StopRetrieveParams(stopId, additionalHeaders.build(), additionalQueryParams.build()) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> stopId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..559d930 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt @@ -0,0 +1,1079 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stop + +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 StopRetrieveResponse +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 [StopRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopRetrieveResponse]. */ + 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(stopRetrieveResponse: StopRetrieveResponse) = apply { + code = stopRetrieveResponse.code + currentTime = stopRetrieveResponse.currentTime + text = stopRetrieveResponse.text + version = stopRetrieveResponse.version + data = stopRetrieveResponse.data + additionalProperties = stopRetrieveResponse.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 [StopRetrieveResponse]. + * + * 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(): StopRetrieveResponse = + StopRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopRetrieveResponse = 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 + 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 + 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, + 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") + + /** + * @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(): 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(): 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 [Entry]. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + 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(entry: Entry) = apply { + id = entry.id + lat = entry.lat + locationType = entry.locationType + lon = entry.lon + name = entry.name + parent = entry.parent + routeIds = entry.routeIds.map { it.toMutableList() } + staticRouteIds = entry.staticRouteIds.map { it.toMutableList() } + code = entry.code + direction = entry.direction + wheelchairBoarding = entry.wheelchairBoarding + additionalProperties = entry.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: 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: 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 [Entry]. + * + * 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(): Entry = + Entry( + 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(): Entry = 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 /* spotless:off */ other is Entry && 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 /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{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 /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is StopRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopRetrieveResponse{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/StopIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParams.kt similarity index 86% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParams.kt index 62ecdf9..b82ad9d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopIdsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParams.kt @@ -1,48 +1,41 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopidsforagency import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Get stop IDs for a specific agency */ class StopIdsForAgencyListParams private constructor( - private val agencyId: String, + private val agencyId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun agencyId(): String = agencyId + fun agencyId(): Optional = Optional.ofNullable(agencyId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): StopIdsForAgencyListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [StopIdsForAgencyListParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [StopIdsForAgencyListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var agencyId: String? = null @@ -56,7 +49,10 @@ private constructor( additionalQueryParams = stopIdsForAgencyListParams.additionalQueryParams.toBuilder() } - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun agencyId(agencyId: String?) = apply { this.agencyId = agencyId } + + /** Alias for calling [Builder.agencyId] with `agencyId.orElse(null)`. */ + fun agencyId(agencyId: Optional) = agencyId(agencyId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +152,29 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [StopIdsForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): StopIdsForAgencyListParams = StopIdsForAgencyListParams( - checkRequired("agencyId", agencyId), + agencyId, additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> agencyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..75f6f06 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt @@ -0,0 +1,565 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopidsforagency + +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 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 StopIdsForAgencyListResponse +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 [StopIdsForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopIdsForAgencyListResponse]. */ + 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(stopIdsForAgencyListResponse: StopIdsForAgencyListResponse) = apply { + code = stopIdsForAgencyListResponse.code + currentTime = stopIdsForAgencyListResponse.currentTime + text = stopIdsForAgencyListResponse.text + version = stopIdsForAgencyListResponse.version + data = stopIdsForAgencyListResponse.data + additionalProperties = stopIdsForAgencyListResponse.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 [StopIdsForAgencyListResponse]. + * + * 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(): StopIdsForAgencyListResponse = + StopIdsForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopIdsForAgencyListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: 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") + + /** + * @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") + + /** + * @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 [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 + + @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 + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 list(list: JsonField>) = apply { + this.list = list.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.list]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: String) = 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 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 + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list() + 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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.size ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopIdsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopIdsForAgencyListResponse{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/StopsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParams.kt similarity index 86% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParams.kt index e58a7ed..434a1bb 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParams.kt @@ -1,48 +1,39 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopsforagency import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Get stops for a specific agency */ class StopsForAgencyListParams private constructor( - private val agencyId: String, + private val agencyId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun agencyId(): String = agencyId + fun agencyId(): Optional = Optional.ofNullable(agencyId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): StopsForAgencyListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [StopsForAgencyListParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [StopsForAgencyListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var agencyId: String? = null @@ -56,7 +47,10 @@ private constructor( additionalQueryParams = stopsForAgencyListParams.additionalQueryParams.toBuilder() } - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun agencyId(agencyId: String?) = apply { this.agencyId = agencyId } + + /** Alias for calling [Builder.agencyId] with `agencyId.orElse(null)`. */ + fun agencyId(agencyId: Optional) = agencyId(agencyId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +150,29 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [StopsForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): StopsForAgencyListParams = StopsForAgencyListParams( - checkRequired("agencyId", agencyId), + agencyId, additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> agencyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..8e3f66e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt @@ -0,0 +1,1005 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforagency + +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 StopsForAgencyListResponse +private constructor( + private val code: JsonField, + 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 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("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(), + ) + + 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 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") + + /** + * 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 [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]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") @ExcludeMissing fun _outOfRange(): JsonField = outOfRange + + @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 [StopsForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForAgencyListResponse]. */ + 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 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(stopsForAgencyListResponse: StopsForAgencyListResponse) = apply { + code = stopsForAgencyListResponse.code + currentTime = stopsForAgencyListResponse.currentTime + text = stopsForAgencyListResponse.text + version = stopsForAgencyListResponse.version + limitExceeded = stopsForAgencyListResponse.limitExceeded + list = stopsForAgencyListResponse.list.map { it.toMutableList() } + references = stopsForAgencyListResponse.references + outOfRange = stopsForAgencyListResponse.outOfRange + additionalProperties = stopsForAgencyListResponse.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 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 [StopsForAgencyListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopsForAgencyListResponse = + StopsForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + outOfRange, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopsForAgencyListResponse = apply { + if (validated) { + return@apply + } + + code() + currentTime() + text() + version() + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + 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) + + (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) + + class List + 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, + 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") + + /** + * @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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is StopsForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, limitExceeded, list, references, outOfRange, additionalProperties) } + /* spotless:on */ + + 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}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt similarity index 79% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt index 679c6c6..41ac407 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopsforlocation import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Params import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers @@ -43,29 +43,23 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.lat.let { queryParams.put("lat", listOf(it.toString())) } - this.lon.let { queryParams.put("lon", listOf(it.toString())) } - this.latSpan?.let { queryParams.put("latSpan", listOf(it.toString())) } - this.lonSpan?.let { queryParams.put("lonSpan", listOf(it.toString())) } - this.query?.let { queryParams.put("query", listOf(it.toString())) } - this.radius?.let { queryParams.put("radius", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [StopsForLocationListParams]. + * + * The following fields are required: + * ```java + * .lat() + * .lon() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [StopsForLocationListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var lat: Double? = null @@ -96,38 +90,47 @@ private constructor( /** An alternative to radius to set the search bounding box (optional) */ fun latSpan(latSpan: Double?) = apply { this.latSpan = latSpan } - /** An alternative to radius to set the search bounding box (optional) */ + /** + * Alias for [Builder.latSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun latSpan(latSpan: Double) = latSpan(latSpan as Double?) - /** An alternative to radius to set the search bounding box (optional) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun latSpan(latSpan: Optional) = latSpan(latSpan.orElse(null) as Double?) + /** Alias for calling [Builder.latSpan] with `latSpan.orElse(null)`. */ + fun latSpan(latSpan: Optional) = latSpan(latSpan.getOrNull()) /** An alternative to radius to set the search bounding box (optional) */ fun lonSpan(lonSpan: Double?) = apply { this.lonSpan = lonSpan } - /** An alternative to radius to set the search bounding box (optional) */ + /** + * Alias for [Builder.lonSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun lonSpan(lonSpan: Double) = lonSpan(lonSpan as Double?) - /** An alternative to radius to set the search bounding box (optional) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.orElse(null) as Double?) + /** Alias for calling [Builder.lonSpan] with `lonSpan.orElse(null)`. */ + fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.getOrNull()) /** A search query string to filter the results */ fun query(query: String?) = apply { this.query = query } - /** A search query string to filter the results */ - fun query(query: Optional) = query(query.orElse(null)) + /** Alias for calling [Builder.query] with `query.orElse(null)`. */ + fun query(query: Optional) = query(query.getOrNull()) /** The radius in meters to search within */ fun radius(radius: Double?) = apply { this.radius = radius } - /** The radius in meters to search within */ + /** + * Alias for [Builder.radius]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun radius(radius: Double) = radius(radius as Double?) - /** The radius in meters to search within */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun radius(radius: Optional) = radius(radius.orElse(null) as Double?) + /** Alias for calling [Builder.radius] with `radius.orElse(null)`. */ + fun radius(radius: Optional) = radius(radius.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -227,6 +230,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [StopsForLocationListParams]. + * + * 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(): StopsForLocationListParams = StopsForLocationListParams( checkRequired("lat", lat), @@ -240,6 +256,21 @@ private constructor( ) } + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("lat", lat.toString()) + put("lon", lon.toString()) + latSpan?.let { put("latSpan", it.toString()) } + lonSpan?.let { put("lonSpan", it.toString()) } + query?.let { put("query", it) } + radius?.let { put("radius", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..3d00f7a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt @@ -0,0 +1,1175 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforlocation + +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 StopsForLocationListResponse +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 [StopsForLocationListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForLocationListResponse]. */ + 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(stopsForLocationListResponse: StopsForLocationListResponse) = apply { + code = stopsForLocationListResponse.code + currentTime = stopsForLocationListResponse.currentTime + text = stopsForLocationListResponse.text + version = stopsForLocationListResponse.version + data = stopsForLocationListResponse.data + additionalProperties = stopsForLocationListResponse.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 [StopsForLocationListResponse]. + * + * 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(): StopsForLocationListResponse = + StopsForLocationListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopsForLocationListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: 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("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") + + /** + * @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") + + /** + * 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]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + @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 + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 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 + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + 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(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + 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 (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) + + class List + 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, + 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") + + /** + * @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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, lat, locationType, lon, name, parent, routeIds, staticRouteIds, code, direction, wheelchairBoarding, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopsForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopsForLocationListResponse{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/StopsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParams.kt similarity index 81% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParams.kt index 3345bb5..21605fc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/StopsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParams.kt @@ -1,26 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopsforroute import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +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 /** Get stops for a specific route */ class StopsForRouteListParams private constructor( - private val routeId: String, + private val routeId: String?, private val includePolylines: Boolean?, private val time: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun routeId(): String = routeId + fun routeId(): Optional = Optional.ofNullable(routeId) /** Include polyline elements in the response (default true) */ fun includePolylines(): Optional = Optional.ofNullable(includePolylines) @@ -32,32 +31,17 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.includePolylines?.let { queryParams.put("includePolylines", listOf(it.toString())) } - this.time?.let { queryParams.put("time", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> routeId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): StopsForRouteListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [StopsForRouteListParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [StopsForRouteListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var routeId: String? = null @@ -75,27 +59,33 @@ private constructor( additionalQueryParams = stopsForRouteListParams.additionalQueryParams.toBuilder() } - fun routeId(routeId: String) = apply { this.routeId = routeId } + fun routeId(routeId: String?) = apply { this.routeId = routeId } + + /** Alias for calling [Builder.routeId] with `routeId.orElse(null)`. */ + fun routeId(routeId: Optional) = routeId(routeId.getOrNull()) /** Include polyline elements in the response (default true) */ fun includePolylines(includePolylines: Boolean?) = apply { this.includePolylines = includePolylines } - /** Include polyline elements in the response (default true) */ + /** + * Alias for [Builder.includePolylines]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun includePolylines(includePolylines: Boolean) = includePolylines(includePolylines as Boolean?) - /** Include polyline elements in the response (default true) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.includePolylines] with `includePolylines.orElse(null)`. */ fun includePolylines(includePolylines: Optional) = - includePolylines(includePolylines.orElse(null) as Boolean?) + includePolylines(includePolylines.getOrNull()) /** Specify service date (YYYY-MM-DD or epoch) (default today) */ fun time(time: String?) = apply { this.time = time } - /** Specify service date (YYYY-MM-DD or epoch) (default today) */ - fun time(time: Optional) = time(time.orElse(null)) + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -195,9 +185,14 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [StopsForRouteListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): StopsForRouteListParams = StopsForRouteListParams( - checkRequired("routeId", routeId), + routeId, includePolylines, time, additionalHeaders.build(), @@ -205,6 +200,23 @@ private constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> routeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includePolylines?.let { put("includePolylines", it.toString()) } + time?.let { put("time", it) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..8dbd809 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt @@ -0,0 +1,1753 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforroute + +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 StopsForRouteListResponse +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 [StopsForRouteListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForRouteListResponse]. */ + 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(stopsForRouteListResponse: StopsForRouteListResponse) = apply { + code = stopsForRouteListResponse.code + currentTime = stopsForRouteListResponse.currentTime + text = stopsForRouteListResponse.text + version = stopsForRouteListResponse.version + data = stopsForRouteListResponse.data + additionalProperties = stopsForRouteListResponse.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 [StopsForRouteListResponse]. + * + * 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(): StopsForRouteListResponse = + StopsForRouteListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopsForRouteListResponse = 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 + 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 + private constructor( + private val polylines: JsonField>, + private val routeId: JsonField, + private val stopGroupings: JsonField>, + private val stopIds: 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") + @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") + + /** + * @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 [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 [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 [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 [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 [Entry]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + 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 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) + } + } + + 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() } + } + + /** + * 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 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 [Entry]. + * + * 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(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + polylines().ifPresent { it.forEach { it.validate() } } + routeId() + stopGroupings().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 = + (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 Polyline + 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 /* spotless:off */ other is Polyline && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + } + + class StopGrouping + private constructor( + private val id: JsonField, + private val name: JsonField, + private val polylines: JsonField>, + private val stopIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @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") + @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 + 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 /* spotless:off */ other is Name && name == other.name && names == other.names && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, names, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" + } + + class Polyline + 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 /* spotless:off */ other is Polyline && length == other.length && levels == other.levels && points == other.points && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(length, levels, points, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is StopGrouping && id == other.id && name == other.name && polylines == other.polylines && stopIds == other.stopIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, polylines, stopIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopGrouping{id=$id, name=$name, polylines=$polylines, stopIds=$stopIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && polylines == other.polylines && routeId == other.routeId && stopGroupings == other.stopGroupings && stopIds == other.stopIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{polylines=$polylines, routeId=$routeId, stopGroupings=$stopGroupings, stopIds=$stopIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is StopsForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopsForRouteListResponse{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/TripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveParams.kt similarity index 85% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveParams.kt index d1a60d5..b28e416 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveParams.kt @@ -1,48 +1,39 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.trip import java.util.Objects -import org.onebusaway.core.NoAutoDetect +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 /** Get details of a specific trip */ class TripRetrieveParams private constructor( - private val tripId: String, + private val tripId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun tripId(): String = tripId + fun tripId(): Optional = Optional.ofNullable(tripId) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> tripId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): TripRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TripRetrieveParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [TripRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var tripId: String? = null @@ -56,7 +47,10 @@ private constructor( additionalQueryParams = tripRetrieveParams.additionalQueryParams.toBuilder() } - fun tripId(tripId: String) = apply { this.tripId = tripId } + fun tripId(tripId: String?) = apply { this.tripId = tripId } + + /** Alias for calling [Builder.tripId] with `tripId.orElse(null)`. */ + fun tripId(tripId: Optional) = tripId(tripId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -156,14 +150,25 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [TripRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): TripRetrieveParams = - TripRetrieveParams( - checkRequired("tripId", tripId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + TripRetrieveParams(tripId, additionalHeaders.build(), additionalQueryParams.build()) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> tripId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..f264aa5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt @@ -0,0 +1,1051 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.trip + +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.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException +import org.onebusaway.models.References +import org.onebusaway.models.ResponseWrapper + +class TripRetrieveResponse +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 [TripRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripRetrieveResponse]. */ + 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(tripRetrieveResponse: TripRetrieveResponse) = apply { + code = tripRetrieveResponse.code + currentTime = tripRetrieveResponse.currentTime + text = tripRetrieveResponse.text + version = tripRetrieveResponse.version + data = tripRetrieveResponse.data + additionalProperties = tripRetrieveResponse.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 [TripRetrieveResponse]. + * + * 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(): TripRetrieveResponse = + TripRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripRetrieveResponse = 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 + 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 + 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") + + /** + * 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 [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 [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 [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 [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 [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 [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 [shapeId]. + * + * Unlike [shapeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shapeId") @ExcludeMissing fun _shapeId(): JsonField = shapeId + + /** + * 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 + + /** + * 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 [tripShortName]. + * + * Unlike [tripShortName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripShortName") + @ExcludeMissing + fun _tripShortName(): JsonField = tripShortName + + @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 + * .id() + * .routeId() + * .serviceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + 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() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + id = entry.id + routeId = entry.routeId + serviceId = entry.serviceId + blockId = entry.blockId + directionId = entry.directionId + peakOffpeak = entry.peakOffpeak + routeShortName = entry.routeShortName + shapeId = entry.shapeId + timeZone = entry.timeZone + tripHeadsign = entry.tripHeadsign + tripShortName = entry.tripShortName + additionalProperties = entry.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 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 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 blockId(blockId: String) = blockId(JsonField.of(blockId)) + + /** + * 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 directionId(directionId: String) = directionId(JsonField.of(directionId)) + + /** + * 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 peakOffpeak(peakOffpeak: Long) = peakOffpeak(JsonField.of(peakOffpeak)) + + /** + * 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 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 + } + + fun shapeId(shapeId: String) = shapeId(JsonField.of(shapeId)) + + /** + * 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 timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * 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 } + + 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 + } + + fun tripShortName(tripShortName: String) = + tripShortName(JsonField.of(tripShortName)) + + /** + * 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 + } + + 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 + * .id() + * .routeId() + * .serviceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("id", id), + checkRequired("routeId", routeId), + checkRequired("serviceId", serviceId), + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + id() + routeId() + serviceId() + blockId() + directionId() + peakOffpeak() + routeShortName() + shapeId() + timeZone() + tripHeadsign() + tripShortName() + 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 (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 equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Entry && id == other.id && routeId == other.routeId && serviceId == other.serviceId && blockId == other.blockId && directionId == other.directionId && peakOffpeak == other.peakOffpeak && routeShortName == other.routeShortName && shapeId == other.shapeId && timeZone == other.timeZone && tripHeadsign == other.tripHeadsign && tripShortName == other.tripShortName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, routeId, serviceId, blockId, directionId, peakOffpeak, routeShortName, shapeId, timeZone, tripHeadsign, tripShortName, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{id=$id, routeId=$routeId, serviceId=$serviceId, blockId=$blockId, directionId=$directionId, peakOffpeak=$peakOffpeak, routeShortName=$routeShortName, shapeId=$shapeId, timeZone=$timeZone, tripHeadsign=$tripHeadsign, tripShortName=$tripShortName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is TripRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripRetrieveResponse{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/TripDetailRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParams.kt similarity index 77% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParams.kt index fa137cd..cae8cf6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripDetailRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParams.kt @@ -1,19 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.tripdetails import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +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 /** Retrieve Trip Details */ class TripDetailRetrieveParams private constructor( - private val tripId: String, + private val tripId: String?, private val includeSchedule: Boolean?, private val includeStatus: Boolean?, private val includeTrip: Boolean?, @@ -23,7 +22,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun tripId(): String = tripId + fun tripId(): Optional = Optional.ofNullable(tripId) /** * Whether to include the full schedule element in the tripDetails section (defaults to true). @@ -46,35 +45,17 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } - this.includeTrip?.let { queryParams.put("includeTrip", listOf(it.toString())) } - this.serviceDate?.let { queryParams.put("serviceDate", listOf(it.toString())) } - this.time?.let { queryParams.put("time", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> tripId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): TripDetailRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TripDetailRetrieveParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [TripDetailRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var tripId: String? = null @@ -98,7 +79,10 @@ private constructor( additionalQueryParams = tripDetailRetrieveParams.additionalQueryParams.toBuilder() } - fun tripId(tripId: String) = apply { this.tripId = tripId } + fun tripId(tripId: String?) = apply { this.tripId = tripId } + + /** Alias for calling [Builder.tripId] with `tripId.orElse(null)`. */ + fun tripId(tripId: Optional) = tripId(tripId.getOrNull()) /** * Whether to include the full schedule element in the tripDetails section (defaults to @@ -109,18 +93,15 @@ private constructor( } /** - * Whether to include the full schedule element in the tripDetails section (defaults to - * true). + * Alias for [Builder.includeSchedule]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) - /** - * Whether to include the full schedule element in the tripDetails section (defaults to - * true). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.includeSchedule] with `includeSchedule.orElse(null)`. */ fun includeSchedule(includeSchedule: Optional) = - includeSchedule(includeSchedule.orElse(null) as Boolean?) + includeSchedule(includeSchedule.getOrNull()) /** * Whether to include the full status element in the tripDetails section (defaults to true). @@ -128,16 +109,15 @@ private constructor( fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } /** - * Whether to include the full status element in the tripDetails section (defaults to true). + * Alias for [Builder.includeStatus]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) - /** - * Whether to include the full status element in the tripDetails section (defaults to true). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.includeStatus] with `includeStatus.orElse(null)`. */ fun includeStatus(includeStatus: Optional) = - includeStatus(includeStatus.orElse(null) as Boolean?) + includeStatus(includeStatus.getOrNull()) /** * Whether to include the full trip element in the references section (defaults to true). @@ -145,37 +125,40 @@ private constructor( fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } /** - * Whether to include the full trip element in the references section (defaults to true). + * Alias for [Builder.includeTrip]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip as Boolean?) - /** - * Whether to include the full trip element in the references section (defaults to true). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun includeTrip(includeTrip: Optional) = - includeTrip(includeTrip.orElse(null) as Boolean?) + /** Alias for calling [Builder.includeTrip] with `includeTrip.orElse(null)`. */ + fun includeTrip(includeTrip: Optional) = includeTrip(includeTrip.getOrNull()) /** Service date for the trip as Unix time in milliseconds (optional). */ fun serviceDate(serviceDate: Long?) = apply { this.serviceDate = serviceDate } - /** Service date for the trip as Unix time in milliseconds (optional). */ + /** + * Alias for [Builder.serviceDate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun serviceDate(serviceDate: Long) = serviceDate(serviceDate as Long?) - /** Service date for the trip as Unix time in milliseconds (optional). */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun serviceDate(serviceDate: Optional) = - serviceDate(serviceDate.orElse(null) as Long?) + /** Alias for calling [Builder.serviceDate] with `serviceDate.orElse(null)`. */ + fun serviceDate(serviceDate: Optional) = serviceDate(serviceDate.getOrNull()) /** Time parameter to query the system at a specific time (optional). */ fun time(time: Long?) = apply { this.time = time } - /** Time parameter to query the system at a specific time (optional). */ + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun time(time: Long) = time(time as Long?) - /** Time parameter to query the system at a specific time (optional). */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun time(time: Optional) = time(time.orElse(null) 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() @@ -275,9 +258,14 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [TripDetailRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): TripDetailRetrieveParams = TripDetailRetrieveParams( - checkRequired("tripId", tripId), + tripId, includeSchedule, includeStatus, includeTrip, @@ -288,6 +276,26 @@ private constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> tripId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeSchedule?.let { put("includeSchedule", it.toString()) } + includeStatus?.let { put("includeStatus", it.toString()) } + includeTrip?.let { put("includeTrip", it.toString()) } + serviceDate?.let { put("serviceDate", it.toString()) } + time?.let { put("time", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..06ec303 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt @@ -0,0 +1,3317 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripdetails + +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 TripDetailRetrieveResponse +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 [TripDetailRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripDetailRetrieveResponse]. */ + 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(tripDetailRetrieveResponse: TripDetailRetrieveResponse) = apply { + code = tripDetailRetrieveResponse.code + currentTime = tripDetailRetrieveResponse.currentTime + text = tripDetailRetrieveResponse.text + version = tripDetailRetrieveResponse.version + data = tripDetailRetrieveResponse.data + additionalProperties = tripDetailRetrieveResponse.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 [TripDetailRetrieveResponse]. + * + * 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(): TripDetailRetrieveResponse = + TripDetailRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripDetailRetrieveResponse = 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 + 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 + private constructor( + private val tripId: JsonField, + private val frequency: JsonField, + private val schedule: JsonField, + private val serviceDate: JsonField, + private val situationIds: JsonField>, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(tripId, frequency, schedule, serviceDate, situationIds, status, 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") + + /** + * @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") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun schedule(): Optional = schedule.getOptional("schedule") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDate(): Optional = serviceDate.getOptional("serviceDate") + + /** + * @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") + + /** + * @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") + + /** + * 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 [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 [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * 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 [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 + + @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 + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var tripId: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var schedule: JsonField = JsonMissing.of() + private var serviceDate: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + tripId = entry.tripId + frequency = entry.frequency + schedule = entry.schedule + serviceDate = entry.serviceDate + situationIds = entry.situationIds.map { it.toMutableList() } + status = entry.status + additionalProperties = entry.additionalProperties.toMutableMap() + } + + 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 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. + * + * 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 } + + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + 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 + } + + 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 status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] 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 } + + 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 + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("tripId", tripId), + frequency, + schedule, + serviceDate, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + tripId() + frequency() + schedule().ifPresent { it.validate() } + serviceDate() + situationIds() + status().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 (tripId.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + class Schedule + private constructor( + private val nextTripId: JsonField, + private val previousTripId: JsonField, + private val stopTimes: JsonField>, + private val timeZone: JsonField, + private val frequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("nextTripId") + @ExcludeMissing + nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + ) : this(nextTripId, previousTripId, stopTimes, timeZone, frequency, 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 nextTripId(): String = nextTripId.getRequired("nextTripId") + + /** + * @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 previousTripId(): String = previousTripId.getRequired("previousTripId") + + /** + * @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 timeZone(): String = timeZone.getRequired("timeZone") + + /** + * @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") + + /** + * Returns the raw JSON value of [nextTripId]. + * + * Unlike [nextTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId + + /** + * Returns the raw JSON value of [previousTripId]. + * + * Unlike [previousTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previousTripId") + @ExcludeMissing + fun _previousTripId(): JsonField = previousTripId + + /** + * 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 [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * 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 + + @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 [Schedule]. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes.map { it.toMutableList() } + timeZone = schedule.timeZone + frequency = schedule.frequency + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) + + /** + * Sets [Builder.nextTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.nextTripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextTripId(nextTripId: JsonField) = apply { + this.nextTripId = nextTripId + } + + fun previousTripId(previousTripId: String) = + previousTripId(JsonField.of(previousTripId)) + + /** + * Sets [Builder.previousTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTripId(previousTripId: JsonField) = apply { + this.previousTripId = previousTripId + } + + fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) + + /** + * 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() } + } + + /** + * 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 timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * 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 } + + 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. + * + * 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 + } + + 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 [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), + frequency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schedule = apply { + if (validated) { + return@apply + } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + 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 (nextTripId.asKnown().isPresent) 1 else 0) + + (if (previousTripId.asKnown().isPresent) 1 else 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceAlongTrip(): Optional = + distanceAlongTrip.getOptional("distanceAlongTrip") + + /** + * @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") + + /** + * @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") + + /** + * @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 [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 [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 [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 [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 [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 [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 [StopTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField = JsonMissing.of() + private var departureTime: JsonField = JsonMissing.of() + private var distanceAlongTrip: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + 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 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 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 + } + + 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 + } + + 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 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 [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopTime = + StopTime( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + 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 (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + 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. + * + * @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 [Status]. + * + * 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 [Status]. */ + 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(status: Status) = apply { + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + distanceAlongTrip = status.distanceAlongTrip + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + phase = status.phase + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + serviceDate = status.serviceDate + this.status = status.status + totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } + vehicleId = status.vehicleId + additionalProperties = status.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. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * 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 [Status]. + * + * 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(): Status = + Status( + 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(): Status = 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. */ + class LastKnownLocation + 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 /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + 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 /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is Status && 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Status{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 /* spotless:off */ other is Entry && tripId == other.tripId && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tripId, frequency, schedule, serviceDate, situationIds, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{tripId=$tripId, frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is TripDetailRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripDetailRetrieveResponse{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/TripForVehicleRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParams.kt similarity index 78% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParams.kt index 5d0b04c..66e38ac 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripForVehicleRetrieveParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParams.kt @@ -1,19 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.tripforvehicle import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +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 /** Retrieve trip for a specific vehicle */ class TripForVehicleRetrieveParams private constructor( - private val vehicleId: String, + private val vehicleId: String?, private val includeSchedule: Boolean?, private val includeStatus: Boolean?, private val includeTrip: Boolean?, @@ -22,7 +21,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun vehicleId(): String = vehicleId + fun vehicleId(): Optional = Optional.ofNullable(vehicleId) /** * Determines whether full element is included in the section. @@ -49,34 +48,19 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } - this.includeTrip?.let { queryParams.put("includeTrip", listOf(it.toString())) } - this.time?.let { queryParams.put("time", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> vehicleId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): TripForVehicleRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [TripForVehicleRetrieveParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [TripForVehicleRetrieveParams]. */ - @NoAutoDetect class Builder internal constructor() { private var vehicleId: String? = null @@ -98,7 +82,10 @@ private constructor( additionalQueryParams = tripForVehicleRetrieveParams.additionalQueryParams.toBuilder() } - fun vehicleId(vehicleId: String) = apply { this.vehicleId = vehicleId } + fun vehicleId(vehicleId: String?) = apply { this.vehicleId = vehicleId } + + /** Alias for calling [Builder.vehicleId] with `vehicleId.orElse(null)`. */ + fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.getOrNull()) /** * Determines whether full element is included in the section. @@ -109,18 +96,15 @@ private constructor( } /** - * Determines whether full element is included in the section. - * Defaults to false. + * Alias for [Builder.includeSchedule]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) - /** - * Determines whether full element is included in the section. - * Defaults to false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.includeSchedule] with `includeSchedule.orElse(null)`. */ fun includeSchedule(includeSchedule: Optional) = - includeSchedule(includeSchedule.orElse(null) as Boolean?) + includeSchedule(includeSchedule.getOrNull()) /** * Determines whether the full element is included in the section. @@ -129,18 +113,15 @@ private constructor( fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } /** - * Determines whether the full element is included in the section. - * Defaults to true. + * Alias for [Builder.includeStatus]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) - /** - * Determines whether the full element is included in the section. - * Defaults to true. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.includeStatus] with `includeStatus.orElse(null)`. */ fun includeStatus(includeStatus: Optional) = - includeStatus(includeStatus.orElse(null) as Boolean?) + includeStatus(includeStatus.getOrNull()) /** * Determines whether full element is included in the section. @@ -149,28 +130,27 @@ private constructor( fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } /** - * Determines whether full element is included in the section. - * Defaults to false. + * Alias for [Builder.includeTrip]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip as Boolean?) - /** - * Determines whether full element is included in the section. - * Defaults to false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun includeTrip(includeTrip: Optional) = - includeTrip(includeTrip.orElse(null) as Boolean?) + /** Alias for calling [Builder.includeTrip] with `includeTrip.orElse(null)`. */ + fun includeTrip(includeTrip: Optional) = includeTrip(includeTrip.getOrNull()) /** Time parameter to query the system at a specific time (optional). */ fun time(time: Long?) = apply { this.time = time } - /** Time parameter to query the system at a specific time (optional). */ + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun time(time: Long) = time(time as Long?) - /** Time parameter to query the system at a specific time (optional). */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun time(time: Optional) = time(time.orElse(null) 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() @@ -270,9 +250,14 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [TripForVehicleRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): TripForVehicleRetrieveParams = TripForVehicleRetrieveParams( - checkRequired("vehicleId", vehicleId), + vehicleId, includeSchedule, includeStatus, includeTrip, @@ -282,6 +267,25 @@ private constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> vehicleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeSchedule?.let { put("includeSchedule", it.toString()) } + includeStatus?.let { put("includeStatus", it.toString()) } + includeTrip?.let { put("includeTrip", it.toString()) } + time?.let { put("time", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..62e25fa --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt @@ -0,0 +1,3319 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripforvehicle + +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 TripForVehicleRetrieveResponse +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 + * [TripForVehicleRetrieveResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripForVehicleRetrieveResponse]. */ + 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(tripForVehicleRetrieveResponse: TripForVehicleRetrieveResponse) = apply { + code = tripForVehicleRetrieveResponse.code + currentTime = tripForVehicleRetrieveResponse.currentTime + text = tripForVehicleRetrieveResponse.text + version = tripForVehicleRetrieveResponse.version + data = tripForVehicleRetrieveResponse.data + additionalProperties = + tripForVehicleRetrieveResponse.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 [TripForVehicleRetrieveResponse]. + * + * 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(): TripForVehicleRetrieveResponse = + TripForVehicleRetrieveResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripForVehicleRetrieveResponse = 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 + 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 + private constructor( + private val tripId: JsonField, + private val frequency: JsonField, + private val schedule: JsonField, + private val serviceDate: JsonField, + private val situationIds: JsonField>, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(tripId, frequency, schedule, serviceDate, situationIds, status, 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") + + /** + * @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") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun schedule(): Optional = schedule.getOptional("schedule") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDate(): Optional = serviceDate.getOptional("serviceDate") + + /** + * @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") + + /** + * @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") + + /** + * 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 [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 [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * 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 [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 + + @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 + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entry]. */ + class Builder internal constructor() { + + private var tripId: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var schedule: JsonField = JsonMissing.of() + private var serviceDate: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entry: Entry) = apply { + tripId = entry.tripId + frequency = entry.frequency + schedule = entry.schedule + serviceDate = entry.serviceDate + situationIds = entry.situationIds.map { it.toMutableList() } + status = entry.status + additionalProperties = entry.additionalProperties.toMutableMap() + } + + 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 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. + * + * 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 } + + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + 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 + } + + 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 status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] 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 } + + 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 + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Entry = + Entry( + checkRequired("tripId", tripId), + frequency, + schedule, + serviceDate, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Entry = apply { + if (validated) { + return@apply + } + + tripId() + frequency() + schedule().ifPresent { it.validate() } + serviceDate() + situationIds() + status().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 (tripId.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + class Schedule + private constructor( + private val nextTripId: JsonField, + private val previousTripId: JsonField, + private val stopTimes: JsonField>, + private val timeZone: JsonField, + private val frequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("nextTripId") + @ExcludeMissing + nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + ) : this(nextTripId, previousTripId, stopTimes, timeZone, frequency, 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 nextTripId(): String = nextTripId.getRequired("nextTripId") + + /** + * @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 previousTripId(): String = previousTripId.getRequired("previousTripId") + + /** + * @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 timeZone(): String = timeZone.getRequired("timeZone") + + /** + * @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") + + /** + * Returns the raw JSON value of [nextTripId]. + * + * Unlike [nextTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId + + /** + * Returns the raw JSON value of [previousTripId]. + * + * Unlike [previousTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previousTripId") + @ExcludeMissing + fun _previousTripId(): JsonField = previousTripId + + /** + * 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 [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * 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 + + @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 [Schedule]. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes.map { it.toMutableList() } + timeZone = schedule.timeZone + frequency = schedule.frequency + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) + + /** + * Sets [Builder.nextTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.nextTripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextTripId(nextTripId: JsonField) = apply { + this.nextTripId = nextTripId + } + + fun previousTripId(previousTripId: String) = + previousTripId(JsonField.of(previousTripId)) + + /** + * Sets [Builder.previousTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTripId(previousTripId: JsonField) = apply { + this.previousTripId = previousTripId + } + + fun stopTimes(stopTimes: List) = stopTimes(JsonField.of(stopTimes)) + + /** + * 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() } + } + + /** + * 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 timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * 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 } + + 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. + * + * 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 + } + + 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 [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), + frequency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schedule = apply { + if (validated) { + return@apply + } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + 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 (nextTripId.asKnown().isPresent) 1 else 0) + + (if (previousTripId.asKnown().isPresent) 1 else 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceAlongTrip(): Optional = + distanceAlongTrip.getOptional("distanceAlongTrip") + + /** + * @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") + + /** + * @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") + + /** + * @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 [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 [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 [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 [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 [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 [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 [StopTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField = JsonMissing.of() + private var departureTime: JsonField = JsonMissing.of() + private var distanceAlongTrip: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + 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 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 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 + } + + 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 + } + + 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 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 [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopTime = + StopTime( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + 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 (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + 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. + * + * @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 [Status]. + * + * 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 [Status]. */ + 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(status: Status) = apply { + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + distanceAlongTrip = status.distanceAlongTrip + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + phase = status.phase + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + serviceDate = status.serviceDate + this.status = status.status + totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } + vehicleId = status.vehicleId + additionalProperties = status.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. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * 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 [Status]. + * + * 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(): Status = + Status( + 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(): Status = 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. */ + class LastKnownLocation + 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 /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + 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 /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is Status && 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Status{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 /* spotless:off */ other is Entry && tripId == other.tripId && frequency == other.frequency && schedule == other.schedule && serviceDate == other.serviceDate && situationIds == other.situationIds && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tripId, frequency, schedule, serviceDate, situationIds, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Entry{tripId=$tripId, frequency=$frequency, schedule=$schedule, serviceDate=$serviceDate, situationIds=$situationIds, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && entry == other.entry && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is TripForVehicleRetrieveResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripForVehicleRetrieveResponse{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/TripsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParams.kt similarity index 75% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParams.kt index 18afcad..9bc7aad 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForLocationListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.tripsforlocation import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.Params import org.onebusaway.core.checkRequired import org.onebusaway.core.http.Headers @@ -13,10 +13,10 @@ import org.onebusaway.core.http.QueryParams /** Retrieve trips for a given location */ class TripsForLocationListParams private constructor( - private val lat: Double, - private val latSpan: Double, - private val lon: Double, - private val lonSpan: Double, + private val lat: Float, + private val latSpan: Float, + private val lon: Float, + private val lonSpan: Float, private val includeSchedule: Boolean?, private val includeTrip: Boolean?, private val time: Long?, @@ -25,16 +25,16 @@ private constructor( ) : Params { /** The latitude coordinate of the search center */ - fun lat(): Double = lat + fun lat(): Float = lat /** Latitude span of the search bounding box */ - fun latSpan(): Double = latSpan + fun latSpan(): Float = latSpan /** The longitude coordinate of the search center */ - fun lon(): Double = lon + fun lon(): Float = lon /** Longitude span of the search bounding box */ - fun lonSpan(): Double = lonSpan + fun lonSpan(): Float = lonSpan /** Whether to include full schedule elements in the tripDetails section. Defaults to false. */ fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) @@ -49,36 +49,31 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.lat.let { queryParams.put("lat", listOf(it.toString())) } - this.latSpan.let { queryParams.put("latSpan", listOf(it.toString())) } - this.lon.let { queryParams.put("lon", listOf(it.toString())) } - this.lonSpan.let { queryParams.put("lonSpan", listOf(it.toString())) } - this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } - this.includeTrip?.let { queryParams.put("includeTrip", listOf(it.toString())) } - this.time?.let { queryParams.put("time", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [TripsForLocationListParams]. + * + * The following fields are required: + * ```java + * .lat() + * .latSpan() + * .lon() + * .lonSpan() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [TripsForLocationListParams]. */ - @NoAutoDetect class Builder internal constructor() { - private var lat: Double? = null - private var latSpan: Double? = null - private var lon: Double? = null - private var lonSpan: Double? = null + private var lat: Float? = null + private var latSpan: Float? = null + private var lon: Float? = null + private var lonSpan: Float? = null private var includeSchedule: Boolean? = null private var includeTrip: Boolean? = null private var time: Long? = null @@ -99,16 +94,16 @@ private constructor( } /** The latitude coordinate of the search center */ - fun lat(lat: Double) = apply { this.lat = lat } + fun lat(lat: Float) = apply { this.lat = lat } /** Latitude span of the search bounding box */ - fun latSpan(latSpan: Double) = apply { this.latSpan = latSpan } + fun latSpan(latSpan: Float) = apply { this.latSpan = latSpan } /** The longitude coordinate of the search center */ - fun lon(lon: Double) = apply { this.lon = lon } + fun lon(lon: Float) = apply { this.lon = lon } /** Longitude span of the search bounding box */ - fun lonSpan(lonSpan: Double) = apply { this.lonSpan = lonSpan } + fun lonSpan(lonSpan: Float) = apply { this.lonSpan = lonSpan } /** * Whether to include full schedule elements in the tripDetails section. Defaults to false. @@ -118,37 +113,41 @@ private constructor( } /** - * Whether to include full schedule elements in the tripDetails section. Defaults to false. + * Alias for [Builder.includeSchedule]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) - /** - * Whether to include full schedule elements in the tripDetails section. Defaults to false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.includeSchedule] with `includeSchedule.orElse(null)`. */ fun includeSchedule(includeSchedule: Optional) = - includeSchedule(includeSchedule.orElse(null) as Boolean?) + includeSchedule(includeSchedule.getOrNull()) /** Whether to include full trip elements in the references section. Defaults to false. */ fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } - /** Whether to include full trip elements in the references section. Defaults to false. */ + /** + * Alias for [Builder.includeTrip]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip as Boolean?) - /** Whether to include full trip elements in the references section. Defaults to false. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun includeTrip(includeTrip: Optional) = - includeTrip(includeTrip.orElse(null) as Boolean?) + /** Alias for calling [Builder.includeTrip] with `includeTrip.orElse(null)`. */ + fun includeTrip(includeTrip: Optional) = includeTrip(includeTrip.getOrNull()) /** Specific time for the query. Defaults to the current time. */ fun time(time: Long?) = apply { this.time = time } - /** Specific time for the query. Defaults to the current time. */ + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun time(time: Long) = time(time as Long?) - /** Specific time for the query. Defaults to the current time. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun time(time: Optional) = time(time.orElse(null) 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() @@ -248,6 +247,21 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [TripsForLocationListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .lat() + * .latSpan() + * .lon() + * .lonSpan() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): TripsForLocationListParams = TripsForLocationListParams( checkRequired("lat", lat), @@ -262,6 +276,22 @@ private constructor( ) } + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("lat", lat.toString()) + put("latSpan", latSpan.toString()) + put("lon", lon.toString()) + put("lonSpan", lonSpan.toString()) + includeSchedule?.let { put("includeSchedule", it.toString()) } + includeTrip?.let { put("includeTrip", it.toString()) } + time?.let { put("time", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..ca490ce --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt @@ -0,0 +1,3428 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforlocation + +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 TripsForLocationListResponse +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 [TripsForLocationListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripsForLocationListResponse]. */ + 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(tripsForLocationListResponse: TripsForLocationListResponse) = apply { + code = tripsForLocationListResponse.code + currentTime = tripsForLocationListResponse.currentTime + text = tripsForLocationListResponse.text + version = tripsForLocationListResponse.version + data = tripsForLocationListResponse.data + additionalProperties = tripsForLocationListResponse.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 [TripsForLocationListResponse]. + * + * 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(): TripsForLocationListResponse = + TripsForLocationListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripsForLocationListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: 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("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") + + /** + * @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") + + /** + * Indicates if the search location is out of range + * + * @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") + + /** + * 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]. + * + * Unlike [outOfRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outOfRange") + @ExcludeMissing + fun _outOfRange(): JsonField = outOfRange + + @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 + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 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 + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 + } + + /** Indicates if the search location is out of range */ + 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 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 + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + 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(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.validate() } + references().validate() + outOfRange() + 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 (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) + + class List + private constructor( + private val schedule: JsonField, + private val status: JsonField, + private val tripId: JsonField, + private val frequency: JsonField, + private val serviceDate: JsonField, + private val situationIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + ) : 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). + */ + fun schedule(): Schedule = schedule.getRequired("schedule") + + /** + * @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(): Status = status.getRequired("status") + + /** + * @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 frequency(): Optional = frequency.getOptional("frequency") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDate(): Optional = serviceDate.getOptional("serviceDate") + + /** + * @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 [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * 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 [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 [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 [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 [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 [List]. + * + * The following fields are required: + * ```java + * .schedule() + * .status() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var schedule: JsonField? = null + private var status: JsonField? = null + private var tripId: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var serviceDate: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + schedule = list.schedule + status = list.status + tripId = list.tripId + frequency = list.frequency + serviceDate = list.serviceDate + situationIds = list.situationIds.map { it.toMutableList() } + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] 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 } + + 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 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. + * + * 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 } + + 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 + } + + fun situationIds(situationIds: kotlin.collections.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 [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .schedule() + * .status() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("schedule", schedule), + checkRequired("status", status), + checkRequired("tripId", tripId), + frequency, + serviceDate, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + schedule().validate() + status().validate() + tripId() + frequency() + serviceDate() + 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 = + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + class Schedule + private constructor( + private val nextTripId: JsonField, + private val previousTripId: JsonField, + private val stopTimes: JsonField>, + private val timeZone: JsonField, + private val frequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("nextTripId") + @ExcludeMissing + nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + ) : this(nextTripId, previousTripId, stopTimes, timeZone, frequency, 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 nextTripId(): String = nextTripId.getRequired("nextTripId") + + /** + * @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 previousTripId(): String = previousTripId.getRequired("previousTripId") + + /** + * @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(): kotlin.collections.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 timeZone(): String = timeZone.getRequired("timeZone") + + /** + * @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") + + /** + * Returns the raw JSON value of [nextTripId]. + * + * Unlike [nextTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId + + /** + * Returns the raw JSON value of [previousTripId]. + * + * Unlike [previousTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previousTripId") + @ExcludeMissing + fun _previousTripId(): JsonField = previousTripId + + /** + * 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 [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * 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 + + @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 [Schedule]. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes.map { it.toMutableList() } + timeZone = schedule.timeZone + frequency = schedule.frequency + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) + + /** + * Sets [Builder.nextTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.nextTripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextTripId(nextTripId: JsonField) = apply { + this.nextTripId = nextTripId + } + + fun previousTripId(previousTripId: String) = + previousTripId(JsonField.of(previousTripId)) + + /** + * Sets [Builder.previousTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTripId(previousTripId: JsonField) = apply { + this.previousTripId = previousTripId + } + + fun stopTimes(stopTimes: kotlin.collections.List) = + stopTimes(JsonField.of(stopTimes)) + + /** + * 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() } + } + + /** + * 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 timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * 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 } + + 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. + * + * 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 + } + + 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 [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), + frequency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schedule = apply { + if (validated) { + return@apply + } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + 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 (nextTripId.asKnown().isPresent) 1 else 0) + + (if (previousTripId.asKnown().isPresent) 1 else 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceAlongTrip(): Optional = + distanceAlongTrip.getOptional("distanceAlongTrip") + + /** + * @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") + + /** + * @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") + + /** + * @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 [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 [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 [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 [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 [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 [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 [StopTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField = JsonMissing.of() + private var departureTime: JsonField = JsonMissing.of() + private var distanceAlongTrip: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + 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 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 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 + } + + 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 + } + + 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 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 [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopTime = + StopTime( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + 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 (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + 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. + * + * @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 [Status]. + * + * 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 [Status]. */ + 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(status: Status) = apply { + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + distanceAlongTrip = status.distanceAlongTrip + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + phase = status.phase + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + serviceDate = status.serviceDate + this.status = status.status + totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } + vehicleId = status.vehicleId + additionalProperties = status.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. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * 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: kotlin.collections.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 [Status]. + * + * 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(): Status = + Status( + 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(): Status = 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. */ + class LastKnownLocation + 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 /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + 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 /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is Status && 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Status{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 /* spotless:off */ other is List && schedule == other.schedule && status == other.status && tripId == other.tripId && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(schedule, status, tripId, frequency, serviceDate, situationIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{schedule=$schedule, status=$status, tripId=$tripId, frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && outOfRange == other.outOfRange && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripsForLocationListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripsForLocationListResponse{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/TripsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParams.kt similarity index 79% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParams.kt index d583984..fcf6831 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/TripsForRouteListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParams.kt @@ -1,19 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.tripsforroute import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +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 /** Search for active trips for a specific route. */ class TripsForRouteListParams private constructor( - private val routeId: String, + private val routeId: String?, private val includeSchedule: Boolean?, private val includeStatus: Boolean?, private val time: Long?, @@ -21,7 +20,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun routeId(): String = routeId + fun routeId(): Optional = Optional.ofNullable(routeId) /** Determine whether full schedule elements are included. Defaults to false. */ fun includeSchedule(): Optional = Optional.ofNullable(includeSchedule) @@ -39,33 +38,17 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.includeSchedule?.let { queryParams.put("includeSchedule", listOf(it.toString())) } - this.includeStatus?.let { queryParams.put("includeStatus", listOf(it.toString())) } - this.time?.let { queryParams.put("time", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> routeId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): TripsForRouteListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TripsForRouteListParams]. */ @JvmStatic fun builder() = Builder() } /** A builder for [TripsForRouteListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var routeId: String? = null @@ -85,20 +68,26 @@ private constructor( additionalQueryParams = tripsForRouteListParams.additionalQueryParams.toBuilder() } - fun routeId(routeId: String) = apply { this.routeId = routeId } + fun routeId(routeId: String?) = apply { this.routeId = routeId } + + /** Alias for calling [Builder.routeId] with `routeId.orElse(null)`. */ + fun routeId(routeId: Optional) = routeId(routeId.getOrNull()) /** Determine whether full schedule elements are included. Defaults to false. */ fun includeSchedule(includeSchedule: Boolean?) = apply { this.includeSchedule = includeSchedule } - /** Determine whether full schedule elements are included. Defaults to false. */ + /** + * Alias for [Builder.includeSchedule]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) - /** Determine whether full schedule elements are included. Defaults to false. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.includeSchedule] with `includeSchedule.orElse(null)`. */ fun includeSchedule(includeSchedule: Optional) = - includeSchedule(includeSchedule.orElse(null) as Boolean?) + includeSchedule(includeSchedule.getOrNull()) /** * Determine whether full tripStatus elements with real-time information are included. @@ -107,28 +96,28 @@ private constructor( fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } /** - * Determine whether full tripStatus elements with real-time information are included. - * Defaults to false. + * Alias for [Builder.includeStatus]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) - /** - * Determine whether full tripStatus elements with real-time information are included. - * Defaults to false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + /** Alias for calling [Builder.includeStatus] with `includeStatus.orElse(null)`. */ fun includeStatus(includeStatus: Optional) = - includeStatus(includeStatus.orElse(null) as Boolean?) + includeStatus(includeStatus.getOrNull()) /** Query the system at a specific time. Useful for testing. */ fun time(time: Long?) = apply { this.time = time } - /** Query the system at a specific time. Useful for testing. */ + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun time(time: Long) = time(time as Long?) - /** Query the system at a specific time. Useful for testing. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun time(time: Optional) = time(time.orElse(null) 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() @@ -228,9 +217,14 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [TripsForRouteListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): TripsForRouteListParams = TripsForRouteListParams( - checkRequired("routeId", routeId), + routeId, includeSchedule, includeStatus, time, @@ -239,6 +233,24 @@ private constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> routeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeSchedule?.let { put("includeSchedule", it.toString()) } + includeStatus?.let { put("includeStatus", it.toString()) } + time?.let { put("time", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..7dcf7a4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt @@ -0,0 +1,3387 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforroute + +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 TripsForRouteListResponse +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 [TripsForRouteListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripsForRouteListResponse]. */ + 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(tripsForRouteListResponse: TripsForRouteListResponse) = apply { + code = tripsForRouteListResponse.code + currentTime = tripsForRouteListResponse.currentTime + text = tripsForRouteListResponse.text + version = tripsForRouteListResponse.version + data = tripsForRouteListResponse.data + additionalProperties = tripsForRouteListResponse.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 [TripsForRouteListResponse]. + * + * 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(): TripsForRouteListResponse = + TripsForRouteListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TripsForRouteListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: 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") + + /** + * @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") + + /** + * 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 + + @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 + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + private constructor( + private val schedule: JsonField, + private val status: JsonField, + private val tripId: JsonField, + private val frequency: JsonField, + private val serviceDate: JsonField, + private val situationIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + ) : 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). + */ + fun schedule(): Schedule = schedule.getRequired("schedule") + + /** + * @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(): Status = status.getRequired("status") + + /** + * @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 frequency(): Optional = frequency.getOptional("frequency") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun serviceDate(): Optional = serviceDate.getOptional("serviceDate") + + /** + * @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 [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * 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 [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 [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 [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 [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 [List]. + * + * The following fields are required: + * ```java + * .schedule() + * .status() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var schedule: JsonField? = null + private var status: JsonField? = null + private var tripId: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var serviceDate: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + schedule = list.schedule + status = list.status + tripId = list.tripId + frequency = list.frequency + serviceDate = list.serviceDate + situationIds = list.situationIds.map { it.toMutableList() } + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] 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 } + + 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 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. + * + * 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 } + + 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 + } + + fun situationIds(situationIds: kotlin.collections.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 [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .schedule() + * .status() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("schedule", schedule), + checkRequired("status", status), + checkRequired("tripId", tripId), + frequency, + serviceDate, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + schedule().validate() + status().validate() + tripId() + frequency() + serviceDate() + 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 = + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + class Schedule + private constructor( + private val nextTripId: JsonField, + private val previousTripId: JsonField, + private val stopTimes: JsonField>, + private val timeZone: JsonField, + private val frequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("nextTripId") + @ExcludeMissing + nextTripId: JsonField = JsonMissing.of(), + @JsonProperty("previousTripId") + @ExcludeMissing + previousTripId: JsonField = JsonMissing.of(), + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + ) : this(nextTripId, previousTripId, stopTimes, timeZone, frequency, 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 nextTripId(): String = nextTripId.getRequired("nextTripId") + + /** + * @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 previousTripId(): String = previousTripId.getRequired("previousTripId") + + /** + * @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(): kotlin.collections.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 timeZone(): String = timeZone.getRequired("timeZone") + + /** + * @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") + + /** + * Returns the raw JSON value of [nextTripId]. + * + * Unlike [nextTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("nextTripId") + @ExcludeMissing + fun _nextTripId(): JsonField = nextTripId + + /** + * Returns the raw JSON value of [previousTripId]. + * + * Unlike [previousTripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previousTripId") + @ExcludeMissing + fun _previousTripId(): JsonField = previousTripId + + /** + * 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 [timeZone]. + * + * Unlike [timeZone], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("timeZone") + @ExcludeMissing + fun _timeZone(): JsonField = timeZone + + /** + * 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 + + @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 [Schedule]. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var nextTripId: JsonField? = null + private var previousTripId: JsonField? = null + private var stopTimes: JsonField>? = null + private var timeZone: JsonField? = null + private var frequency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + nextTripId = schedule.nextTripId + previousTripId = schedule.previousTripId + stopTimes = schedule.stopTimes.map { it.toMutableList() } + timeZone = schedule.timeZone + frequency = schedule.frequency + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + fun nextTripId(nextTripId: String) = nextTripId(JsonField.of(nextTripId)) + + /** + * Sets [Builder.nextTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.nextTripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextTripId(nextTripId: JsonField) = apply { + this.nextTripId = nextTripId + } + + fun previousTripId(previousTripId: String) = + previousTripId(JsonField.of(previousTripId)) + + /** + * Sets [Builder.previousTripId] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTripId(previousTripId: JsonField) = apply { + this.previousTripId = previousTripId + } + + fun stopTimes(stopTimes: kotlin.collections.List) = + stopTimes(JsonField.of(stopTimes)) + + /** + * 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() } + } + + /** + * 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 timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + + /** + * 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 } + + 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. + * + * 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 + } + + 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 [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nextTripId() + * .previousTripId() + * .stopTimes() + * .timeZone() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("nextTripId", nextTripId), + checkRequired("previousTripId", previousTripId), + checkRequired("stopTimes", stopTimes).map { it.toImmutable() }, + checkRequired("timeZone", timeZone), + frequency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schedule = apply { + if (validated) { + return@apply + } + + nextTripId() + previousTripId() + stopTimes().forEach { it.validate() } + timeZone() + frequency() + 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 (nextTripId.asKnown().isPresent) 1 else 0) + + (if (previousTripId.asKnown().isPresent) 1 else 0) + + (stopTimes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (timeZone.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + class StopTime + private constructor( + private val arrivalTime: JsonField, + private val departureTime: JsonField, + private val distanceAlongTrip: JsonField, + private val historicalOccupancy: JsonField, + private val stopHeadsign: JsonField, + private val stopId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + ) : this( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun arrivalTime(): Optional = arrivalTime.getOptional("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun departureTime(): Optional = departureTime.getOptional("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceAlongTrip(): Optional = + distanceAlongTrip.getOptional("distanceAlongTrip") + + /** + * @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") + + /** + * @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") + + /** + * @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 [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 [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 [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 [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 [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 [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 [StopTime]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalTime: JsonField = JsonMissing.of() + private var departureTime: JsonField = JsonMissing.of() + private var distanceAlongTrip: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalTime = stopTime.arrivalTime + departureTime = stopTime.departureTime + distanceAlongTrip = stopTime.distanceAlongTrip + historicalOccupancy = stopTime.historicalOccupancy + stopHeadsign = stopTime.stopHeadsign + stopId = stopTime.stopId + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + 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 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 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 + } + + 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 + } + + 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 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 [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopTime = + StopTime( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalTime() + departureTime() + distanceAlongTrip() + historicalOccupancy() + stopHeadsign() + 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 (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (distanceAlongTrip.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is StopTime && arrivalTime == other.arrivalTime && departureTime == other.departureTime && distanceAlongTrip == other.distanceAlongTrip && historicalOccupancy == other.historicalOccupancy && stopHeadsign == other.stopHeadsign && stopId == other.stopId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arrivalTime, departureTime, distanceAlongTrip, historicalOccupancy, stopHeadsign, stopId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schedule && nextTripId == other.nextTripId && previousTripId == other.previousTripId && stopTimes == other.stopTimes && timeZone == other.timeZone && frequency == other.frequency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(nextTripId, previousTripId, stopTimes, timeZone, frequency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + 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. + * + * @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 [Status]. + * + * 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 [Status]. */ + 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(status: Status) = apply { + activeTripId = status.activeTripId + blockTripSequence = status.blockTripSequence + closestStop = status.closestStop + distanceAlongTrip = status.distanceAlongTrip + lastKnownDistanceAlongTrip = status.lastKnownDistanceAlongTrip + lastLocationUpdateTime = status.lastLocationUpdateTime + lastUpdateTime = status.lastUpdateTime + occupancyCapacity = status.occupancyCapacity + occupancyCount = status.occupancyCount + occupancyStatus = status.occupancyStatus + phase = status.phase + predicted = status.predicted + scheduleDeviation = status.scheduleDeviation + serviceDate = status.serviceDate + this.status = status.status + totalDistanceAlongTrip = status.totalDistanceAlongTrip + closestStopTimeOffset = status.closestStopTimeOffset + frequency = status.frequency + lastKnownLocation = status.lastKnownLocation + lastKnownOrientation = status.lastKnownOrientation + nextStop = status.nextStop + nextStopTimeOffset = status.nextStopTimeOffset + orientation = status.orientation + position = status.position + scheduledDistanceAlongTrip = status.scheduledDistanceAlongTrip + situationIds = status.situationIds.map { it.toMutableList() } + vehicleId = status.vehicleId + additionalProperties = status.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. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * 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: kotlin.collections.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 [Status]. + * + * 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(): Status = + Status( + 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(): Status = 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. */ + class LastKnownLocation + 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 /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + 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 /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ other is Status && 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Status{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 /* spotless:off */ other is List && schedule == other.schedule && status == other.status && tripId == other.tripId && frequency == other.frequency && serviceDate == other.serviceDate && situationIds == other.situationIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(schedule, status, tripId, frequency, serviceDate, situationIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{schedule=$schedule, status=$status, tripId=$tripId, frequency=$frequency, serviceDate=$serviceDate, situationIds=$situationIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TripsForRouteListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripsForRouteListResponse{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/VehiclesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParams.kt similarity index 83% rename from onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt rename to onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParams.kt index 37a0200..5398c9c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/VehiclesForAgencyListParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParams.kt @@ -1,25 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.vehiclesforagency import java.util.Objects import java.util.Optional -import org.onebusaway.core.NoAutoDetect +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 /** Get vehicles for a specific agency */ class VehiclesForAgencyListParams private constructor( - private val agencyId: String, + private val agencyId: String?, private val time: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun agencyId(): String = agencyId + fun agencyId(): Optional = Optional.ofNullable(agencyId) /** Specific time for querying the status (timestamp format) */ fun time(): Optional = Optional.ofNullable(time) @@ -28,31 +27,19 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.time?.let { queryParams.put("time", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> agencyId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): VehiclesForAgencyListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [VehiclesForAgencyListParams]. + */ @JvmStatic fun builder() = Builder() } /** A builder for [VehiclesForAgencyListParams]. */ - @NoAutoDetect class Builder internal constructor() { private var agencyId: String? = null @@ -68,13 +55,16 @@ private constructor( additionalQueryParams = vehiclesForAgencyListParams.additionalQueryParams.toBuilder() } - fun agencyId(agencyId: String) = apply { this.agencyId = agencyId } + fun agencyId(agencyId: String?) = apply { this.agencyId = agencyId } + + /** Alias for calling [Builder.agencyId] with `agencyId.orElse(null)`. */ + fun agencyId(agencyId: Optional) = agencyId(agencyId.getOrNull()) /** Specific time for querying the status (timestamp format) */ fun time(time: String?) = apply { this.time = time } - /** Specific time for querying the status (timestamp format) */ - fun time(time: Optional) = time(time.orElse(null)) + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -174,15 +164,36 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [VehiclesForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): VehiclesForAgencyListParams = VehiclesForAgencyListParams( - checkRequired("agencyId", agencyId), + agencyId, time, additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> agencyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + time?.let { put("time", it) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 new file mode 100644 index 0000000..1b3af09 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -0,0 +1,3052 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.vehiclesforagency + +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 VehiclesForAgencyListResponse +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 + * [VehiclesForAgencyListResponse]. + * + * The following fields are required: + * ```java + * .code() + * .currentTime() + * .text() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VehiclesForAgencyListResponse]. */ + 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(vehiclesForAgencyListResponse: VehiclesForAgencyListResponse) = apply { + code = vehiclesForAgencyListResponse.code + currentTime = vehiclesForAgencyListResponse.currentTime + text = vehiclesForAgencyListResponse.text + version = vehiclesForAgencyListResponse.version + data = vehiclesForAgencyListResponse.data + additionalProperties = vehiclesForAgencyListResponse.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 [VehiclesForAgencyListResponse]. + * + * 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(): VehiclesForAgencyListResponse = + VehiclesForAgencyListResponse( + checkRequired("code", code), + checkRequired("currentTime", currentTime), + checkRequired("text", text), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VehiclesForAgencyListResponse = 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 + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val references: 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") + + /** + * @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") + + /** + * 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 + + @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 + * .limitExceeded() + * .list() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + limitExceeded = data.limitExceeded + list = data.list.map { it.toMutableList() } + references = data.references + 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)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * 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 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 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 + * .limitExceeded() + * .list() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("limitExceeded", limitExceeded), + checkRequired("list", list).map { it.toImmutable() }, + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + limitExceeded() + list().forEach { it.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 = + (if (limitExceeded.asKnown().isPresent) 1 else 0) + + (list.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class List + 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 occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @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("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("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this( + lastLocationUpdateTime, + lastUpdateTime, + location, + tripId, + tripStatus, + vehicleId, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + status, + 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 lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * @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") + + /** + * @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 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") + + /** + * @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") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun occupancyCapacity(): Optional = + occupancyCapacity.getOptional("occupancyCapacity") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun occupancyCount(): Optional = occupancyCount.getOptional("occupancyCount") + + /** + * @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") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun phase(): Optional = phase.getOptional("phase") + + /** + * @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") + + /** + * 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 [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]. + * + * Unlike [tripStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus + + /** + * 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 [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 [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @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 + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .location() + * .tripId() + * .tripStatus() + * .vehicleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal 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 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 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 + occupancyCapacity = list.occupancyCapacity + occupancyCount = list.occupancyCount + occupancyStatus = list.occupancyStatus + phase = list.phase + status = list.status + additionalProperties = list.additionalProperties.toMutableMap() + } + + 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 + } + + 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 + } + + 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)) + + /** + * 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 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 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 + } + + 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 + } + + 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 + } + + 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 } + + 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 } + + 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 + * .lastLocationUpdateTime() + * .lastUpdateTime() + * .location() + * .tripId() + * .tripStatus() + * .vehicleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("lastLocationUpdateTime", lastLocationUpdateTime), + checkRequired("lastUpdateTime", lastUpdateTime), + checkRequired("location", location), + checkRequired("tripId", tripId), + checkRequired("tripStatus", tripStatus), + checkRequired("vehicleId", vehicleId), + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + lastLocationUpdateTime() + lastUpdateTime() + location().validate() + tripId() + tripStatus().validate() + vehicleId() + occupancyCapacity() + occupancyCount() + occupancyStatus() + phase() + status() + 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 (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) + + (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) + + class Location + 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()) + + /** + * @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") + + /** + * @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 [Location]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Location]. */ + 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(location: Location) = apply { + lat = location.lat + lon = location.lon + additionalProperties = location.additionalProperties.toMutableMap() + } + + 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 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 [Location]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Location = Location(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Location = 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 /* spotless:off */ other is Location && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Location{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + class TripStatus + 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. + * + * @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. */ + fun lastKnownLocation(lastKnownLocation: LastKnownLocation) = + lastKnownLocation(JsonField.of(lastKnownLocation)) + + /** + * 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: kotlin.collections.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. */ + class LastKnownLocation + 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 /* spotless:off */ other is LastKnownLocation && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + 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 /* spotless:off */ other is Position && lat == other.lat && lon == other.lon && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + /* spotless:on */ + + 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 /* spotless:off */ 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 /* spotless:on */ + } + + /* spotless:off */ + 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) } + /* spotless:on */ + + 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 /* spotless:off */ other is List && lastLocationUpdateTime == other.lastLocationUpdateTime && lastUpdateTime == other.lastUpdateTime && location == other.location && tripId == other.tripId && tripStatus == other.tripStatus && vehicleId == other.vehicleId && occupancyCapacity == other.occupancyCapacity && occupancyCount == other.occupancyCount && occupancyStatus == other.occupancyStatus && phase == other.phase && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(lastLocationUpdateTime, lastUpdateTime, location, tripId, tripStatus, vehicleId, occupancyCapacity, occupancyCount, occupancyStatus, phase, status, additionalProperties) } + /* spotless:on */ + + 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}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && limitExceeded == other.limitExceeded && list == other.list && references == other.references && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(limitExceeded, list, references, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is VehiclesForAgencyListResponse && code == other.code && currentTime == other.currentTime && text == other.text && version == other.version && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, currentTime, text, version, data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VehiclesForAgencyListResponse{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/AgenciesWithCoverageServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt index 202311d..3b4ca66 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt @@ -1,23 +1,76 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.AgenciesWithCoverageListParams -import org.onebusaway.models.AgenciesWithCoverageListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse interface AgenciesWithCoverageServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Returns a list of all transit agencies currently supported by OneBusAway along with the * center of their coverage area. */ - @JvmOverloads + fun list(): CompletableFuture = + list(AgenciesWithCoverageListParams.none()) + + /** @see [list] */ fun list( - params: AgenciesWithCoverageListParams, - requestOptions: RequestOptions = RequestOptions.none() + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(AgenciesWithCoverageListParams.none(), requestOptions) + + /** + * A view of [AgenciesWithCoverageServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/agencies-with-coverage.json`, but is + * otherwise the same as [AgenciesWithCoverageServiceAsync.list]. + */ + @MustBeClosed + fun list(): CompletableFuture> = + list(AgenciesWithCoverageListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(AgenciesWithCoverageListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt index 987fee8..ae8826a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,46 +12,62 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.AgenciesWithCoverageListParams -import org.onebusaway.models.AgenciesWithCoverageListResponse +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse class AgenciesWithCoverageServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : AgenciesWithCoverageServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCoverageServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AgenciesWithCoverageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): AgenciesWithCoverageServiceAsync.WithRawResponse = + withRawResponse - /** - * Returns a list of all transit agencies currently supported by OneBusAway along with the - * center of their coverage area. - */ override fun list( params: AgenciesWithCoverageListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "agencies-with-coverage.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/agencies-with-coverage.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AgenciesWithCoverageServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AgenciesWithCoverageListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "agencies-with-coverage.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/AgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt index 6520228..65fa413 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt @@ -1,20 +1,106 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.AgencyRetrieveParams -import org.onebusaway.models.AgencyRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.agency.AgencyRetrieveParams +import org.onebusaway.models.agency.AgencyRetrieveResponse interface AgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve information for a specific transit agency identified by its unique ID. */ - @JvmOverloads + fun retrieve(agencyId: String): CompletableFuture = + retrieve(agencyId, AgencyRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + ): CompletableFuture = retrieve(agencyId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: AgencyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: AgencyRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(agencyId, AgencyRetrieveParams.none(), requestOptions) + + /** + * A view of [AgencyServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/agency/{agencyID}.json`, but is otherwise + * the same as [AgencyServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(agencyId: String): CompletableFuture> = + retrieve(agencyId, AgencyRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + ): CompletableFuture> = + retrieve(agencyId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AgencyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AgencyRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(agencyId, AgencyRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt index f11f454..b4ee1be 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt @@ -3,50 +3,75 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.AgencyRetrieveParams -import org.onebusaway.models.AgencyRetrieveResponse +import org.onebusaway.models.agency.AgencyRetrieveParams +import org.onebusaway.models.agency.AgencyRetrieveResponse -class AgencyServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : AgencyServiceAsync { +class AgencyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): AgencyServiceAsync.WithRawResponse = withRawResponse - /** Retrieve information for a specific transit agency identified by its unique ID. */ override fun retrieve( params: AgencyRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "agency", "${params.getPathParam(0)}.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/agency/{agencyID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: AgencyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "agency", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt index 339e502..5d85667 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt @@ -1,29 +1,176 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureListResponse -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListResponse +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveResponse interface ArrivalAndDepartureServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** arrival-and-departure-for-stop */ - @JvmOverloads fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): CompletableFuture = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, params: ArrivalAndDepartureRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + params: ArrivalAndDepartureRetrieveParams + ): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** arrivals-and-departures-for-stop */ - @JvmOverloads + fun list(stopId: String): CompletableFuture = + list(stopId, ArrivalAndDepartureListParams.none()) + + /** @see [list] */ + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [list] */ + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + ): CompletableFuture = + list(stopId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: ArrivalAndDepartureListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: ArrivalAndDepartureListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(stopId, ArrivalAndDepartureListParams.none(), requestOptions) + + /** + * A view of [ArrivalAndDepartureServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get + * /api/where/arrival-and-departure-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ArrivalAndDepartureRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get + * /api/where/arrivals-and-departures-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureServiceAsync.list]. + */ + @MustBeClosed + fun list( + stopId: String + ): CompletableFuture> = + list(stopId, ArrivalAndDepartureListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + ): CompletableFuture> = + list(stopId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: ArrivalAndDepartureListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: ArrivalAndDepartureListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(stopId, ArrivalAndDepartureListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt index f78eb4a..bc5c1ea 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt @@ -3,91 +3,128 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureListResponse -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListResponse +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveResponse class ArrivalAndDepartureServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ArrivalAndDepartureServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepartureServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ArrivalAndDepartureServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ArrivalAndDepartureServiceAsync.WithRawResponse = + withRawResponse - /** arrival-and-departure-for-stop */ override fun retrieve( params: ArrivalAndDepartureRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "arrival-and-departure-for-stop", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/arrival-and-departure-for-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** arrivals-and-departures-for-stop */ override fun list( params: ArrivalAndDepartureListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "arrivals-and-departures-for-stop", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/arrivals-and-departures-for-stop/{stopID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ArrivalAndDepartureServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "arrival-and-departure-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ArrivalAndDepartureListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "arrivals-and-departures-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/BlockServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt index 8d2afda..543b005 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.BlockRetrieveParams -import org.onebusaway.models.BlockRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.block.BlockRetrieveParams +import org.onebusaway.models.block.BlockRetrieveResponse interface BlockServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific block by ID */ - @JvmOverloads + fun retrieve(blockId: String): CompletableFuture = + retrieve(blockId, BlockRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + ): CompletableFuture = retrieve(blockId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: BlockRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: BlockRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(blockId, BlockRetrieveParams.none(), requestOptions) + + /** A view of [BlockServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/block/{blockID}.json`, but is otherwise + * the same as [BlockServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(blockId: String): CompletableFuture> = + retrieve(blockId, BlockRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + ): CompletableFuture> = + retrieve(blockId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: BlockRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: BlockRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(blockId, BlockRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt index 0ecc49b..30df072 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt @@ -3,50 +3,75 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.BlockRetrieveParams -import org.onebusaway.models.BlockRetrieveResponse +import org.onebusaway.models.block.BlockRetrieveParams +import org.onebusaway.models.block.BlockRetrieveResponse -class BlockServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : BlockServiceAsync { +class BlockServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BlockServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: BlockServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): BlockServiceAsync.WithRawResponse = withRawResponse - /** Get details of a specific block by ID */ override fun retrieve( params: BlockRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "block", "${params.getPathParam(0)}.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/block/{blockID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BlockServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: BlockRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "block", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt index 79530a4..13c3253 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt @@ -1,20 +1,72 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ConfigRetrieveParams -import org.onebusaway.models.ConfigRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.config.ConfigRetrieveParams +import org.onebusaway.models.config.ConfigRetrieveResponse interface ConfigServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** config */ - @JvmOverloads + fun retrieve(): CompletableFuture = + retrieve(ConfigRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: ConfigRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none() + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(requestOptions: RequestOptions): CompletableFuture = + retrieve(ConfigRetrieveParams.none(), requestOptions) + + /** + * A view of [ConfigServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/config.json`, but is otherwise the same + * as [ConfigServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(): CompletableFuture> = + retrieve(ConfigRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none() + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture> = + retrieve(ConfigRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt index f3b57a2..c575a72 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,42 +12,61 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ConfigRetrieveParams -import org.onebusaway.models.ConfigRetrieveResponse +import org.onebusaway.models.config.ConfigRetrieveParams +import org.onebusaway.models.config.ConfigRetrieveResponse -class ConfigServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ConfigServiceAsync { +class ConfigServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ConfigServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ConfigServiceAsync.WithRawResponse = withRawResponse - /** config */ override fun retrieve( params: ConfigRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "config.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/config.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ConfigRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "config.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt index c26d89d..6702fa8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt @@ -1,20 +1,73 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse interface CurrentTimeServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** current-time */ - @JvmOverloads + fun retrieve(): CompletableFuture = + retrieve(CurrentTimeRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: CurrentTimeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none() + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(requestOptions: RequestOptions): CompletableFuture = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) + + /** + * A view of [CurrentTimeServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/current-time.json`, but is otherwise the + * same as [CurrentTimeServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(): CompletableFuture> = + retrieve(CurrentTimeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none() + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture> = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt index 399e61e..c6e7e08 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,43 +12,61 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse -class CurrentTimeServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : CurrentTimeServiceAsync { +class CurrentTimeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CurrentTimeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): CurrentTimeServiceAsync.WithRawResponse = withRawResponse - /** current-time */ override fun retrieve( params: CurrentTimeRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "current-time.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/current-time.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: CurrentTimeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "current-time.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt index 718bef1..9c5fadc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt @@ -1,20 +1,108 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ReportProblemWithStopRetrieveParams +import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams interface ReportProblemWithStopServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Submit a user-generated problem report for a stop */ - @JvmOverloads + fun retrieve(stopId: String): CompletableFuture = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + ): CompletableFuture = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ReportProblemWithStopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: ReportProblemWithStopRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none(), requestOptions) + + /** + * A view of [ReportProblemWithStopServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-stop/{stopID}.json`, + * but is otherwise the same as [ReportProblemWithStopServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): CompletableFuture> = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = + ReportProblemWithStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithStopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithStopRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt index 63945b6..ff5765e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt @@ -3,55 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ReportProblemWithStopRetrieveParams import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams class ReportProblemWithStopServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ReportProblemWithStopServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithStopServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ReportProblemWithStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ReportProblemWithStopServiceAsync.WithRawResponse = + withRawResponse - /** Submit a user-generated problem report for a stop */ override fun retrieve( params: ReportProblemWithStopRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "report-problem-with-stop", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/report-problem-with-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ReportProblemWithStopServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ReportProblemWithStopRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "report-problem-with-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt index 851e7d1..4ed86c7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt @@ -1,20 +1,108 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ReportProblemWithTripRetrieveParams +import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams interface ReportProblemWithTripServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Submit a user-generated problem report for a particular trip. */ - @JvmOverloads + fun retrieve(tripId: String): CompletableFuture = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + ): CompletableFuture = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ReportProblemWithTripRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: ReportProblemWithTripRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none(), requestOptions) + + /** + * A view of [ReportProblemWithTripServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-trip/{tripID}.json`, + * but is otherwise the same as [ReportProblemWithTripServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): CompletableFuture> = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = + ReportProblemWithTripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + ): CompletableFuture> = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithTripRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithTripRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt index f97f9ec..c3f940e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt @@ -3,55 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ReportProblemWithTripRetrieveParams import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams class ReportProblemWithTripServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ReportProblemWithTripServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithTripServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ReportProblemWithTripServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ReportProblemWithTripServiceAsync.WithRawResponse = + withRawResponse - /** Submit a user-generated problem report for a particular trip. */ override fun retrieve( params: ReportProblemWithTripRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "report-problem-with-trip", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/report-problem-with-trip/{tripID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ReportProblemWithTripServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ReportProblemWithTripRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "report-problem-with-trip", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt index e42ee2c..af5ad86 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RouteIdsForAgencyListParams -import org.onebusaway.models.RouteIdsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListResponse interface RouteIdsForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get route IDs for a specific agency */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, RouteIdsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + ): CompletableFuture = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RouteIdsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: RouteIdsForAgencyListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, RouteIdsForAgencyListParams.none(), requestOptions) + + /** + * A view of [RouteIdsForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/route-ids-for-agency/{agencyID}.json`, + * but is otherwise the same as [RouteIdsForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list( + agencyId: String + ): CompletableFuture> = + list(agencyId, RouteIdsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RouteIdsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: RouteIdsForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, RouteIdsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt index fe189de..7040fa2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.RouteIdsForAgencyListParams -import org.onebusaway.models.RouteIdsForAgencyListResponse +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListResponse class RouteIdsForAgencyServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RouteIdsForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : RouteIdsForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RouteIdsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RouteIdsForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Get route IDs for a specific agency */ override fun list( params: RouteIdsForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "route-ids-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/route-ids-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RouteIdsForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RouteIdsForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "route-ids-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/RouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt index d13343c..96edd41 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RouteRetrieveParams -import org.onebusaway.models.RouteRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.route.RouteRetrieveParams +import org.onebusaway.models.route.RouteRetrieveResponse interface RouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve information for a specific route identified by its unique ID. */ - @JvmOverloads + fun retrieve(routeId: String): CompletableFuture = + retrieve(routeId, RouteRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + ): CompletableFuture = retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: RouteRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: RouteRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(routeId, RouteRetrieveParams.none(), requestOptions) + + /** A view of [RouteServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/route/{routeID}.json`, but is otherwise + * the same as [RouteServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(routeId: String): CompletableFuture> = + retrieve(routeId, RouteRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + ): CompletableFuture> = + retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: RouteRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: RouteRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(routeId, RouteRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt index 0cb2551..fa3f4c6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt @@ -3,50 +3,75 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.RouteRetrieveParams -import org.onebusaway.models.RouteRetrieveResponse +import org.onebusaway.models.route.RouteRetrieveParams +import org.onebusaway.models.route.RouteRetrieveResponse -class RouteServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RouteServiceAsync { +class RouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): RouteServiceAsync.WithRawResponse = withRawResponse - /** Retrieve information for a specific route identified by its unique ID. */ override fun retrieve( params: RouteRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "route", "${params.getPathParam(0)}.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/route/{routeID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: RouteRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "route", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt index 91ad8aa..579e603 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt @@ -1,20 +1,110 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RoutesForAgencyListParams -import org.onebusaway.models.RoutesForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse interface RoutesForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve the list of all routes for a particular agency by id */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, RoutesForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + ): CompletableFuture = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RoutesForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: RoutesForAgencyListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, RoutesForAgencyListParams.none(), requestOptions) + + /** + * A view of [RoutesForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-agency/{agencyID}.json`, but + * is otherwise the same as [RoutesForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list( + agencyId: String + ): CompletableFuture> = + list(agencyId, RoutesForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, RoutesForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt index 73593ee..8401bec 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.RoutesForAgencyListParams -import org.onebusaway.models.RoutesForAgencyListResponse +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse class RoutesForAgencyServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RoutesForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : RoutesForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoutesForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RoutesForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Retrieve the list of all routes for a particular agency by id */ override fun list( params: RoutesForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "routes-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/routes-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoutesForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "routes-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/RoutesForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt index daad3e3..3be0354 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt @@ -1,20 +1,53 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RoutesForLocationListParams -import org.onebusaway.models.RoutesForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse interface RoutesForLocationServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** routes-for-location */ - @JvmOverloads + fun list( + params: RoutesForLocationListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RoutesForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [RoutesForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-location.json`, but is + * otherwise the same as [RoutesForLocationServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: RoutesForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt index 092cc9e..4208b4d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,43 +12,61 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.RoutesForLocationListParams -import org.onebusaway.models.RoutesForLocationListResponse +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse class RoutesForLocationServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RoutesForLocationServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : RoutesForLocationServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoutesForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RoutesForLocationServiceAsync.WithRawResponse = withRawResponse - /** routes-for-location */ override fun list( params: RoutesForLocationListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "routes-for-location.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/routes-for-location.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForLocationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "routes-for-location.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/ScheduleForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt index 2bd92f9..adf72f3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ScheduleForRouteRetrieveParams -import org.onebusaway.models.ScheduleForRouteRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse interface ScheduleForRouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve the full schedule for a route on a particular day */ - @JvmOverloads + fun retrieve(routeId: String): CompletableFuture = + retrieve(routeId, ScheduleForRouteRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + ): CompletableFuture = + retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ScheduleForRouteRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: ScheduleForRouteRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(routeId, ScheduleForRouteRetrieveParams.none(), requestOptions) + + /** + * A view of [ScheduleForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-route/{routeID}.json`, but + * is otherwise the same as [ScheduleForRouteServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + routeId: String + ): CompletableFuture> = + retrieve(routeId, ScheduleForRouteRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + ): CompletableFuture> = + retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForRouteRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForRouteRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(routeId, ScheduleForRouteRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt index 16c23fa..e2d9e81 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ScheduleForRouteRetrieveParams -import org.onebusaway.models.ScheduleForRouteRetrieveResponse +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse class ScheduleForRouteServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ScheduleForRouteServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ScheduleForRouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ScheduleForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ScheduleForRouteServiceAsync.WithRawResponse = withRawResponse - /** Retrieve the full schedule for a route on a particular day */ override fun retrieve( params: ScheduleForRouteRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "schedule-for-route", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/schedule-for-route/{routeID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForRouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ScheduleForRouteRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "schedule-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt index d553c5c..886f4a1 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ScheduleForStopRetrieveParams -import org.onebusaway.models.ScheduleForStopRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveResponse interface ScheduleForStopServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get schedule for a specific stop */ - @JvmOverloads + fun retrieve(stopId: String): CompletableFuture = + retrieve(stopId, ScheduleForStopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + ): CompletableFuture = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ScheduleForStopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: ScheduleForStopRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(stopId, ScheduleForStopRetrieveParams.none(), requestOptions) + + /** + * A view of [ScheduleForStopServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-stop/{stopID}.json`, but is + * otherwise the same as [ScheduleForStopServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + stopId: String + ): CompletableFuture> = + retrieve(stopId, ScheduleForStopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForStopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForStopRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(stopId, ScheduleForStopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt index 3461606..96f3b3d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ScheduleForStopRetrieveParams -import org.onebusaway.models.ScheduleForStopRetrieveResponse +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveResponse class ScheduleForStopServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ScheduleForStopServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : ScheduleForStopServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ScheduleForStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ScheduleForStopServiceAsync.WithRawResponse = withRawResponse - /** Get schedule for a specific stop */ override fun retrieve( params: ScheduleForStopRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "schedule-for-stop", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/schedule-for-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForStopServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ScheduleForStopRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "schedule-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt index d63a5d4..ea62172 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.SearchForRouteListParams -import org.onebusaway.models.SearchForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.searchforroute.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListResponse interface SearchForRouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for a route based on its name. */ - @JvmOverloads + fun list(params: SearchForRouteListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: SearchForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [SearchForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/search/route.json`, but is otherwise the + * same as [SearchForRouteServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: SearchForRouteListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt index b2cbde6..574b9ee 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,43 +12,61 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.SearchForRouteListParams -import org.onebusaway.models.SearchForRouteListResponse +import org.onebusaway.models.searchforroute.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListResponse class SearchForRouteServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : SearchForRouteServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : SearchForRouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SearchForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SearchForRouteServiceAsync.WithRawResponse = withRawResponse - /** Search for a route based on its name. */ override fun list( params: SearchForRouteListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "search", "route.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/search/route.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForRouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "search", "route.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/SearchForStopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt index 31d27f4..525689c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.SearchForStopListParams -import org.onebusaway.models.SearchForStopListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.searchforstop.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListResponse interface SearchForStopServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for a stop based on its name. */ - @JvmOverloads + fun list(params: SearchForStopListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: SearchForStopListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [SearchForStopServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/search/stop.json`, but is otherwise the + * same as [SearchForStopServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: SearchForStopListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt index ffc950d..51078e2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,43 +12,61 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.SearchForStopListParams -import org.onebusaway.models.SearchForStopListResponse +import org.onebusaway.models.searchforstop.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListResponse -class SearchForStopServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : SearchForStopServiceAsync { +class SearchForStopServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SearchForStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SearchForStopServiceAsync.WithRawResponse = withRawResponse - /** Search for a stop based on its name. */ override fun list( params: SearchForStopListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "search", "stop.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/search/stop.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "search", "stop.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/ShapeServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt index ba76e9a..4614a08 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ShapeRetrieveParams -import org.onebusaway.models.ShapeRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.shape.ShapeRetrieveParams +import org.onebusaway.models.shape.ShapeRetrieveResponse interface ShapeServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ - @JvmOverloads + fun retrieve(shapeId: String): CompletableFuture = + retrieve(shapeId, ShapeRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + ): CompletableFuture = retrieve(shapeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ShapeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: ShapeRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(shapeId, ShapeRetrieveParams.none(), requestOptions) + + /** A view of [ShapeServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/shape/{shapeID}.json`, but is otherwise + * the same as [ShapeServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(shapeId: String): CompletableFuture> = + retrieve(shapeId, ShapeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + ): CompletableFuture> = + retrieve(shapeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ShapeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ShapeRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(shapeId, ShapeRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt index cc692d4..17d585e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt @@ -3,50 +3,75 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ShapeRetrieveParams -import org.onebusaway.models.ShapeRetrieveResponse +import org.onebusaway.models.shape.ShapeRetrieveParams +import org.onebusaway.models.shape.ShapeRetrieveResponse -class ShapeServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ShapeServiceAsync { +class ShapeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ShapeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ShapeServiceAsync.WithRawResponse = withRawResponse - /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ override fun retrieve( params: ShapeRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "shape", "${params.getPathParam(0)}.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/shape/{shapeID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ShapeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shapeId", params.shapeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "shape", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt index 5302c4f..6a2c5f9 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt @@ -1,20 +1,110 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopIdsForAgencyListParams -import org.onebusaway.models.StopIdsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse interface StopIdsForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stop IDs for a specific agency */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, StopIdsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + ): CompletableFuture = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopIdsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: StopIdsForAgencyListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, StopIdsForAgencyListParams.none(), requestOptions) + + /** + * A view of [StopIdsForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stop-ids-for-agency/{agencyID}.json`, but + * is otherwise the same as [StopIdsForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list( + agencyId: String + ): CompletableFuture> = + list(agencyId, StopIdsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopIdsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopIdsForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, StopIdsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt index 2269905..bbe0917 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopIdsForAgencyListParams -import org.onebusaway.models.StopIdsForAgencyListResponse +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse class StopIdsForAgencyServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopIdsForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : StopIdsForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopIdsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopIdsForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Get stop IDs for a specific agency */ override fun list( params: StopIdsForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stop-ids-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stop-ids-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopIdsForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopIdsForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stop-ids-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/StopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt index 477416b..597b17d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopRetrieveParams -import org.onebusaway.models.StopRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stop.StopRetrieveParams +import org.onebusaway.models.stop.StopRetrieveResponse interface StopServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific stop */ - @JvmOverloads + fun retrieve(stopId: String): CompletableFuture = + retrieve(stopId, StopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + ): CompletableFuture = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: StopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: StopRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(stopId, StopRetrieveParams.none(), requestOptions) + + /** A view of [StopServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stop/{stopID}.json`, but is otherwise the + * same as [StopServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): CompletableFuture> = + retrieve(stopId, StopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: StopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: StopRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(stopId, StopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt index 783e18b..81d7c5a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt @@ -3,50 +3,75 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopRetrieveParams -import org.onebusaway.models.StopRetrieveResponse +import org.onebusaway.models.stop.StopRetrieveParams +import org.onebusaway.models.stop.StopRetrieveResponse -class StopServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopServiceAsync { +class StopServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + StopServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): StopServiceAsync.WithRawResponse = withRawResponse - /** Get details of a specific stop */ override fun retrieve( params: StopRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "stop", "${params.getPathParam(0)}.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: StopRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "stop", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt index a8aa840..af0198f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt @@ -1,20 +1,107 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForAgencyListParams -import org.onebusaway.models.StopsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforagency.StopsForAgencyListParams +import org.onebusaway.models.stopsforagency.StopsForAgencyListResponse interface StopsForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stops for a specific agency */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, StopsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + ): CompletableFuture = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: StopsForAgencyListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, StopsForAgencyListParams.none(), requestOptions) + + /** + * A view of [StopsForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-agency/{agencyID}.json`, but is + * otherwise the same as [StopsForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list(agencyId: String): CompletableFuture> = + list(agencyId, StopsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, StopsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt index 1cb4bcf..08a34be 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForAgencyListParams -import org.onebusaway.models.StopsForAgencyListResponse +import org.onebusaway.models.stopsforagency.StopsForAgencyListParams +import org.onebusaway.models.stopsforagency.StopsForAgencyListResponse class StopsForAgencyServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopsForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : StopsForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Get stops for a specific agency */ override fun list( params: StopsForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stops-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stops-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stops-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/StopsForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt index 18f1776..764ff9a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForLocationListParams -import org.onebusaway.models.StopsForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse interface StopsForLocationServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** stops-for-location */ - @JvmOverloads + fun list(params: StopsForLocationListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [StopsForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-location.json`, but is + * otherwise the same as [StopsForLocationServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: StopsForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt index cd2d5ac..586b618 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,43 +12,61 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForLocationListParams -import org.onebusaway.models.StopsForLocationListResponse +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse class StopsForLocationServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopsForLocationServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : StopsForLocationServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForLocationServiceAsync.WithRawResponse = withRawResponse - /** stops-for-location */ override fun list( params: StopsForLocationListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "stops-for-location.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stops-for-location.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForLocationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "stops-for-location.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/StopsForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt index 21a4d17..59f7969 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt @@ -1,20 +1,107 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForRouteListParams -import org.onebusaway.models.StopsForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforroute.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse interface StopsForRouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stops for a specific route */ - @JvmOverloads + fun list(routeId: String): CompletableFuture = + list(routeId, StopsForRouteListParams.none()) + + /** @see [list] */ + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + ): CompletableFuture = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: StopsForRouteListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(routeId, StopsForRouteListParams.none(), requestOptions) + + /** + * A view of [StopsForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-route/{routeID}.json`, but is + * otherwise the same as [StopsForRouteServiceAsync.list]. + */ + @MustBeClosed + fun list(routeId: String): CompletableFuture> = + list(routeId, StopsForRouteListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + ): CompletableFuture> = + list(routeId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForRouteListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(routeId, StopsForRouteListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt index c218860..4739e7d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForRouteListParams -import org.onebusaway.models.StopsForRouteListResponse +import org.onebusaway.models.stopsforroute.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse -class StopsForRouteServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopsForRouteServiceAsync { +class StopsForRouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForRouteServiceAsync.WithRawResponse = withRawResponse - /** Get stops for a specific route */ override fun list( params: StopsForRouteListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stops-for-route", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/stops-for-route/{routeID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForRouteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stops-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/TripDetailServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt index 9ba625f..5de78ae 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt @@ -1,20 +1,110 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripDetailRetrieveParams -import org.onebusaway.models.TripDetailRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse interface TripDetailServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve Trip Details */ - @JvmOverloads + fun retrieve(tripId: String): CompletableFuture = + retrieve(tripId, TripDetailRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + ): CompletableFuture = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripDetailRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: TripDetailRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(tripId, TripDetailRetrieveParams.none(), requestOptions) + + /** + * A view of [TripDetailServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip-details/{tripID}.json`, but is + * otherwise the same as [TripDetailServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + tripId: String + ): CompletableFuture> = + retrieve(tripId, TripDetailRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + ): CompletableFuture> = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripDetailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripDetailRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(tripId, TripDetailRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt index 8f03c39..95045d3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt @@ -3,51 +3,75 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripDetailRetrieveParams -import org.onebusaway.models.TripDetailRetrieveResponse +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse -class TripDetailServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripDetailServiceAsync { +class TripDetailServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripDetailServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripDetailServiceAsync.WithRawResponse = withRawResponse - /** Retrieve Trip Details */ override fun retrieve( params: TripDetailRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trip-details", "${params.getPathParam(0)}.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trip-details/{tripID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripDetailRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trip-details", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt index c5cccd9..3446b32 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripForVehicleRetrieveParams -import org.onebusaway.models.TripForVehicleRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse interface TripForVehicleServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve trip for a specific vehicle */ - @JvmOverloads + fun retrieve(vehicleId: String): CompletableFuture = + retrieve(vehicleId, TripForVehicleRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + ): CompletableFuture = + retrieve(vehicleId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripForVehicleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve( + params: TripForVehicleRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(vehicleId, TripForVehicleRetrieveParams.none(), requestOptions) + + /** + * A view of [TripForVehicleServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip-for-vehicle/{vehicleID}.json`, but + * is otherwise the same as [TripForVehicleServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + vehicleId: String + ): CompletableFuture> = + retrieve(vehicleId, TripForVehicleRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + ): CompletableFuture> = + retrieve(vehicleId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripForVehicleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripForVehicleRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(vehicleId, TripForVehicleRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt index a2a4297..4307268 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripForVehicleRetrieveParams -import org.onebusaway.models.TripForVehicleRetrieveResponse +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse class TripForVehicleServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripForVehicleServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : TripForVehicleServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripForVehicleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripForVehicleServiceAsync.WithRawResponse = withRawResponse - /** Retrieve trip for a specific vehicle */ override fun retrieve( params: TripForVehicleRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "trip-for-vehicle", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trip-for-vehicle/{vehicleID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripForVehicleServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripForVehicleRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("vehicleId", params.vehicleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "trip-for-vehicle", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt index f6695da..e137c1a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt @@ -1,20 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripRetrieveParams -import org.onebusaway.models.TripRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.trip.TripRetrieveParams +import org.onebusaway.models.trip.TripRetrieveResponse interface TripServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific trip */ - @JvmOverloads + fun retrieve(tripId: String): CompletableFuture = + retrieve(tripId, TripRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + ): CompletableFuture = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: TripRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(tripId, TripRetrieveParams.none(), requestOptions) + + /** A view of [TripServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip/{tripID}.json`, but is otherwise the + * same as [TripServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): CompletableFuture> = + retrieve(tripId, TripRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + ): CompletableFuture> = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(tripId, TripRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt index 3313c58..428e431 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt @@ -3,50 +3,75 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripRetrieveParams -import org.onebusaway.models.TripRetrieveResponse +import org.onebusaway.models.trip.TripRetrieveParams +import org.onebusaway.models.trip.TripRetrieveResponse -class TripServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripServiceAsync { +class TripServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): TripServiceAsync.WithRawResponse = withRawResponse - /** Get details of a specific trip */ override fun retrieve( params: TripRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trip", "${params.getPathParam(0)}.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trip/{tripID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trip", "${params._pathParam(0)}.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt index 5d82f61..0290143 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripsForLocationListParams -import org.onebusaway.models.TripsForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListResponse interface TripsForLocationServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve trips for a given location */ - @JvmOverloads + fun list(params: TripsForLocationListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: TripsForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [TripsForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-location.json`, but is + * otherwise the same as [TripsForLocationServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: TripsForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt index cdc234d..472f2c2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -11,43 +12,61 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripsForLocationListParams -import org.onebusaway.models.TripsForLocationListResponse +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListResponse class TripsForLocationServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripsForLocationServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : TripsForLocationServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripsForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripsForLocationServiceAsync.WithRawResponse = withRawResponse - /** Retrieve trips for a given location */ override fun list( params: TripsForLocationListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trips-for-location.json") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trips-for-location.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForLocationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trips-for-location.json") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/TripsForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt index 5f8f848..b9b2161 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt @@ -1,20 +1,107 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripsForRouteListParams -import org.onebusaway.models.TripsForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripsforroute.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse interface TripsForRouteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for active trips for a specific route. */ - @JvmOverloads + fun list(routeId: String): CompletableFuture = + list(routeId, TripsForRouteListParams.none()) + + /** @see [list] */ + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + ): CompletableFuture = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: TripsForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list(params: TripsForRouteListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(routeId, TripsForRouteListParams.none(), requestOptions) + + /** + * A view of [TripsForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-route/{routeID}.json`, but is + * otherwise the same as [TripsForRouteServiceAsync.list]. + */ + @MustBeClosed + fun list(routeId: String): CompletableFuture> = + list(routeId, TripsForRouteListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + ): CompletableFuture> = + list(routeId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForRouteListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(routeId, TripsForRouteListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt index a68955e..11c93c2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripsForRouteListParams -import org.onebusaway.models.TripsForRouteListResponse +import org.onebusaway.models.tripsforroute.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse -class TripsForRouteServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripsForRouteServiceAsync { +class TripsForRouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripsForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripsForRouteServiceAsync.WithRawResponse = withRawResponse - /** Search for active trips for a specific route. */ override fun list( params: TripsForRouteListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "trips-for-route", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/trips-for-route/{routeID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TripsForRouteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "trips-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/async/VehiclesForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt index f24836a..78aed5c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt @@ -1,20 +1,111 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.async +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture import org.onebusaway.core.RequestOptions -import org.onebusaway.models.VehiclesForAgencyListParams -import org.onebusaway.models.VehiclesForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse interface VehiclesForAgencyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get vehicles for a specific agency */ - @JvmOverloads + fun list(agencyId: String): CompletableFuture = + list(agencyId, VehiclesForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + ): CompletableFuture = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: VehiclesForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: VehiclesForAgencyListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(agencyId, VehiclesForAgencyListParams.none(), requestOptions) + + /** + * A view of [VehiclesForAgencyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/vehicles-for-agency/{agencyID}.json`, but + * is otherwise the same as [VehiclesForAgencyServiceAsync.list]. + */ + @MustBeClosed + fun list( + agencyId: String + ): CompletableFuture> = + list(agencyId, VehiclesForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + ): CompletableFuture> = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: VehiclesForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: VehiclesForAgencyListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(agencyId, VehiclesForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt index ed8e4a9..aa2e990 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt @@ -3,56 +3,80 @@ package org.onebusaway.services.async import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.VehiclesForAgencyListParams -import org.onebusaway.models.VehiclesForAgencyListResponse +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse class VehiclesForAgencyServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : VehiclesForAgencyServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : VehiclesForAgencyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: VehiclesForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): VehiclesForAgencyServiceAsync.WithRawResponse = withRawResponse - /** Get vehicles for a specific agency */ override fun list( params: VehiclesForAgencyListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "vehicles-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/vehicles-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VehiclesForAgencyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: VehiclesForAgencyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "vehicles-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + 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/AgenciesWithCoverageService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt index 8e54c10..1f18b1c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt @@ -1,22 +1,73 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.AgenciesWithCoverageListParams -import org.onebusaway.models.AgenciesWithCoverageListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse interface AgenciesWithCoverageService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Returns a list of all transit agencies currently supported by OneBusAway along with the * center of their coverage area. */ - @JvmOverloads + fun list(): AgenciesWithCoverageListResponse = list(AgenciesWithCoverageListParams.none()) + + /** @see [list] */ fun list( - params: AgenciesWithCoverageListParams, - requestOptions: RequestOptions = RequestOptions.none() + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): AgenciesWithCoverageListResponse + + /** @see [list] */ + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none() + ): AgenciesWithCoverageListResponse = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(requestOptions: RequestOptions): AgenciesWithCoverageListResponse = + list(AgenciesWithCoverageListParams.none(), requestOptions) + + /** + * A view of [AgenciesWithCoverageService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/agencies-with-coverage.json`, but is + * otherwise the same as [AgenciesWithCoverageService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = + list(AgenciesWithCoverageListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: AgenciesWithCoverageListParams = AgenciesWithCoverageListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): HttpResponseFor = + list(AgenciesWithCoverageListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt index f1781f8..a109b92 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,43 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.AgenciesWithCoverageListParams -import org.onebusaway.models.AgenciesWithCoverageListResponse +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse class AgenciesWithCoverageServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : AgenciesWithCoverageService { +internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCoverageService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AgenciesWithCoverageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): AgenciesWithCoverageService.WithRawResponse = withRawResponse - /** - * Returns a list of all transit agencies currently supported by OneBusAway along with the - * center of their coverage area. - */ override fun list( params: AgenciesWithCoverageListParams, - requestOptions: RequestOptions - ): AgenciesWithCoverageListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "agencies-with-coverage.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): AgenciesWithCoverageListResponse = + // get /api/where/agencies-with-coverage.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AgenciesWithCoverageService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AgenciesWithCoverageListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "agencies-with-coverage.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/AgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt index 33676cb..2d98f44 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt @@ -1,19 +1,98 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.AgencyRetrieveParams -import org.onebusaway.models.AgencyRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.agency.AgencyRetrieveParams +import org.onebusaway.models.agency.AgencyRetrieveResponse interface AgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve information for a specific transit agency identified by its unique ID. */ - @JvmOverloads + fun retrieve(agencyId: String): AgencyRetrieveResponse = + retrieve(agencyId, AgencyRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AgencyRetrieveResponse = + retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + ): AgencyRetrieveResponse = retrieve(agencyId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: AgencyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AgencyRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: AgencyRetrieveParams): AgencyRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(agencyId: String, requestOptions: RequestOptions): AgencyRetrieveResponse = + retrieve(agencyId, AgencyRetrieveParams.none(), requestOptions) + + /** A view of [AgencyService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/agency/{agencyID}.json`, but is otherwise + * the same as [AgencyService.retrieve]. + */ + @MustBeClosed + fun retrieve(agencyId: String): HttpResponseFor = + retrieve(agencyId, AgencyRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + params: AgencyRetrieveParams = AgencyRetrieveParams.none(), + ): HttpResponseFor = + retrieve(agencyId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: AgencyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: AgencyRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(agencyId, AgencyRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt index 1c98da6..e8e2b39 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt @@ -2,47 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.AgencyRetrieveParams -import org.onebusaway.models.AgencyRetrieveResponse +import org.onebusaway.models.agency.AgencyRetrieveParams +import org.onebusaway.models.agency.AgencyRetrieveResponse -class AgencyServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : AgencyService { +class AgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): AgencyService.WithRawResponse = withRawResponse - /** Retrieve information for a specific transit agency identified by its unique ID. */ override fun retrieve( params: AgencyRetrieveParams, - requestOptions: RequestOptions - ): AgencyRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "agency", "${params.getPathParam(0)}.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): AgencyRetrieveResponse = + // get /api/where/agency/{agencyID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: AgencyRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "agency", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt index deb29be..0638304 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt @@ -1,28 +1,164 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureListResponse -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListResponse +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveResponse interface ArrivalAndDepartureService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** arrival-and-departure-for-stop */ - @JvmOverloads + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): ArrivalAndDepartureRetrieveResponse = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ArrivalAndDepartureRetrieveResponse = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve(params: ArrivalAndDepartureRetrieveParams): ArrivalAndDepartureRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ArrivalAndDepartureRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ArrivalAndDepartureRetrieveResponse /** arrivals-and-departures-for-stop */ - @JvmOverloads + fun list(stopId: String): ArrivalAndDepartureListResponse = + list(stopId, ArrivalAndDepartureListParams.none()) + + /** @see [list] */ + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ArrivalAndDepartureListResponse = + list(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [list] */ + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + ): ArrivalAndDepartureListResponse = list(stopId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: ArrivalAndDepartureListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ArrivalAndDepartureListResponse + + /** @see [list] */ + fun list(params: ArrivalAndDepartureListParams): ArrivalAndDepartureListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(stopId: String, requestOptions: RequestOptions): ArrivalAndDepartureListResponse = + list(stopId, ArrivalAndDepartureListParams.none(), requestOptions) + + /** + * A view of [ArrivalAndDepartureService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get + * /api/where/arrival-and-departure-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureService.retrieve]. + */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): HttpResponseFor = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ArrivalAndDepartureRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get + * /api/where/arrivals-and-departures-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureService.list]. + */ + @MustBeClosed + fun list(stopId: String): HttpResponseFor = + list(stopId, ArrivalAndDepartureListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + params: ArrivalAndDepartureListParams = ArrivalAndDepartureListParams.none(), + ): HttpResponseFor = + list(stopId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: ArrivalAndDepartureListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: ArrivalAndDepartureListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + stopId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(stopId, ArrivalAndDepartureListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt index 20a92a7..cee01ad 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt @@ -2,85 +2,121 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureListResponse -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveResponse +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListResponse +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveResponse class ArrivalAndDepartureServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ArrivalAndDepartureService { +internal constructor(private val clientOptions: ClientOptions) : ArrivalAndDepartureService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ArrivalAndDepartureService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ArrivalAndDepartureService.WithRawResponse = withRawResponse - /** arrival-and-departure-for-stop */ override fun retrieve( params: ArrivalAndDepartureRetrieveParams, - requestOptions: RequestOptions - ): ArrivalAndDepartureRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "arrival-and-departure-for-stop", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + requestOptions: RequestOptions, + ): ArrivalAndDepartureRetrieveResponse = + // get /api/where/arrival-and-departure-for-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** arrivals-and-departures-for-stop */ override fun list( params: ArrivalAndDepartureListParams, - requestOptions: RequestOptions - ): ArrivalAndDepartureListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "arrivals-and-departures-for-stop", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): ArrivalAndDepartureListResponse = + // get /api/where/arrivals-and-departures-for-stop/{stopID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ArrivalAndDepartureService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "arrival-and-departure-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ArrivalAndDepartureListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "arrivals-and-departures-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/BlockService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt index 850f9e3..0508966 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt @@ -1,19 +1,96 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.BlockRetrieveParams -import org.onebusaway.models.BlockRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.block.BlockRetrieveParams +import org.onebusaway.models.block.BlockRetrieveResponse interface BlockService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific block by ID */ - @JvmOverloads + fun retrieve(blockId: String): BlockRetrieveResponse = + retrieve(blockId, BlockRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BlockRetrieveResponse = retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + ): BlockRetrieveResponse = retrieve(blockId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: BlockRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): BlockRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: BlockRetrieveParams): BlockRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(blockId: String, requestOptions: RequestOptions): BlockRetrieveResponse = + retrieve(blockId, BlockRetrieveParams.none(), requestOptions) + + /** A view of [BlockService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/block/{blockID}.json`, but is otherwise + * the same as [BlockService.retrieve]. + */ + @MustBeClosed + fun retrieve(blockId: String): HttpResponseFor = + retrieve(blockId, BlockRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + params: BlockRetrieveParams = BlockRetrieveParams.none(), + ): HttpResponseFor = retrieve(blockId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: BlockRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: BlockRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + blockId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(blockId, BlockRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt index 95c79c1..04ec198 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt @@ -2,47 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.BlockRetrieveParams -import org.onebusaway.models.BlockRetrieveResponse +import org.onebusaway.models.block.BlockRetrieveParams +import org.onebusaway.models.block.BlockRetrieveResponse -class BlockServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : BlockService { +class BlockServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BlockService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: BlockService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): BlockService.WithRawResponse = withRawResponse - /** Get details of a specific block by ID */ override fun retrieve( params: BlockRetrieveParams, - requestOptions: RequestOptions - ): BlockRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "block", "${params.getPathParam(0)}.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): BlockRetrieveResponse = + // get /api/where/block/{blockID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BlockService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: BlockRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "block", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt index b28fab8..fdce05f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt @@ -1,19 +1,65 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ConfigRetrieveParams -import org.onebusaway.models.ConfigRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.config.ConfigRetrieveParams +import org.onebusaway.models.config.ConfigRetrieveResponse interface ConfigService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** config */ - @JvmOverloads + fun retrieve(): ConfigRetrieveResponse = retrieve(ConfigRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: ConfigRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): ConfigRetrieveResponse + + /** @see [retrieve] */ + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none() + ): ConfigRetrieveResponse = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(requestOptions: RequestOptions): ConfigRetrieveResponse = + retrieve(ConfigRetrieveParams.none(), requestOptions) + + /** A view of [ConfigService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/config.json`, but is otherwise the same + * as [ConfigService.retrieve]. + */ + @MustBeClosed + fun retrieve(): HttpResponseFor = + retrieve(ConfigRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ConfigRetrieveParams = ConfigRetrieveParams.none() + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(requestOptions: RequestOptions): HttpResponseFor = + retrieve(ConfigRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt index 4f8b585..e4e752b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,39 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ConfigRetrieveParams -import org.onebusaway.models.ConfigRetrieveResponse +import org.onebusaway.models.config.ConfigRetrieveParams +import org.onebusaway.models.config.ConfigRetrieveResponse -class ConfigServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ConfigService { +class ConfigServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ConfigService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ConfigService.WithRawResponse = withRawResponse - /** config */ override fun retrieve( params: ConfigRetrieveParams, - requestOptions: RequestOptions - ): ConfigRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "config.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): ConfigRetrieveResponse = + // get /api/where/config.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ConfigRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "config.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt index 95d6a7c..2d912a3 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt @@ -1,19 +1,67 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse interface CurrentTimeService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** current-time */ - @JvmOverloads + fun retrieve(): CurrentTimeRetrieveResponse = retrieve(CurrentTimeRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: CurrentTimeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CurrentTimeRetrieveResponse + + /** @see [retrieve] */ + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none() + ): CurrentTimeRetrieveResponse = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(requestOptions: RequestOptions): CurrentTimeRetrieveResponse = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) + + /** + * A view of [CurrentTimeService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/current-time.json`, but is otherwise the + * same as [CurrentTimeService.retrieve]. + */ + @MustBeClosed + fun retrieve(): HttpResponseFor = + retrieve(CurrentTimeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.none() + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(requestOptions: RequestOptions): HttpResponseFor = + retrieve(CurrentTimeRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt index a468a87..ee69013 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,40 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse -class CurrentTimeServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : CurrentTimeService { +class CurrentTimeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CurrentTimeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): CurrentTimeService.WithRawResponse = withRawResponse - /** current-time */ override fun retrieve( params: CurrentTimeRetrieveParams, - requestOptions: RequestOptions - ): CurrentTimeRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "current-time.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): CurrentTimeRetrieveResponse = + // get /api/where/current-time.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: CurrentTimeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "current-time.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt index 1085081..2869322 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt @@ -1,19 +1,101 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ReportProblemWithStopRetrieveParams +import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams interface ReportProblemWithStopService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Submit a user-generated problem report for a stop */ - @JvmOverloads + fun retrieve(stopId: String): ResponseWrapper = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseWrapper = retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + ): ResponseWrapper = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ReportProblemWithStopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ResponseWrapper + + /** @see [retrieve] */ + fun retrieve(params: ReportProblemWithStopRetrieveParams): ResponseWrapper = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(stopId: String, requestOptions: RequestOptions): ResponseWrapper = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none(), requestOptions) + + /** + * A view of [ReportProblemWithStopService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-stop/{stopID}.json`, + * but is otherwise the same as [ReportProblemWithStopService.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): HttpResponseFor = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = + ReportProblemWithStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ReportProblemWithStopRetrieveParams = ReportProblemWithStopRetrieveParams.none(), + ): HttpResponseFor = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithStopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithStopRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(stopId, ReportProblemWithStopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt index 4899729..91a98bc 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt @@ -2,52 +2,76 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ReportProblemWithStopRetrieveParams import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams class ReportProblemWithStopServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ReportProblemWithStopService { +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithStopService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ReportProblemWithStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ReportProblemWithStopService.WithRawResponse = withRawResponse - /** Submit a user-generated problem report for a stop */ override fun retrieve( params: ReportProblemWithStopRetrieveParams, - requestOptions: RequestOptions - ): ResponseWrapper { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "report-problem-with-stop", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): ResponseWrapper = + // get /api/where/report-problem-with-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ReportProblemWithStopService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ReportProblemWithStopRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "report-problem-with-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt index d8e2a3d..db963a6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt @@ -1,19 +1,101 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ReportProblemWithTripRetrieveParams +import org.onebusaway.core.http.HttpResponseFor import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams interface ReportProblemWithTripService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Submit a user-generated problem report for a particular trip. */ - @JvmOverloads + fun retrieve(tripId: String): ResponseWrapper = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseWrapper = retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + ): ResponseWrapper = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ReportProblemWithTripRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ResponseWrapper + + /** @see [retrieve] */ + fun retrieve(params: ReportProblemWithTripRetrieveParams): ResponseWrapper = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(tripId: String, requestOptions: RequestOptions): ResponseWrapper = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none(), requestOptions) + + /** + * A view of [ReportProblemWithTripService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-trip/{tripID}.json`, + * but is otherwise the same as [ReportProblemWithTripService.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): HttpResponseFor = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = + ReportProblemWithTripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: ReportProblemWithTripRetrieveParams = ReportProblemWithTripRetrieveParams.none(), + ): HttpResponseFor = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithTripRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ReportProblemWithTripRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(tripId, ReportProblemWithTripRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt index 76b40c0..48e57de 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt @@ -2,52 +2,76 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ReportProblemWithTripRetrieveParams import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams class ReportProblemWithTripServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ReportProblemWithTripService { +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithTripService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ReportProblemWithTripService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ReportProblemWithTripService.WithRawResponse = withRawResponse - /** Submit a user-generated problem report for a particular trip. */ override fun retrieve( params: ReportProblemWithTripRetrieveParams, - requestOptions: RequestOptions - ): ResponseWrapper { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "report-problem-with-trip", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): ResponseWrapper = + // get /api/where/report-problem-with-trip/{tripID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ReportProblemWithTripService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ReportProblemWithTripRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "report-problem-with-trip", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt index 6cd5d26..5709b20 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt @@ -1,19 +1,102 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RouteIdsForAgencyListParams -import org.onebusaway.models.RouteIdsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListResponse interface RouteIdsForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get route IDs for a specific agency */ - @JvmOverloads + fun list(agencyId: String): RouteIdsForAgencyListResponse = + list(agencyId, RouteIdsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RouteIdsForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + ): RouteIdsForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RouteIdsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RouteIdsForAgencyListResponse + + /** @see [list] */ + fun list(params: RouteIdsForAgencyListParams): RouteIdsForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): RouteIdsForAgencyListResponse = + list(agencyId, RouteIdsForAgencyListParams.none(), requestOptions) + + /** + * A view of [RouteIdsForAgencyService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/route-ids-for-agency/{agencyID}.json`, + * but is otherwise the same as [RouteIdsForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, RouteIdsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RouteIdsForAgencyListParams = RouteIdsForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RouteIdsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: RouteIdsForAgencyListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, RouteIdsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt index afc9602..44ef629 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.RouteIdsForAgencyListParams -import org.onebusaway.models.RouteIdsForAgencyListResponse +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListResponse -class RouteIdsForAgencyServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RouteIdsForAgencyService { +class RouteIdsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RouteIdsForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RouteIdsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RouteIdsForAgencyService.WithRawResponse = withRawResponse - /** Get route IDs for a specific agency */ override fun list( params: RouteIdsForAgencyListParams, - requestOptions: RequestOptions - ): RouteIdsForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "route-ids-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): RouteIdsForAgencyListResponse = + // get /api/where/route-ids-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RouteIdsForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RouteIdsForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "route-ids-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/RouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt index 705ef38..1f304b0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt @@ -1,19 +1,96 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RouteRetrieveParams -import org.onebusaway.models.RouteRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.route.RouteRetrieveParams +import org.onebusaway.models.route.RouteRetrieveResponse interface RouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve information for a specific route identified by its unique ID. */ - @JvmOverloads + fun retrieve(routeId: String): RouteRetrieveResponse = + retrieve(routeId, RouteRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RouteRetrieveResponse = retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + ): RouteRetrieveResponse = retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: RouteRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RouteRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: RouteRetrieveParams): RouteRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(routeId: String, requestOptions: RequestOptions): RouteRetrieveResponse = + retrieve(routeId, RouteRetrieveParams.none(), requestOptions) + + /** A view of [RouteService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/route/{routeID}.json`, but is otherwise + * the same as [RouteService.retrieve]. + */ + @MustBeClosed + fun retrieve(routeId: String): HttpResponseFor = + retrieve(routeId, RouteRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: RouteRetrieveParams = RouteRetrieveParams.none(), + ): HttpResponseFor = retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: RouteRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: RouteRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(routeId, RouteRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt index 64d3eb2..bca72fb 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt @@ -2,47 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.RouteRetrieveParams -import org.onebusaway.models.RouteRetrieveResponse +import org.onebusaway.models.route.RouteRetrieveParams +import org.onebusaway.models.route.RouteRetrieveResponse -class RouteServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RouteService { +class RouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): RouteService.WithRawResponse = withRawResponse - /** Retrieve information for a specific route identified by its unique ID. */ override fun retrieve( params: RouteRetrieveParams, - requestOptions: RequestOptions - ): RouteRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "route", "${params.getPathParam(0)}.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): RouteRetrieveResponse = + // get /api/where/route/{routeID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: RouteRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "route", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt index 845d40d..9b00bdd 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt @@ -1,19 +1,101 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RoutesForAgencyListParams -import org.onebusaway.models.RoutesForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse interface RoutesForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve the list of all routes for a particular agency by id */ - @JvmOverloads + fun list(agencyId: String): RoutesForAgencyListResponse = + list(agencyId, RoutesForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RoutesForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + ): RoutesForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RoutesForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RoutesForAgencyListResponse + + /** @see [list] */ + fun list(params: RoutesForAgencyListParams): RoutesForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): RoutesForAgencyListResponse = + list(agencyId, RoutesForAgencyListParams.none(), requestOptions) + + /** + * A view of [RoutesForAgencyService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-agency/{agencyID}.json`, but + * is otherwise the same as [RoutesForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, RoutesForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: RoutesForAgencyListParams = RoutesForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: RoutesForAgencyListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, RoutesForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt index f1850cb..101ed80 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.RoutesForAgencyListParams -import org.onebusaway.models.RoutesForAgencyListResponse +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse -class RoutesForAgencyServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RoutesForAgencyService { +class RoutesForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoutesForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RoutesForAgencyService.WithRawResponse = withRawResponse - /** Retrieve the list of all routes for a particular agency by id */ override fun list( params: RoutesForAgencyListParams, - requestOptions: RequestOptions - ): RoutesForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "routes-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): RoutesForAgencyListResponse = + // get /api/where/routes-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoutesForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "routes-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/RoutesForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt index 9cecbf9..0096c2b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt @@ -1,19 +1,50 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.RoutesForLocationListParams -import org.onebusaway.models.RoutesForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse interface RoutesForLocationService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** routes-for-location */ - @JvmOverloads + fun list(params: RoutesForLocationListParams): RoutesForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: RoutesForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RoutesForLocationListResponse + + /** + * A view of [RoutesForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-location.json`, but is + * otherwise the same as [RoutesForLocationService.list]. + */ + @MustBeClosed + fun list( + params: RoutesForLocationListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt index c28bfc4..442e156 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,40 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.RoutesForLocationListParams -import org.onebusaway.models.RoutesForLocationListResponse +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse -class RoutesForLocationServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RoutesForLocationService { +class RoutesForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForLocationService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoutesForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): RoutesForLocationService.WithRawResponse = withRawResponse - /** routes-for-location */ override fun list( params: RoutesForLocationListParams, - requestOptions: RequestOptions - ): RoutesForLocationListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "routes-for-location.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): RoutesForLocationListResponse = + // get /api/where/routes-for-location.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForLocationService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "routes-for-location.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/ScheduleForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt index f9a4e1b..2979d2f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt @@ -1,19 +1,106 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ScheduleForRouteRetrieveParams -import org.onebusaway.models.ScheduleForRouteRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse interface ScheduleForRouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve the full schedule for a route on a particular day */ - @JvmOverloads + fun retrieve(routeId: String): ScheduleForRouteRetrieveResponse = + retrieve(routeId, ScheduleForRouteRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ScheduleForRouteRetrieveResponse = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + ): ScheduleForRouteRetrieveResponse = retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ScheduleForRouteRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ScheduleForRouteRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: ScheduleForRouteRetrieveParams): ScheduleForRouteRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): ScheduleForRouteRetrieveResponse = + retrieve(routeId, ScheduleForRouteRetrieveParams.none(), requestOptions) + + /** + * A view of [ScheduleForRouteService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-route/{routeID}.json`, but + * is otherwise the same as [ScheduleForRouteService.retrieve]. + */ + @MustBeClosed + fun retrieve(routeId: String): HttpResponseFor = + retrieve(routeId, ScheduleForRouteRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + params: ScheduleForRouteRetrieveParams = ScheduleForRouteRetrieveParams.none(), + ): HttpResponseFor = + retrieve(routeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForRouteRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForRouteRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + routeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(routeId, ScheduleForRouteRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt index ffbfe43..51fcebf 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ScheduleForRouteRetrieveParams -import org.onebusaway.models.ScheduleForRouteRetrieveResponse +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse -class ScheduleForRouteServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ScheduleForRouteService { +class ScheduleForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForRouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ScheduleForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ScheduleForRouteService.WithRawResponse = withRawResponse - /** Retrieve the full schedule for a route on a particular day */ override fun retrieve( params: ScheduleForRouteRetrieveParams, - requestOptions: RequestOptions - ): ScheduleForRouteRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "schedule-for-route", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): ScheduleForRouteRetrieveResponse = + // get /api/where/schedule-for-route/{routeID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForRouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ScheduleForRouteRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "schedule-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt index 6893084..605661b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt @@ -1,19 +1,103 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ScheduleForStopRetrieveParams -import org.onebusaway.models.ScheduleForStopRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveResponse interface ScheduleForStopService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get schedule for a specific stop */ - @JvmOverloads + fun retrieve(stopId: String): ScheduleForStopRetrieveResponse = + retrieve(stopId, ScheduleForStopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ScheduleForStopRetrieveResponse = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + ): ScheduleForStopRetrieveResponse = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ScheduleForStopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ScheduleForStopRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: ScheduleForStopRetrieveParams): ScheduleForStopRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(stopId: String, requestOptions: RequestOptions): ScheduleForStopRetrieveResponse = + retrieve(stopId, ScheduleForStopRetrieveParams.none(), requestOptions) + + /** + * A view of [ScheduleForStopService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-stop/{stopID}.json`, but is + * otherwise the same as [ScheduleForStopService.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): HttpResponseFor = + retrieve(stopId, ScheduleForStopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: ScheduleForStopRetrieveParams = ScheduleForStopRetrieveParams.none(), + ): HttpResponseFor = + retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForStopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ScheduleForStopRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(stopId, ScheduleForStopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt index 114f9b2..fbf848d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ScheduleForStopRetrieveParams -import org.onebusaway.models.ScheduleForStopRetrieveResponse +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveResponse -class ScheduleForStopServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ScheduleForStopService { +class ScheduleForStopServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForStopService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ScheduleForStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): ScheduleForStopService.WithRawResponse = withRawResponse - /** Get schedule for a specific stop */ override fun retrieve( params: ScheduleForStopRetrieveParams, - requestOptions: RequestOptions - ): ScheduleForStopRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "schedule-for-stop", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): ScheduleForStopRetrieveResponse = + // get /api/where/schedule-for-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForStopService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ScheduleForStopRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "schedule-for-stop", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt index 4e0c391..04b354e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt @@ -1,19 +1,48 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.SearchForRouteListParams -import org.onebusaway.models.SearchForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.searchforroute.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListResponse interface SearchForRouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for a route based on its name. */ - @JvmOverloads + fun list(params: SearchForRouteListParams): SearchForRouteListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: SearchForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SearchForRouteListResponse + + /** + * A view of [SearchForRouteService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/search/route.json`, but is otherwise the + * same as [SearchForRouteService.list]. + */ + @MustBeClosed + fun list(params: SearchForRouteListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt index 3be0bc5..ff5e599 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,40 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.SearchForRouteListParams -import org.onebusaway.models.SearchForRouteListResponse +import org.onebusaway.models.searchforroute.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListResponse -class SearchForRouteServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : SearchForRouteService { +class SearchForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForRouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SearchForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SearchForRouteService.WithRawResponse = withRawResponse - /** Search for a route based on its name. */ override fun list( params: SearchForRouteListParams, - requestOptions: RequestOptions - ): SearchForRouteListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "search", "route.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): SearchForRouteListResponse = + // get /api/where/search/route.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForRouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "search", "route.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/SearchForStopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt index 7b8508b..f11dbd7 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt @@ -1,19 +1,48 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.SearchForStopListParams -import org.onebusaway.models.SearchForStopListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.searchforstop.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListResponse interface SearchForStopService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for a stop based on its name. */ - @JvmOverloads + fun list(params: SearchForStopListParams): SearchForStopListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: SearchForStopListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SearchForStopListResponse + + /** + * A view of [SearchForStopService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/search/stop.json`, but is otherwise the + * same as [SearchForStopService.list]. + */ + @MustBeClosed + fun list(params: SearchForStopListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt index ec7bcd4..2c9e4b0 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,40 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.SearchForStopListParams -import org.onebusaway.models.SearchForStopListResponse +import org.onebusaway.models.searchforstop.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListResponse -class SearchForStopServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : SearchForStopService { +class SearchForStopServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SearchForStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SearchForStopService.WithRawResponse = withRawResponse - /** Search for a stop based on its name. */ override fun list( params: SearchForStopListParams, - requestOptions: RequestOptions - ): SearchForStopListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "search", "stop.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): SearchForStopListResponse = + // get /api/where/search/stop.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "search", "stop.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/ShapeService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt index 653548d..d82d700 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt @@ -1,19 +1,96 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.ShapeRetrieveParams -import org.onebusaway.models.ShapeRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.shape.ShapeRetrieveParams +import org.onebusaway.models.shape.ShapeRetrieveResponse interface ShapeService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ - @JvmOverloads + fun retrieve(shapeId: String): ShapeRetrieveResponse = + retrieve(shapeId, ShapeRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ShapeRetrieveResponse = retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + ): ShapeRetrieveResponse = retrieve(shapeId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ShapeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ShapeRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: ShapeRetrieveParams): ShapeRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(shapeId: String, requestOptions: RequestOptions): ShapeRetrieveResponse = + retrieve(shapeId, ShapeRetrieveParams.none(), requestOptions) + + /** A view of [ShapeService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/shape/{shapeID}.json`, but is otherwise + * the same as [ShapeService.retrieve]. + */ + @MustBeClosed + fun retrieve(shapeId: String): HttpResponseFor = + retrieve(shapeId, ShapeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().shapeId(shapeId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + params: ShapeRetrieveParams = ShapeRetrieveParams.none(), + ): HttpResponseFor = retrieve(shapeId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: ShapeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: ShapeRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + shapeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(shapeId, ShapeRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt index 1ddb284..1d1d961 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt @@ -2,47 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.ShapeRetrieveParams -import org.onebusaway.models.ShapeRetrieveResponse +import org.onebusaway.models.shape.ShapeRetrieveParams +import org.onebusaway.models.shape.ShapeRetrieveResponse -class ShapeServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ShapeService { +class ShapeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ShapeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ShapeService.WithRawResponse = withRawResponse - /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ override fun retrieve( params: ShapeRetrieveParams, - requestOptions: RequestOptions - ): ShapeRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "shape", "${params.getPathParam(0)}.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): ShapeRetrieveResponse = + // get /api/where/shape/{shapeID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: ShapeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shapeId", params.shapeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "shape", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt index d4d5592..aadb2ac 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt @@ -1,19 +1,102 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopIdsForAgencyListParams -import org.onebusaway.models.StopIdsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse interface StopIdsForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stop IDs for a specific agency */ - @JvmOverloads + fun list(agencyId: String): StopIdsForAgencyListResponse = + list(agencyId, StopIdsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): StopIdsForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + ): StopIdsForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopIdsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopIdsForAgencyListResponse + + /** @see [list] */ + fun list(params: StopIdsForAgencyListParams): StopIdsForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): StopIdsForAgencyListResponse = + list(agencyId, StopIdsForAgencyListParams.none(), requestOptions) + + /** + * A view of [StopIdsForAgencyService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stop-ids-for-agency/{agencyID}.json`, but + * is otherwise the same as [StopIdsForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, StopIdsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopIdsForAgencyListParams = StopIdsForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopIdsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopIdsForAgencyListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, StopIdsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt index fe012fc..13d621b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopIdsForAgencyListParams -import org.onebusaway.models.StopIdsForAgencyListResponse +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse -class StopIdsForAgencyServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopIdsForAgencyService { +class StopIdsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopIdsForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopIdsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopIdsForAgencyService.WithRawResponse = withRawResponse - /** Get stop IDs for a specific agency */ override fun list( params: StopIdsForAgencyListParams, - requestOptions: RequestOptions - ): StopIdsForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stop-ids-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): StopIdsForAgencyListResponse = + // get /api/where/stop-ids-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopIdsForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopIdsForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stop-ids-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/StopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt index dd88877..ff15b60 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt @@ -1,19 +1,95 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopRetrieveParams -import org.onebusaway.models.StopRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stop.StopRetrieveParams +import org.onebusaway.models.stop.StopRetrieveResponse interface StopService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific stop */ - @JvmOverloads + fun retrieve(stopId: String): StopRetrieveResponse = retrieve(stopId, StopRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): StopRetrieveResponse = retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + ): StopRetrieveResponse = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: StopRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: StopRetrieveParams): StopRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(stopId: String, requestOptions: RequestOptions): StopRetrieveResponse = + retrieve(stopId, StopRetrieveParams.none(), requestOptions) + + /** A view of [StopService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stop/{stopID}.json`, but is otherwise the + * same as [StopService.retrieve]. + */ + @MustBeClosed + fun retrieve(stopId: String): HttpResponseFor = + retrieve(stopId, StopRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().stopId(stopId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + params: StopRetrieveParams = StopRetrieveParams.none(), + ): HttpResponseFor = retrieve(stopId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: StopRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: StopRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + stopId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(stopId, StopRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt index 7a5d88a..78b0a9a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt @@ -2,47 +2,71 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopRetrieveParams -import org.onebusaway.models.StopRetrieveResponse +import org.onebusaway.models.stop.StopRetrieveParams +import org.onebusaway.models.stop.StopRetrieveResponse -class StopServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopService { +class StopServiceImpl internal constructor(private val clientOptions: ClientOptions) : StopService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): StopService.WithRawResponse = withRawResponse - /** Get details of a specific stop */ override fun retrieve( params: StopRetrieveParams, - requestOptions: RequestOptions - ): StopRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "stop", "${params.getPathParam(0)}.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): StopRetrieveResponse = + // get /api/where/stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: StopRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("stopId", params.stopId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "stop", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt index 48ccc54..6bd2fde 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt @@ -1,19 +1,100 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForAgencyListParams -import org.onebusaway.models.StopsForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforagency.StopsForAgencyListParams +import org.onebusaway.models.stopsforagency.StopsForAgencyListResponse interface StopsForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stops for a specific agency */ - @JvmOverloads + fun list(agencyId: String): StopsForAgencyListResponse = + list(agencyId, StopsForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): StopsForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + ): StopsForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopsForAgencyListResponse + + /** @see [list] */ + fun list(params: StopsForAgencyListParams): StopsForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): StopsForAgencyListResponse = + list(agencyId, StopsForAgencyListParams.none(), requestOptions) + + /** + * A view of [StopsForAgencyService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-agency/{agencyID}.json`, but is + * otherwise the same as [StopsForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, StopsForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: StopsForAgencyListParams = StopsForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: StopsForAgencyListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, StopsForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt index 5fdab39..ce8ac3b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForAgencyListParams -import org.onebusaway.models.StopsForAgencyListResponse +import org.onebusaway.models.stopsforagency.StopsForAgencyListParams +import org.onebusaway.models.stopsforagency.StopsForAgencyListResponse -class StopsForAgencyServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopsForAgencyService { +class StopsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForAgencyService.WithRawResponse = withRawResponse - /** Get stops for a specific agency */ override fun list( params: StopsForAgencyListParams, - requestOptions: RequestOptions - ): StopsForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stops-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): StopsForAgencyListResponse = + // get /api/where/stops-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stops-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/StopsForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt index 5645cfb..fc4606c 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt @@ -1,19 +1,50 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForLocationListParams -import org.onebusaway.models.StopsForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse interface StopsForLocationService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** stops-for-location */ - @JvmOverloads + fun list(params: StopsForLocationListParams): StopsForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopsForLocationListResponse + + /** + * A view of [StopsForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-location.json`, but is + * otherwise the same as [StopsForLocationService.list]. + */ + @MustBeClosed + fun list( + params: StopsForLocationListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt index 69c3566..37a9da8 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,40 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForLocationListParams -import org.onebusaway.models.StopsForLocationListResponse +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse -class StopsForLocationServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopsForLocationService { +class StopsForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForLocationService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForLocationService.WithRawResponse = withRawResponse - /** stops-for-location */ override fun list( params: StopsForLocationListParams, - requestOptions: RequestOptions - ): StopsForLocationListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "stops-for-location.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): StopsForLocationListResponse = + // get /api/where/stops-for-location.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForLocationService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "stops-for-location.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/StopsForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt index 72c87c4..5c91312 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt @@ -1,19 +1,98 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.StopsForRouteListParams -import org.onebusaway.models.StopsForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.stopsforroute.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse interface StopsForRouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get stops for a specific route */ - @JvmOverloads + fun list(routeId: String): StopsForRouteListResponse = + list(routeId, StopsForRouteListParams.none()) + + /** @see [list] */ + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): StopsForRouteListResponse = list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + ): StopsForRouteListResponse = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: StopsForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): StopsForRouteListResponse + + /** @see [list] */ + fun list(params: StopsForRouteListParams): StopsForRouteListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(routeId: String, requestOptions: RequestOptions): StopsForRouteListResponse = + list(routeId, StopsForRouteListParams.none(), requestOptions) + + /** + * A view of [StopsForRouteService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-route/{routeID}.json`, but is + * otherwise the same as [StopsForRouteService.list]. + */ + @MustBeClosed + fun list(routeId: String): HttpResponseFor = + list(routeId, StopsForRouteListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: StopsForRouteListParams = StopsForRouteListParams.none(), + ): HttpResponseFor = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: StopsForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: StopsForRouteListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(routeId, StopsForRouteListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt index 0468d86..59690be 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.StopsForRouteListParams -import org.onebusaway.models.StopsForRouteListResponse +import org.onebusaway.models.stopsforroute.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse -class StopsForRouteServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : StopsForRouteService { +class StopsForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: StopsForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): StopsForRouteService.WithRawResponse = withRawResponse - /** Get stops for a specific route */ override fun list( params: StopsForRouteListParams, - requestOptions: RequestOptions - ): StopsForRouteListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "stops-for-route", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): StopsForRouteListResponse = + // get /api/where/stops-for-route/{routeID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: StopsForRouteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "stops-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/TripDetailService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt index 5040d0f..942f586 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt @@ -1,19 +1,99 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripDetailRetrieveParams -import org.onebusaway.models.TripDetailRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse interface TripDetailService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve Trip Details */ - @JvmOverloads + fun retrieve(tripId: String): TripDetailRetrieveResponse = + retrieve(tripId, TripDetailRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TripDetailRetrieveResponse = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + ): TripDetailRetrieveResponse = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripDetailRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripDetailRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: TripDetailRetrieveParams): TripDetailRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(tripId: String, requestOptions: RequestOptions): TripDetailRetrieveResponse = + retrieve(tripId, TripDetailRetrieveParams.none(), requestOptions) + + /** A view of [TripDetailService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip-details/{tripID}.json`, but is + * otherwise the same as [TripDetailService.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): HttpResponseFor = + retrieve(tripId, TripDetailRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripDetailRetrieveParams = TripDetailRetrieveParams.none(), + ): HttpResponseFor = + retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripDetailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripDetailRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(tripId, TripDetailRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt index 0db93f0..4c96e8d 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt @@ -2,48 +2,72 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripDetailRetrieveParams -import org.onebusaway.models.TripDetailRetrieveResponse +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse -class TripDetailServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripDetailService { +class TripDetailServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripDetailService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripDetailService.WithRawResponse = withRawResponse - /** Retrieve Trip Details */ override fun retrieve( params: TripDetailRetrieveParams, - requestOptions: RequestOptions - ): TripDetailRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trip-details", "${params.getPathParam(0)}.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): TripDetailRetrieveResponse = + // get /api/where/trip-details/{tripID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripDetailRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trip-details", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt index ed0659a..e0c77c2 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt @@ -1,19 +1,104 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripForVehicleRetrieveParams -import org.onebusaway.models.TripForVehicleRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse interface TripForVehicleService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve trip for a specific vehicle */ - @JvmOverloads + fun retrieve(vehicleId: String): TripForVehicleRetrieveResponse = + retrieve(vehicleId, TripForVehicleRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TripForVehicleRetrieveResponse = + retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + ): TripForVehicleRetrieveResponse = retrieve(vehicleId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripForVehicleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripForVehicleRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: TripForVehicleRetrieveParams): TripForVehicleRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + vehicleId: String, + requestOptions: RequestOptions, + ): TripForVehicleRetrieveResponse = + retrieve(vehicleId, TripForVehicleRetrieveParams.none(), requestOptions) + + /** + * A view of [TripForVehicleService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip-for-vehicle/{vehicleID}.json`, but + * is otherwise the same as [TripForVehicleService.retrieve]. + */ + @MustBeClosed + fun retrieve(vehicleId: String): HttpResponseFor = + retrieve(vehicleId, TripForVehicleRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().vehicleId(vehicleId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + params: TripForVehicleRetrieveParams = TripForVehicleRetrieveParams.none(), + ): HttpResponseFor = + retrieve(vehicleId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripForVehicleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripForVehicleRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + vehicleId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(vehicleId, TripForVehicleRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt index 3718f47..bbb0d41 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripForVehicleRetrieveParams -import org.onebusaway.models.TripForVehicleRetrieveResponse +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse -class TripForVehicleServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripForVehicleService { +class TripForVehicleServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripForVehicleService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripForVehicleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripForVehicleService.WithRawResponse = withRawResponse - /** Retrieve trip for a specific vehicle */ override fun retrieve( params: TripForVehicleRetrieveParams, - requestOptions: RequestOptions - ): TripForVehicleRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "trip-for-vehicle", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): TripForVehicleRetrieveResponse = + // get /api/where/trip-for-vehicle/{vehicleID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripForVehicleService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripForVehicleRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("vehicleId", params.vehicleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "trip-for-vehicle", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt index ad7c940..170dec6 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt @@ -1,19 +1,95 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripRetrieveParams -import org.onebusaway.models.TripRetrieveResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.trip.TripRetrieveParams +import org.onebusaway.models.trip.TripRetrieveResponse interface TripService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get details of a specific trip */ - @JvmOverloads + fun retrieve(tripId: String): TripRetrieveResponse = retrieve(tripId, TripRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TripRetrieveResponse = retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + ): TripRetrieveResponse = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: TripRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripRetrieveResponse + + /** @see [retrieve] */ + fun retrieve(params: TripRetrieveParams): TripRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(tripId: String, requestOptions: RequestOptions): TripRetrieveResponse = + retrieve(tripId, TripRetrieveParams.none(), requestOptions) + + /** A view of [TripService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trip/{tripID}.json`, but is otherwise the + * same as [TripService.retrieve]. + */ + @MustBeClosed + fun retrieve(tripId: String): HttpResponseFor = + retrieve(tripId, TripRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().tripId(tripId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + params: TripRetrieveParams = TripRetrieveParams.none(), + ): HttpResponseFor = retrieve(tripId, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: TripRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: TripRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + tripId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(tripId, TripRetrieveParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt index 57d1a7a..6cd67ed 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt @@ -2,47 +2,71 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripRetrieveParams -import org.onebusaway.models.TripRetrieveResponse +import org.onebusaway.models.trip.TripRetrieveParams +import org.onebusaway.models.trip.TripRetrieveResponse -class TripServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripService { +class TripServiceImpl internal constructor(private val clientOptions: ClientOptions) : TripService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): TripService.WithRawResponse = withRawResponse - /** Get details of a specific trip */ override fun retrieve( params: TripRetrieveParams, - requestOptions: RequestOptions - ): TripRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trip", "${params.getPathParam(0)}.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): TripRetrieveResponse = + // get /api/where/trip/{tripID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: TripRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tripId", params.tripId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trip", "${params._pathParam(0)}.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt index ba9a53d..f313dba 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt @@ -1,19 +1,50 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripsForLocationListParams -import org.onebusaway.models.TripsForLocationListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListResponse interface TripsForLocationService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve trips for a given location */ - @JvmOverloads + fun list(params: TripsForLocationListParams): TripsForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: TripsForLocationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripsForLocationListResponse + + /** + * A view of [TripsForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-location.json`, but is + * otherwise the same as [TripsForLocationService.list]. + */ + @MustBeClosed + fun list( + params: TripsForLocationListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt index 536a1d1..6a5576b 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt @@ -3,6 +3,7 @@ package org.onebusaway.services.blocking import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler @@ -10,40 +11,58 @@ import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripsForLocationListParams -import org.onebusaway.models.TripsForLocationListResponse +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListResponse -class TripsForLocationServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripsForLocationService { +class TripsForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForLocationService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripsForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripsForLocationService.WithRawResponse = withRawResponse - /** Retrieve trips for a given location */ override fun list( params: TripsForLocationListParams, - requestOptions: RequestOptions - ): TripsForLocationListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("api", "where", "trips-for-location.json") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): TripsForLocationListResponse = + // get /api/where/trips-for-location.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForLocationService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("api", "where", "trips-for-location.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/TripsForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt index 22f114a..449719e 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt @@ -1,19 +1,98 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.TripsForRouteListParams -import org.onebusaway.models.TripsForRouteListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.tripsforroute.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse interface TripsForRouteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Search for active trips for a specific route. */ - @JvmOverloads + fun list(routeId: String): TripsForRouteListResponse = + list(routeId, TripsForRouteListParams.none()) + + /** @see [list] */ + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TripsForRouteListResponse = list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + ): TripsForRouteListResponse = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: TripsForRouteListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): TripsForRouteListResponse + + /** @see [list] */ + fun list(params: TripsForRouteListParams): TripsForRouteListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(routeId: String, requestOptions: RequestOptions): TripsForRouteListResponse = + list(routeId, TripsForRouteListParams.none(), requestOptions) + + /** + * A view of [TripsForRouteService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-route/{routeID}.json`, but is + * otherwise the same as [TripsForRouteService.list]. + */ + @MustBeClosed + fun list(routeId: String): HttpResponseFor = + list(routeId, TripsForRouteListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().routeId(routeId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + params: TripsForRouteListParams = TripsForRouteListParams.none(), + ): HttpResponseFor = list(routeId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TripsForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list(params: TripsForRouteListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + routeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(routeId, TripsForRouteListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt index 7e3fe19..f63ee3a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.TripsForRouteListParams -import org.onebusaway.models.TripsForRouteListResponse +import org.onebusaway.models.tripsforroute.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse -class TripsForRouteServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TripsForRouteService { +class TripsForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TripsForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TripsForRouteService.WithRawResponse = withRawResponse - /** Search for active trips for a specific route. */ override fun list( params: TripsForRouteListParams, - requestOptions: RequestOptions - ): TripsForRouteListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "trips-for-route", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): TripsForRouteListResponse = + // get /api/where/trips-for-route/{routeID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TripsForRouteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("routeId", params.routeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "trips-for-route", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/VehiclesForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt index 6fb09be..836379a 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt @@ -1,19 +1,102 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package org.onebusaway.services.blocking +import com.google.errorprone.annotations.MustBeClosed import org.onebusaway.core.RequestOptions -import org.onebusaway.models.VehiclesForAgencyListParams -import org.onebusaway.models.VehiclesForAgencyListResponse +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse interface VehiclesForAgencyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get vehicles for a specific agency */ - @JvmOverloads + fun list(agencyId: String): VehiclesForAgencyListResponse = + list(agencyId, VehiclesForAgencyListParams.none()) + + /** @see [list] */ + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VehiclesForAgencyListResponse = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + ): VehiclesForAgencyListResponse = list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ fun list( params: VehiclesForAgencyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): VehiclesForAgencyListResponse + + /** @see [list] */ + fun list(params: VehiclesForAgencyListParams): VehiclesForAgencyListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(agencyId: String, requestOptions: RequestOptions): VehiclesForAgencyListResponse = + list(agencyId, VehiclesForAgencyListParams.none(), requestOptions) + + /** + * A view of [VehiclesForAgencyService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /api/where/vehicles-for-agency/{agencyID}.json`, but + * is otherwise the same as [VehiclesForAgencyService.list]. + */ + @MustBeClosed + fun list(agencyId: String): HttpResponseFor = + list(agencyId, VehiclesForAgencyListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().agencyId(agencyId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + params: VehiclesForAgencyListParams = VehiclesForAgencyListParams.none(), + ): HttpResponseFor = + list(agencyId, params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: VehiclesForAgencyListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: VehiclesForAgencyListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + agencyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(agencyId, VehiclesForAgencyListParams.none(), requestOptions) + } } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt index 7030568..2a854ae 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt @@ -2,53 +2,77 @@ package org.onebusaway.services.blocking +import kotlin.jvm.optionals.getOrNull import org.onebusaway.core.ClientOptions +import org.onebusaway.core.JsonValue import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired import org.onebusaway.core.handlers.errorHandler import org.onebusaway.core.handlers.jsonHandler import org.onebusaway.core.handlers.withErrorHandler import org.onebusaway.core.http.HttpMethod import org.onebusaway.core.http.HttpRequest 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.errors.OnebusawaySdkError -import org.onebusaway.models.VehiclesForAgencyListParams -import org.onebusaway.models.VehiclesForAgencyListResponse +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse -class VehiclesForAgencyServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : VehiclesForAgencyService { +class VehiclesForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + VehiclesForAgencyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: VehiclesForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): VehiclesForAgencyService.WithRawResponse = withRawResponse - /** Get vehicles for a specific agency */ override fun list( params: VehiclesForAgencyListParams, - requestOptions: RequestOptions - ): VehiclesForAgencyListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "api", - "where", - "vehicles-for-agency", - "${params.getPathParam(0)}.json" - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + requestOptions: RequestOptions, + ): VehiclesForAgencyListResponse = + // get /api/where/vehicles-for-agency/{agencyID}.json + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VehiclesForAgencyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: VehiclesForAgencyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("agencyId", params.agencyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "api", + "where", + "vehicles-for-agency", + "${params._pathParam(0)}.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return 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/TestServerExtension.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/TestServerExtension.kt index 0902411..ce4f7d3 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/TestServerExtension.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/TestServerExtension.kt @@ -36,7 +36,7 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { $ prism mock path/to/your.openapi.yml """ .trimIndent(), - e + e, ) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ObjectMappersTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ObjectMappersTest.kt new file mode 100644 index 0000000..9033497 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ObjectMappersTest.kt @@ -0,0 +1,102 @@ +package org.onebusaway.core + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime +import kotlin.reflect.KClass +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import org.junitpioneer.jupiter.cartesian.CartesianTest + +internal class ObjectMappersTest { + + internal class ClassWithBooleanFieldPrefixedWithIs(private val isActive: JsonField) { + + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + } + + @Test + fun write_whenFieldPrefixedWithIs_keepsPrefix() { + val value = ClassWithBooleanFieldPrefixedWithIs(JsonField.of(true)) + + val json = jsonMapper().writeValueAsString(value) + + assertThat(json).isEqualTo("{\"is_active\":true}") + } + + internal class Class(@get:JsonProperty("field") @JsonProperty("field") val field: String) + + enum class ShapeTestCase(val value: Any, val kClass: KClass<*>) { + STRING("Hello World!", String::class), + BOOLEAN(true, Boolean::class), + FLOAT(3.14F, Float::class), + DOUBLE(3.14, Double::class), + INTEGER(42, Int::class), + LONG(42L, Long::class), + MAP(mapOf("property" to "value"), Map::class), + CLASS(Class("Hello World!"), Class::class), + LIST(listOf(1, 2, 3), List::class); + + companion object { + val VALID_CONVERSIONS = + listOf( + FLOAT to DOUBLE, + FLOAT to INTEGER, + FLOAT to LONG, + DOUBLE to FLOAT, + DOUBLE to INTEGER, + DOUBLE to LONG, + INTEGER to FLOAT, + INTEGER to DOUBLE, + INTEGER to LONG, + LONG to FLOAT, + LONG to DOUBLE, + LONG to INTEGER, + CLASS to MAP, + // These aren't actually valid, but coercion configs don't work for String until + // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 + // We currently test on v2.13.4. + BOOLEAN to STRING, + FLOAT to STRING, + DOUBLE to STRING, + INTEGER to STRING, + LONG to STRING, + ) + } + } + + @CartesianTest + fun read(@CartesianTest.Enum shape1: ShapeTestCase, @CartesianTest.Enum shape2: ShapeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(shape1.value) + + val e = catchThrowable { jsonMapper.readValue(json, shape2.kClass.java) } + + if (shape1 == shape2 || shape1 to shape2 in ShapeTestCase.VALID_CONVERSIONS) { + assertThat(e).isNull() + } else { + assertThat(e).isInstanceOf(MismatchedInputException::class.java) + } + } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue(json) } + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt index 01df843..8fc02c7 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt @@ -14,13 +14,13 @@ internal class PhantomReachableTest { // Pass an inline object for the object to observe so that it becomes immediately // unreachable. Any(), - closeable + closeable, ) assertThat(closed).isFalse() System.gc() - Thread.sleep(3000) + Thread.sleep(100) assertThat(closed).isTrue() } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/UtilsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/UtilsTest.kt new file mode 100644 index 0000000..35c3319 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/UtilsTest.kt @@ -0,0 +1,33 @@ +package org.onebusaway.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtilsTest { + @Test + fun contentDeepEquals() { + assertThat(42 contentEquals 42).isTrue() + assertThat(42 contentEquals "Hello World!").isFalse() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 3)).isTrue() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 4)).isFalse() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) + ) + .isTrue() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1), byteArrayOf(2, 3)) + ) + .isFalse() + } + + @Test + fun contentToString() { + assertThat((42).contentToString()).isEqualTo("42") + assertThat("Hello World!".contentToString()).isEqualTo("Hello World!") + assertThat(byteArrayOf(1, 2, 3).contentToString()).isEqualTo("[1, 2, 3]") + assertThat(arrayOf(byteArrayOf(1, 2), byteArrayOf(3)).contentToString()) + .isEqualTo("[[1, 2], [3]]") + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ValuesTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ValuesTest.kt new file mode 100644 index 0000000..e160c68 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ValuesTest.kt @@ -0,0 +1,144 @@ +package org.onebusaway.core + +import java.util.Optional +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ValuesTest { + companion object { + private val NON_JSON = Any() + } + + enum class TestCase( + val value: JsonField<*>, + val expectedIsMissing: Boolean = false, + val expectedIsNull: Boolean = false, + val expectedAsKnown: Optional<*> = Optional.empty(), + val expectedAsBoolean: Optional = Optional.empty(), + val expectedAsNumber: Optional = Optional.empty(), + val expectedAsString: Optional = Optional.empty(), + val expectedAsArray: Optional> = Optional.empty(), + val expectedAsObject: Optional> = Optional.empty(), + ) { + MISSING(JsonMissing.of(), expectedIsMissing = true), + NULL(JsonNull.of(), expectedIsNull = true), + KNOWN(KnownValue.of(NON_JSON), expectedAsKnown = Optional.of(NON_JSON)), + KNOWN_BOOLEAN( + KnownValue.of(true), + expectedAsKnown = Optional.of(true), + expectedAsBoolean = Optional.of(true), + ), + BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), + KNOWN_NUMBER( + KnownValue.of(42), + expectedAsKnown = Optional.of(42), + expectedAsNumber = Optional.of(42), + ), + NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), + KNOWN_STRING( + KnownValue.of("hello"), + expectedAsKnown = Optional.of("hello"), + expectedAsString = Optional.of("hello"), + ), + STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), + KNOWN_ARRAY_NOT_ALL_JSON( + KnownValue.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + ), + KNOWN_ARRAY( + KnownValue.of(listOf("a", "b", "c")), + expectedAsKnown = Optional.of(listOf("a", "b", "c")), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + ARRAY( + JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + KNOWN_OBJECT_NOT_ALL_STRING_KEYS( + KnownValue.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + ), + KNOWN_OBJECT_NOT_ALL_JSON( + KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + ), + KNOWN_OBJECT( + KnownValue.of(mapOf("a" to "b", "b" to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + OBJECT( + JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + } + + @ParameterizedTest + @EnumSource + fun isMissing(testCase: TestCase) { + val isMissing = testCase.value.isMissing() + + assertThat(isMissing).isEqualTo(testCase.expectedIsMissing) + } + + @ParameterizedTest + @EnumSource + fun isNull(testCase: TestCase) { + val isNull = testCase.value.isNull() + + assertThat(isNull).isEqualTo(testCase.expectedIsNull) + } + + @ParameterizedTest + @EnumSource + fun asKnown(testCase: TestCase) { + val known = testCase.value.asKnown() + + assertThat(known).isEqualTo(testCase.expectedAsKnown) + } + + @ParameterizedTest + @EnumSource + fun asBoolean(testCase: TestCase) { + val boolean = testCase.value.asBoolean() + + assertThat(boolean).isEqualTo(testCase.expectedAsBoolean) + } + + @ParameterizedTest + @EnumSource + fun asNumber(testCase: TestCase) { + val number = testCase.value.asNumber() + + assertThat(number).isEqualTo(testCase.expectedAsNumber) + } + + @ParameterizedTest + @EnumSource + fun asString(testCase: TestCase) { + val string = testCase.value.asString() + + assertThat(string).isEqualTo(testCase.expectedAsString) + } + + @ParameterizedTest + @EnumSource + fun asArray(testCase: TestCase) { + val array = testCase.value.asArray() + + assertThat(array).isEqualTo(testCase.expectedAsArray) + } + + @ParameterizedTest + @EnumSource + fun asObject(testCase: TestCase) { + val obj = testCase.value.asObject() + + assertThat(obj).isEqualTo(testCase.expectedAsObject) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/AsyncStreamResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/AsyncStreamResponseTest.kt new file mode 100644 index 0000000..805169f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/AsyncStreamResponseTest.kt @@ -0,0 +1,268 @@ +package org.onebusaway.core.http + +import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.stream.Stream +import kotlin.streams.asStream +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.* + +@ExtendWith(MockitoExtension::class) +internal class AsyncStreamResponseTest { + + companion object { + private val ERROR = RuntimeException("ERROR!") + } + + private val streamResponse = + spy> { + doReturn(Stream.of("chunk1", "chunk2", "chunk3")).whenever(it).stream() + } + private val erroringStreamResponse = + spy> { + doReturn( + sequence { + yield("chunk1") + yield("chunk2") + throw ERROR + } + .asStream() + ) + .whenever(it) + .stream() + } + private val executor = + spy { + doAnswer { invocation -> invocation.getArgument(0).run() } + .whenever(it) + .execute(any()) + } + private val handler = mock>() + + @Test + fun subscribe_whenAlreadySubscribed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.subscribe {} + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe more than once") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenClosed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.close() + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe after the response is closed") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletesAfterClose_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + asyncStreamResponse.close() + + future.complete(streamResponse) + + verify(handler, never()).onNext(any()) + verify(handler, never()).onComplete(any()) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureErrors_callsOnComplete() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.completeExceptionally(ERROR) + + verify(handler, never()).onNext(any()) + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletes_runsHandler() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(streamResponse) + + inOrder(handler, streamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onNext("chunk3") + verify(handler, times(1)).onComplete(Optional.empty()) + verify(streamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenStreamErrors_callsOnCompleteEarly() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(erroringStreamResponse) + + inOrder(handler, erroringStreamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(erroringStreamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureNotCompleted_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.completeExceptionally(ERROR) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedButStillStreaming_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamCompleted_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithoutThrowableThrows_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithThrowableThrows_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenClosed_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun close_whenNotClosed_closesStreamResponse() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + asyncStreamResponse.close() + future.complete(streamResponse) + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenAlreadyClosed_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + future.complete(streamResponse) + + asyncStreamResponse.close() + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenFutureErrors_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + assertDoesNotThrow { future.completeExceptionally(ERROR) } + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt index 94b91cf..3f4ec78 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt @@ -1,8 +1,6 @@ package org.onebusaway.core.http import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -11,28 +9,28 @@ internal class HeadersTest { enum class TestCase( val headers: Headers, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( Headers.builder().put("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( Headers.builder().put("name1", "value").put("name2", "value").build(), expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( Headers.builder().put("name", "value1").put("name", "value2").build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( Headers.builder() @@ -40,7 +38,7 @@ internal class HeadersTest { .put("name", listOf("value1", "value2")) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_CASE_INSENSITIVE( Headers.builder() @@ -49,25 +47,25 @@ internal class HeadersTest { .put("nAmE", "value3") .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), PUT_ALL_MAP( Headers.builder() .putAll( mapOf( "name1" to listOf("value1", "value2"), - "name2" to listOf("value1", "value2") + "name2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_ALL_CASE_INSENSITIVE( Headers.builder() @@ -75,32 +73,32 @@ internal class HeadersTest { mapOf( "name" to listOf("value1"), "NAME" to listOf("value2"), - "nAmE" to listOf("value3") + "nAmE" to listOf("value3"), ) ) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), REMOVE_ABSENT( Headers.builder().remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( Headers.builder().put("name", "value").remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_CASE_INSENSITIVE( Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( Headers.builder() @@ -109,7 +107,7 @@ internal class HeadersTest { .removeAll(setOf("name1", "name2", "name3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -118,22 +116,22 @@ internal class HeadersTest { .removeAll(setOf("NAME1", "nAmE3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( Headers.builder().put("name1", "value").put("name2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( Headers.builder().replace("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( Headers.builder().put("name", "value1").replace("name", "value2").build(), expectedMap = mapOf("name" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( Headers.builder() @@ -141,12 +139,12 @@ internal class HeadersTest { .replace("name", "value3") .build(), expectedMap = mapOf("name" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( Headers.builder().replace("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( Headers.builder() @@ -154,7 +152,7 @@ internal class HeadersTest { .replace("name", listOf("value2", "value3")) .build(), expectedMap = mapOf("name" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( Headers.builder() @@ -162,7 +160,7 @@ internal class HeadersTest { .replace("name", listOf("value3", "value4")) .build(), expectedMap = mapOf("name" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_CASE_INSENSITIVE( Headers.builder() @@ -170,7 +168,7 @@ internal class HeadersTest { .replace("NAME", listOf("value2", "value3")) .build(), expectedMap = mapOf("NAME" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( Headers.builder() @@ -183,9 +181,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( Headers.builder() @@ -198,9 +196,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -209,8 +207,8 @@ internal class HeadersTest { .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) .build(), expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), - expectedSize = 2 - ) + expectedSize = 2, + ), } @ParameterizedTest @@ -241,34 +239,4 @@ internal class HeadersTest { assertThat(size).isEqualTo(testCase.expectedSize) } - - @ParameterizedTest - @EnumSource - fun namesAreImmutable(testCase: TestCase) { - val headers = testCase.headers - val headerNamesCopy = headers.names().toSet() - - val throwable = catchThrowable { - (headers.names() as MutableSet).add("another name") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(headers.names()).isEqualTo(headerNamesCopy) - } - - @ParameterizedTest - @EnumSource - fun valuesAreImmutable(testCase: TestCase) { - val headers = testCase.headers - assumeThat(headers.size).isNotEqualTo(0) - val name = headers.names().first() - val headerValuesCopy = headers.values(name).toList() - - val throwable = catchThrowable { - (headers.values(name) as MutableList).add("another value") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(headers.values(name)).isEqualTo(headerValuesCopy) - } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt index 0c0b4c5..d145396 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt @@ -1,8 +1,6 @@ package org.onebusaway.core.http import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -11,28 +9,28 @@ internal class QueryParamsTest { enum class TestCase( val queryParams: QueryParams, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( QueryParams.builder().put("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( QueryParams.builder().put("key1", "value").put("key2", "value").build(), expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( QueryParams.builder().put("key", "value1").put("key", "value2").build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( QueryParams.builder() @@ -40,40 +38,40 @@ internal class QueryParamsTest { .put("key", listOf("value1", "value2")) .build(), expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_MAP( QueryParams.builder() .putAll( mapOf( "key1" to listOf("value1", "value2"), - "key2" to listOf("value1", "value2") + "key2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REMOVE_ABSENT( QueryParams.builder().remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( QueryParams.builder().put("key", "value").remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( QueryParams.builder() @@ -82,22 +80,22 @@ internal class QueryParamsTest { .removeAll(setOf("key1", "key2", "key3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( QueryParams.builder().replace("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( QueryParams.builder().put("key", "value1").replace("key", "value2").build(), expectedMap = mapOf("key" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( QueryParams.builder() @@ -105,12 +103,12 @@ internal class QueryParamsTest { .replace("key", "value3") .build(), expectedMap = mapOf("key" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( QueryParams.builder().replace("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( QueryParams.builder() @@ -118,7 +116,7 @@ internal class QueryParamsTest { .replace("key", listOf("value2", "value3")) .build(), expectedMap = mapOf("key" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( QueryParams.builder() @@ -126,7 +124,7 @@ internal class QueryParamsTest { .replace("key", listOf("value3", "value4")) .build(), expectedMap = mapOf("key" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( QueryParams.builder() @@ -139,9 +137,9 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( QueryParams.builder() @@ -156,10 +154,10 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 - ) + expectedSize = 3, + ), } @ParameterizedTest @@ -179,34 +177,4 @@ internal class QueryParamsTest { assertThat(size).isEqualTo(testCase.expectedSize) } - - @ParameterizedTest - @EnumSource - fun keysAreImmutable(testCase: TestCase) { - val queryParams = testCase.queryParams - val queryParamKeysCopy = queryParams.keys().toSet() - - val throwable = catchThrowable { - (queryParams.keys() as MutableSet).add("another key") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(queryParams.keys()).isEqualTo(queryParamKeysCopy) - } - - @ParameterizedTest - @EnumSource - fun valuesAreImmutable(testCase: TestCase) { - val queryParams = testCase.queryParams - assumeThat(queryParams.size).isNotEqualTo(0) - val key = queryParams.keys().first() - val queryParamValuesCopy = queryParams.values(key).toList() - - val throwable = catchThrowable { - (queryParams.values(key) as MutableList).add("another value") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(queryParams.values(key)).isEqualTo(queryParamValuesCopy) - } } 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 0cda7ea..49ef7ce 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 @@ -5,15 +5,18 @@ 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.Duration import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.parallel.ResourceLock import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource import org.onebusaway.client.okhttp.OkHttpClient import org.onebusaway.core.RequestOptions @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") internal class RetryingHttpClientTest { private var openResponseCount = 0 @@ -24,14 +27,15 @@ internal class RetryingHttpClientTest { val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() httpClient = object : HttpClient { + override fun execute( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture = okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } @@ -40,6 +44,7 @@ internal class RetryingHttpClientTest { private fun trackClose(response: HttpResponse): HttpResponse { openResponseCount++ return object : HttpResponse { + private var isClosed = false override fun statusCode(): Int = response.statusCode() @@ -66,12 +71,12 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() + val retryingClient = retryingHttpClientBuilder().build() val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) @@ -88,16 +93,12 @@ internal class RetryingHttpClientTest { .willReturn(ok()) ) val retryingClient = - RetryingHttpClient.builder() - .httpClient(httpClient) - .maxRetries(2) - .idempotencyHeader("X-Some-Header") - .build() + retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) @@ -134,30 +135,29 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("0")) + .withHeader("x-stainless-retry-count", equalTo("0")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("1")) + .withHeader("x-stainless-retry-count", equalTo("1")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("2")) + .withHeader("x-stainless-retry-count", equalTo("2")), ) assertNoResponseLeaks() } @@ -181,8 +181,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() val response = retryingClient.execute( @@ -191,14 +190,14 @@ internal class RetryingHttpClientTest { .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) verify( 2, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("42")) + .withHeader("x-stainless-retry-count", equalTo("42")), ) assertNoResponseLeaks() } @@ -220,13 +219,12 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) @@ -234,6 +232,20 @@ internal class RetryingHttpClientTest { assertNoResponseLeaks() } + private fun retryingHttpClientBuilder() = + RetryingHttpClient.builder() + .httpClient(httpClient) + // Use a no-op `Sleeper` to make the test fast. + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + } + ) + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = if (async) executeAsync(request).get() else execute(request) diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt deleted file mode 100644 index 22f9102..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/SerializerTest.kt +++ /dev/null @@ -1,106 +0,0 @@ -package org.onebusaway.core.http - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.core.* - -internal class SerializerTest { - @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) - @NoAutoDetect - class ClassWithBooleanFieldPrefixedWithIs - private constructor( - private val isActive: JsonField, - private val additionalProperties: Map, - ) { - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun isActive(): Boolean? = isActive.getNullable("is_active") - - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate() = apply { - if (!validated) { - isActive() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - isActive, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" - - companion object { - fun builder() = Builder() - } - - @NoAutoDetect - class Builder internal constructor() { - - private var isActive: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - @JsonProperty("is_active") - @ExcludeMissing - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs( - isActive, - additionalProperties.toImmutable(), - ) - } - } - - @Test - fun serializeBooleanPrefixedWithIs() { - val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() - assertThat(jsonMapper().writeValueAsString(value)).isEqualTo("{\"is_active\":true}") - } -} 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 7111a2c..f237544 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 @@ -2,13 +2,15 @@ package org.onebusaway.models +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 -class ReferencesTest { +internal class ReferencesTest { @Test - fun createReferences() { + fun create() { val references = References.builder() .addAgency( @@ -137,7 +139,7 @@ class ReferencesTest { .build() ) .build() - assertThat(references).isNotNull + assertThat(references.agencies()) .containsExactly( References.Agency.builder() @@ -267,4 +269,145 @@ class ReferencesTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val 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(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() + + val roundtrippedReferences = + jsonMapper.readValue( + jsonMapper.writeValueAsString(references), + jacksonTypeRef(), + ) + + assertThat(roundtrippedReferences).isEqualTo(references) + } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt index 92b875c..dbf3ef5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt @@ -2,19 +2,36 @@ package org.onebusaway.models +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 -class ResponseWrapperTest { +internal class ResponseWrapperTest { @Test - fun createResponseWrapper() { + fun create() { val responseWrapper = ResponseWrapper.builder().code(0L).currentTime(0L).text("text").version(0L).build() - assertThat(responseWrapper).isNotNull + assertThat(responseWrapper.code()).isEqualTo(0L) assertThat(responseWrapper.currentTime()).isEqualTo(0L) assertThat(responseWrapper.text()).isEqualTo("text") assertThat(responseWrapper.version()).isEqualTo(0L) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responseWrapper = + ResponseWrapper.builder().code(0L).currentTime(0L).text("text").version(0L).build() + + val roundtrippedResponseWrapper = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseWrapper), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseWrapper).isEqualTo(responseWrapper) + } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt deleted file mode 100644 index d5df439..0000000 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForLocationListParamsTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package org.onebusaway.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.onebusaway.core.http.QueryParams - -class TripsForLocationListParamsTest { - - @Test - fun create() { - TripsForLocationListParams.builder() - .lat(0.0) - .latSpan(0.0) - .lon(0.0) - .lonSpan(0.0) - .includeSchedule(true) - .includeTrip(true) - .time(0L) - .build() - } - - @Test - fun queryParams() { - val params = - TripsForLocationListParams.builder() - .lat(0.0) - .latSpan(0.0) - .lon(0.0) - .lonSpan(0.0) - .includeSchedule(true) - .includeTrip(true) - .time(0L) - .build() - val expected = QueryParams.builder() - expected.put("lat", "0.0") - expected.put("latSpan", "0.0") - expected.put("lon", "0.0") - expected.put("lonSpan", "0.0") - expected.put("includeSchedule", "true") - expected.put("includeTrip", "true") - expected.put("time", "0") - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = - TripsForLocationListParams.builder().lat(0.0).latSpan(0.0).lon(0.0).lonSpan(0.0).build() - val expected = QueryParams.builder() - expected.put("lat", "0.0") - expected.put("latSpan", "0.0") - expected.put("lon", "0.0") - expected.put("lonSpan", "0.0") - assertThat(params._queryParams()).isEqualTo(expected.build()) - } -} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt similarity index 64% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt index 7a32ee3..7879547 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgenciesWithCoverageListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.agencieswithcoverage import org.junit.jupiter.api.Test -class AgenciesWithCoverageListParamsTest { +internal class AgenciesWithCoverageListParamsTest { @Test fun create() { 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 new file mode 100644 index 0000000..db34d4f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponseTest.kt @@ -0,0 +1,520 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agencieswithcoverage + +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 AgenciesWithCoverageListResponseTest { + + @Test + fun create() { + val agenciesWithCoverageListResponse = + AgenciesWithCoverageListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + AgenciesWithCoverageListResponse.Data.builder() + .limitExceeded(true) + .addList( + AgenciesWithCoverageListResponse.Data.List.builder() + .agencyId("agencyId") + .lat(0.0) + .latSpan(0.0) + .lon(0.0) + .lonSpan(0.0) + .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(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() + ) + .build() + + assertThat(agenciesWithCoverageListResponse.code()).isEqualTo(0L) + assertThat(agenciesWithCoverageListResponse.currentTime()).isEqualTo(0L) + assertThat(agenciesWithCoverageListResponse.text()).isEqualTo("text") + assertThat(agenciesWithCoverageListResponse.version()).isEqualTo(0L) + assertThat(agenciesWithCoverageListResponse.data()) + .isEqualTo( + AgenciesWithCoverageListResponse.Data.builder() + .limitExceeded(true) + .addList( + AgenciesWithCoverageListResponse.Data.List.builder() + .agencyId("agencyId") + .lat(0.0) + .latSpan(0.0) + .lon(0.0) + .lonSpan(0.0) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val agenciesWithCoverageListResponse = + AgenciesWithCoverageListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + AgenciesWithCoverageListResponse.Data.builder() + .limitExceeded(true) + .addList( + AgenciesWithCoverageListResponse.Data.List.builder() + .agencyId("agencyId") + .lat(0.0) + .latSpan(0.0) + .lon(0.0) + .lonSpan(0.0) + .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(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() + ) + .build() + + val roundtrippedAgenciesWithCoverageListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(agenciesWithCoverageListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAgenciesWithCoverageListResponse) + .isEqualTo(agenciesWithCoverageListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveParamsTest.kt index 9b28a54..f3b777c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/AgencyRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.agency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AgencyRetrieveParamsTest { +internal class AgencyRetrieveParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class AgencyRetrieveParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = AgencyRetrieveParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + + assertThat(params._pathParam(0)).isEqualTo("agencyID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..16fb9ac --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponseTest.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agency + +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 AgencyRetrieveResponseTest { + + @Test + fun create() { + val agencyRetrieveResponse = + AgencyRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + AgencyRetrieveResponse.Data.builder() + .entry( + AgencyRetrieveResponse.Data.Entry.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .limitExceeded(true) + .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(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() + ) + .build() + + assertThat(agencyRetrieveResponse.code()).isEqualTo(0L) + assertThat(agencyRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(agencyRetrieveResponse.text()).isEqualTo("text") + assertThat(agencyRetrieveResponse.version()).isEqualTo(0L) + assertThat(agencyRetrieveResponse.data()) + .isEqualTo( + AgencyRetrieveResponse.Data.builder() + .entry( + AgencyRetrieveResponse.Data.Entry.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .limitExceeded(true) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val agencyRetrieveResponse = + AgencyRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + AgencyRetrieveResponse.Data.builder() + .entry( + AgencyRetrieveResponse.Data.Entry.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + .limitExceeded(true) + .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(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() + ) + .build() + + val roundtrippedAgencyRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(agencyRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAgencyRetrieveResponse).isEqualTo(agencyRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParamsTest.kt similarity index 60% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParamsTest.kt index 26808dd..9b5b4a1 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParamsTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.arrivalanddeparture import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class ArrivalAndDepartureListParamsTest { +internal class ArrivalAndDepartureListParamsTest { @Test fun create() { @@ -19,6 +19,15 @@ class ArrivalAndDepartureListParamsTest { .build() } + @Test + fun pathParams() { + val params = ArrivalAndDepartureListParams.builder().stopId("1_75403").build() + + assertThat(params._pathParam(0)).isEqualTo("1_75403") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -28,27 +37,25 @@ class ArrivalAndDepartureListParamsTest { .minutesBefore(0L) .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() - val expected = QueryParams.builder() - expected.put("minutesAfter", "0") - expected.put("minutesBefore", "0") - expected.put("time", "2019-12-27T18:11:19.117Z") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("minutesAfter", "0") + .put("minutesBefore", "0") + .put("time", "2019-12-27T18:11:19.117Z") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = ArrivalAndDepartureListParams.builder().stopId("1_75403").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = ArrivalAndDepartureListParams.builder().stopId("1_75403").build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("1_75403") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } 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 new file mode 100644 index 0000000..eaf1315 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponseTest.kt @@ -0,0 +1,772 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +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 ArrivalAndDepartureListResponseTest { + + @Test + fun create() { + val arrivalAndDepartureListResponse = + ArrivalAndDepartureListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ArrivalAndDepartureListResponse.Data.builder() + .entry( + ArrivalAndDepartureListResponse.Data.Entry.builder() + .addArrivalsAndDeparture( + ArrivalAndDepartureListResponse.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( + ArrivalAndDepartureListResponse.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( + ArrivalAndDepartureListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalAndDepartureListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .build() + ) + .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(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() + ) + .build() + + assertThat(arrivalAndDepartureListResponse.code()).isEqualTo(0L) + assertThat(arrivalAndDepartureListResponse.currentTime()).isEqualTo(0L) + assertThat(arrivalAndDepartureListResponse.text()).isEqualTo("text") + assertThat(arrivalAndDepartureListResponse.version()).isEqualTo(0L) + assertThat(arrivalAndDepartureListResponse.data()) + .isEqualTo( + ArrivalAndDepartureListResponse.Data.builder() + .entry( + ArrivalAndDepartureListResponse.Data.Entry.builder() + .addArrivalsAndDeparture( + ArrivalAndDepartureListResponse.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( + ArrivalAndDepartureListResponse.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( + ArrivalAndDepartureListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalAndDepartureListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .build() + ) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val arrivalAndDepartureListResponse = + ArrivalAndDepartureListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ArrivalAndDepartureListResponse.Data.builder() + .entry( + ArrivalAndDepartureListResponse.Data.Entry.builder() + .addArrivalsAndDeparture( + ArrivalAndDepartureListResponse.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( + ArrivalAndDepartureListResponse.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( + ArrivalAndDepartureListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalAndDepartureListResponse.Data.Entry + .ArrivalsAndDeparture + .TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .build() + ) + .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(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() + ) + .build() + + val roundtrippedArrivalAndDepartureListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(arrivalAndDepartureListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedArrivalAndDepartureListResponse) + .isEqualTo(arrivalAndDepartureListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParamsTest.kt similarity index 60% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParamsTest.kt index 37b7569..170c28b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ArrivalAndDepartureRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.arrivalanddeparture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class ArrivalAndDepartureRetrieveParamsTest { +internal class ArrivalAndDepartureRetrieveParamsTest { @Test fun create() { @@ -21,51 +21,59 @@ class ArrivalAndDepartureRetrieveParamsTest { } @Test - fun queryParams() { + fun pathParams() { val params = ArrivalAndDepartureRetrieveParams.builder() .stopId("1_75403") .serviceDate(0L) .tripId("tripId") - .stopSequence(0L) - .time(0L) - .vehicleId("vehicleId") .build() - val expected = QueryParams.builder() - expected.put("serviceDate", "0") - expected.put("tripId", "tripId") - expected.put("stopSequence", "0") - expected.put("time", "0") - expected.put("vehicleId", "vehicleId") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + assertThat(params._pathParam(0)).isEqualTo("1_75403") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") } @Test - fun queryParamsWithoutOptionalFields() { + fun queryParams() { val params = ArrivalAndDepartureRetrieveParams.builder() .stopId("1_75403") .serviceDate(0L) .tripId("tripId") + .stopSequence(0L) + .time(0L) + .vehicleId("vehicleId") .build() - val expected = QueryParams.builder() - expected.put("serviceDate", "0") - expected.put("tripId", "tripId") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("serviceDate", "0") + .put("tripId", "tripId") + .put("stopSequence", "0") + .put("time", "0") + .put("vehicleId", "vehicleId") + .build() + ) } @Test - fun getPathParam() { + fun queryParamsWithoutOptionalFields() { val params = ArrivalAndDepartureRetrieveParams.builder() .stopId("1_75403") .serviceDate(0L) .tripId("tripId") .build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("1_75403") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder().put("serviceDate", "0").put("tripId", "tripId").build() + ) } } 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 new file mode 100644 index 0000000..381b6e4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponseTest.kt @@ -0,0 +1,742 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +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 ArrivalAndDepartureRetrieveResponseTest { + + @Test + fun create() { + val arrivalAndDepartureRetrieveResponse = + ArrivalAndDepartureRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ArrivalAndDepartureRetrieveResponse.Data.builder() + .entry( + ArrivalAndDepartureRetrieveResponse.Data.Entry.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( + ArrivalAndDepartureRetrieveResponse.Data.Entry.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( + ArrivalAndDepartureRetrieveResponse.Data.Entry + .TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalAndDepartureRetrieveResponse.Data.Entry + .TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + .build() + + assertThat(arrivalAndDepartureRetrieveResponse.code()).isEqualTo(0L) + assertThat(arrivalAndDepartureRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(arrivalAndDepartureRetrieveResponse.text()).isEqualTo("text") + assertThat(arrivalAndDepartureRetrieveResponse.version()).isEqualTo(0L) + assertThat(arrivalAndDepartureRetrieveResponse.data()) + .isEqualTo( + ArrivalAndDepartureRetrieveResponse.Data.builder() + .entry( + ArrivalAndDepartureRetrieveResponse.Data.Entry.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( + ArrivalAndDepartureRetrieveResponse.Data.Entry.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( + ArrivalAndDepartureRetrieveResponse.Data.Entry.TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalAndDepartureRetrieveResponse.Data.Entry.TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val arrivalAndDepartureRetrieveResponse = + ArrivalAndDepartureRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ArrivalAndDepartureRetrieveResponse.Data.builder() + .entry( + ArrivalAndDepartureRetrieveResponse.Data.Entry.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( + ArrivalAndDepartureRetrieveResponse.Data.Entry.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( + ArrivalAndDepartureRetrieveResponse.Data.Entry + .TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + ArrivalAndDepartureRetrieveResponse.Data.Entry + .TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + .build() + + val roundtrippedArrivalAndDepartureRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(arrivalAndDepartureRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedArrivalAndDepartureRetrieveResponse) + .isEqualTo(arrivalAndDepartureRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveParamsTest.kt index e3d6b10..f9bbb90 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/BlockRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.block import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class BlockRetrieveParamsTest { +internal class BlockRetrieveParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class BlockRetrieveParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = BlockRetrieveParams.builder().blockId("blockID").build() - assertThat(params).isNotNull - // path param "blockId" - assertThat(params.getPathParam(0)).isEqualTo("blockID") + + assertThat(params._pathParam(0)).isEqualTo("blockID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..c905c86 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveResponseTest.kt @@ -0,0 +1,617 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.block + +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 BlockRetrieveResponseTest { + + @Test + fun create() { + val blockRetrieveResponse = + BlockRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + BlockRetrieveResponse.Data.builder() + .entry( + BlockRetrieveResponse.Data.Entry.builder() + .id("id") + .addConfiguration( + BlockRetrieveResponse.Data.Entry.Configuration.builder() + .addActiveServiceId("string") + .addTrip( + BlockRetrieveResponse.Data.Entry.Configuration.Trip + .builder() + .accumulatedSlackTime(0.0f) + .addBlockStopTime( + BlockRetrieveResponse.Data.Entry.Configuration + .Trip + .BlockStopTime + .builder() + .accumulatedSlackTime(0.0f) + .blockSequence(0L) + .distanceAlongBlock(0.0f) + .stopTime( + BlockRetrieveResponse.Data.Entry + .Configuration + .Trip + .BlockStopTime + .StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .stopId("stopId") + .dropOffType(0L) + .pickupType(0L) + .build() + ) + .build() + ) + .distanceAlongBlock(0.0f) + .tripId("tripId") + .build() + ) + .addInactiveServiceId("string") + .build() + ) + .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(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() + ) + .build() + + assertThat(blockRetrieveResponse.code()).isEqualTo(0L) + assertThat(blockRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(blockRetrieveResponse.text()).isEqualTo("text") + assertThat(blockRetrieveResponse.version()).isEqualTo(0L) + assertThat(blockRetrieveResponse.data()) + .isEqualTo( + BlockRetrieveResponse.Data.builder() + .entry( + BlockRetrieveResponse.Data.Entry.builder() + .id("id") + .addConfiguration( + BlockRetrieveResponse.Data.Entry.Configuration.builder() + .addActiveServiceId("string") + .addTrip( + BlockRetrieveResponse.Data.Entry.Configuration.Trip + .builder() + .accumulatedSlackTime(0.0f) + .addBlockStopTime( + BlockRetrieveResponse.Data.Entry.Configuration.Trip + .BlockStopTime + .builder() + .accumulatedSlackTime(0.0f) + .blockSequence(0L) + .distanceAlongBlock(0.0f) + .stopTime( + BlockRetrieveResponse.Data.Entry + .Configuration + .Trip + .BlockStopTime + .StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .stopId("stopId") + .dropOffType(0L) + .pickupType(0L) + .build() + ) + .build() + ) + .distanceAlongBlock(0.0f) + .tripId("tripId") + .build() + ) + .addInactiveServiceId("string") + .build() + ) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val blockRetrieveResponse = + BlockRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + BlockRetrieveResponse.Data.builder() + .entry( + BlockRetrieveResponse.Data.Entry.builder() + .id("id") + .addConfiguration( + BlockRetrieveResponse.Data.Entry.Configuration.builder() + .addActiveServiceId("string") + .addTrip( + BlockRetrieveResponse.Data.Entry.Configuration.Trip + .builder() + .accumulatedSlackTime(0.0f) + .addBlockStopTime( + BlockRetrieveResponse.Data.Entry.Configuration + .Trip + .BlockStopTime + .builder() + .accumulatedSlackTime(0.0f) + .blockSequence(0L) + .distanceAlongBlock(0.0f) + .stopTime( + BlockRetrieveResponse.Data.Entry + .Configuration + .Trip + .BlockStopTime + .StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .stopId("stopId") + .dropOffType(0L) + .pickupType(0L) + .build() + ) + .build() + ) + .distanceAlongBlock(0.0f) + .tripId("tripId") + .build() + ) + .addInactiveServiceId("string") + .build() + ) + .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(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() + ) + .build() + + val roundtrippedBlockRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(blockRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBlockRetrieveResponse).isEqualTo(blockRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveParamsTest.kt similarity index 69% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveParamsTest.kt index 09c62a4..e0e0be4 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ConfigRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.config import org.junit.jupiter.api.Test -class ConfigRetrieveParamsTest { +internal class ConfigRetrieveParamsTest { @Test fun create() { 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 new file mode 100644 index 0000000..db41d44 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveResponseTest.kt @@ -0,0 +1,585 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.config + +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 ConfigRetrieveResponseTest { + + @Test + fun create() { + val configRetrieveResponse = + ConfigRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ConfigRetrieveResponse.Data.builder() + .entry( + ConfigRetrieveResponse.Data.Entry.builder() + .id("id") + .gitProperties( + ConfigRetrieveResponse.Data.Entry.GitProperties.builder() + .gitBranch("git.branch") + .gitBuildHost("git.build.host") + .gitBuildTime("git.build.time") + .gitBuildUserEmail("git.build.user.email") + .gitBuildUserName("git.build.user.name") + .gitBuildVersion("git.build.version") + .gitClosestTagCommitCount("git.closest.tag.commit.count") + .gitClosestTagName("git.closest.tag.name") + .gitCommitId("git.commit.id") + .gitCommitIdAbbrev("git.commit.id.abbrev") + .gitCommitIdDescribe("git.commit.id.describe") + .gitCommitIdDescribeShort("git.commit.id.describe-short") + .gitCommitMessageFull("git.commit.message.full") + .gitCommitMessageShort("git.commit.message.short") + .gitCommitTime("git.commit.time") + .gitCommitUserEmail("git.commit.user.email") + .gitCommitUserName("git.commit.user.name") + .gitDirty("git.dirty") + .gitRemoteOriginUrl("git.remote.origin.url") + .gitTags("git.tags") + .build() + ) + .name("name") + .serviceDateFrom("serviceDateFrom") + .serviceDateTo("serviceDateTo") + .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(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() + ) + .build() + + assertThat(configRetrieveResponse.code()).isEqualTo(0L) + assertThat(configRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(configRetrieveResponse.text()).isEqualTo("text") + assertThat(configRetrieveResponse.version()).isEqualTo(0L) + assertThat(configRetrieveResponse.data()) + .isEqualTo( + ConfigRetrieveResponse.Data.builder() + .entry( + ConfigRetrieveResponse.Data.Entry.builder() + .id("id") + .gitProperties( + ConfigRetrieveResponse.Data.Entry.GitProperties.builder() + .gitBranch("git.branch") + .gitBuildHost("git.build.host") + .gitBuildTime("git.build.time") + .gitBuildUserEmail("git.build.user.email") + .gitBuildUserName("git.build.user.name") + .gitBuildVersion("git.build.version") + .gitClosestTagCommitCount("git.closest.tag.commit.count") + .gitClosestTagName("git.closest.tag.name") + .gitCommitId("git.commit.id") + .gitCommitIdAbbrev("git.commit.id.abbrev") + .gitCommitIdDescribe("git.commit.id.describe") + .gitCommitIdDescribeShort("git.commit.id.describe-short") + .gitCommitMessageFull("git.commit.message.full") + .gitCommitMessageShort("git.commit.message.short") + .gitCommitTime("git.commit.time") + .gitCommitUserEmail("git.commit.user.email") + .gitCommitUserName("git.commit.user.name") + .gitDirty("git.dirty") + .gitRemoteOriginUrl("git.remote.origin.url") + .gitTags("git.tags") + .build() + ) + .name("name") + .serviceDateFrom("serviceDateFrom") + .serviceDateTo("serviceDateTo") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val configRetrieveResponse = + ConfigRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ConfigRetrieveResponse.Data.builder() + .entry( + ConfigRetrieveResponse.Data.Entry.builder() + .id("id") + .gitProperties( + ConfigRetrieveResponse.Data.Entry.GitProperties.builder() + .gitBranch("git.branch") + .gitBuildHost("git.build.host") + .gitBuildTime("git.build.time") + .gitBuildUserEmail("git.build.user.email") + .gitBuildUserName("git.build.user.name") + .gitBuildVersion("git.build.version") + .gitClosestTagCommitCount("git.closest.tag.commit.count") + .gitClosestTagName("git.closest.tag.name") + .gitCommitId("git.commit.id") + .gitCommitIdAbbrev("git.commit.id.abbrev") + .gitCommitIdDescribe("git.commit.id.describe") + .gitCommitIdDescribeShort("git.commit.id.describe-short") + .gitCommitMessageFull("git.commit.message.full") + .gitCommitMessageShort("git.commit.message.short") + .gitCommitTime("git.commit.time") + .gitCommitUserEmail("git.commit.user.email") + .gitCommitUserName("git.commit.user.name") + .gitDirty("git.dirty") + .gitRemoteOriginUrl("git.remote.origin.url") + .gitTags("git.tags") + .build() + ) + .name("name") + .serviceDateFrom("serviceDateFrom") + .serviceDateTo("serviceDateTo") + .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(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() + ) + .build() + + val roundtrippedConfigRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(configRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedConfigRetrieveResponse).isEqualTo(configRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParamsTest.kt similarity index 67% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParamsTest.kt index 7045aac..23e4299 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/CurrentTimeRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.currenttime import org.junit.jupiter.api.Test -class CurrentTimeRetrieveParamsTest { +internal class CurrentTimeRetrieveParamsTest { @Test fun create() { 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 new file mode 100644 index 0000000..f3aaf22 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponseTest.kt @@ -0,0 +1,507 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.currenttime + +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 CurrentTimeRetrieveResponseTest { + + @Test + fun create() { + val currentTimeRetrieveResponse = + CurrentTimeRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + CurrentTimeRetrieveResponse.Data.builder() + .entry( + CurrentTimeRetrieveResponse.Data.Entry.builder() + .readableTime("readableTime") + .time(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() + ) + .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(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() + ) + .build() + + assertThat(currentTimeRetrieveResponse.code()).isEqualTo(0L) + assertThat(currentTimeRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(currentTimeRetrieveResponse.text()).isEqualTo("text") + assertThat(currentTimeRetrieveResponse.version()).isEqualTo(0L) + assertThat(currentTimeRetrieveResponse.data()) + .isEqualTo( + CurrentTimeRetrieveResponse.Data.builder() + .entry( + CurrentTimeRetrieveResponse.Data.Entry.builder() + .readableTime("readableTime") + .time(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() + ) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentTimeRetrieveResponse = + CurrentTimeRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + CurrentTimeRetrieveResponse.Data.builder() + .entry( + CurrentTimeRetrieveResponse.Data.Entry.builder() + .readableTime("readableTime") + .time(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() + ) + .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(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() + ) + .build() + + val roundtrippedCurrentTimeRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentTimeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCurrentTimeRetrieveResponse).isEqualTo(currentTimeRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParamsTest.kt similarity index 50% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParamsTest.kt index a4a0191..6bfa62e 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.reportproblemwithstop import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class ReportProblemWithStopRetrieveParamsTest { +internal class ReportProblemWithStopRetrieveParamsTest { @Test fun create() { @@ -14,12 +14,21 @@ class ReportProblemWithStopRetrieveParamsTest { .stopId("stopID") .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) .userComment("userComment") - .userLat(0.0) - .userLocationAccuracy(0.0) - .userLon(0.0) + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) .build() } + @Test + fun pathParams() { + val params = ReportProblemWithStopRetrieveParams.builder().stopId("stopID").build() + + assertThat(params._pathParam(0)).isEqualTo("stopID") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -27,33 +36,31 @@ class ReportProblemWithStopRetrieveParamsTest { .stopId("stopID") .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) .userComment("userComment") - .userLat(0.0) - .userLocationAccuracy(0.0) - .userLon(0.0) + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) .build() - val expected = QueryParams.builder() - expected.put("code", ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG.toString()) - expected.put("userComment", "userComment") - expected.put("userLat", "0.0") - expected.put("userLocationAccuracy", "0.0") - expected.put("userLon", "0.0") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("code", "stop_name_wrong") + .put("userComment", "userComment") + .put("userLat", "0.0") + .put("userLocationAccuracy", "0.0") + .put("userLon", "0.0") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = ReportProblemWithStopRetrieveParams.builder().stopId("stopID").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = ReportProblemWithStopRetrieveParams.builder().stopId("stopID").build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParamsTest.kt similarity index 53% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParamsTest.kt index 45cbdba..86b9156 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReportProblemWithTripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.reportproblemwithtrip import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class ReportProblemWithTripRetrieveParamsTest { +internal class ReportProblemWithTripRetrieveParamsTest { @Test fun create() { @@ -16,15 +16,24 @@ class ReportProblemWithTripRetrieveParamsTest { .serviceDate(0L) .stopId("stopID") .userComment("userComment") - .userLat(0.0) - .userLocationAccuracy(0.0) - .userLon(0.0) + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) .userOnVehicle(true) .userVehicleNumber("userVehicleNumber") .vehicleId("vehicleID") .build() } + @Test + fun pathParams() { + val params = ReportProblemWithTripRetrieveParams.builder().tripId("tripID").build() + + assertThat(params._pathParam(0)).isEqualTo("tripID") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -34,41 +43,39 @@ class ReportProblemWithTripRetrieveParamsTest { .serviceDate(0L) .stopId("stopID") .userComment("userComment") - .userLat(0.0) - .userLocationAccuracy(0.0) - .userLon(0.0) + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) .userOnVehicle(true) .userVehicleNumber("userVehicleNumber") .vehicleId("vehicleID") .build() - val expected = QueryParams.builder() - expected.put("code", ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME.toString()) - expected.put("serviceDate", "0") - expected.put("stopID", "stopID") - expected.put("userComment", "userComment") - expected.put("userLat", "0.0") - expected.put("userLocationAccuracy", "0.0") - expected.put("userLon", "0.0") - expected.put("userOnVehicle", "true") - expected.put("userVehicleNumber", "userVehicleNumber") - expected.put("vehicleID", "vehicleID") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("code", "vehicle_never_came") + .put("serviceDate", "0") + .put("stopID", "stopID") + .put("userComment", "userComment") + .put("userLat", "0.0") + .put("userLocationAccuracy", "0.0") + .put("userLon", "0.0") + .put("userOnVehicle", "true") + .put("userVehicleNumber", "userVehicleNumber") + .put("vehicleID", "vehicleID") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = ReportProblemWithTripRetrieveParams.builder().tripId("tripID").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = ReportProblemWithTripRetrieveParams.builder().tripId("tripID").build() - assertThat(params).isNotNull - // path param "tripId" - assertThat(params.getPathParam(0)).isEqualTo("tripID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt index beb1604..bbd2166 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.route import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RouteRetrieveParamsTest { +internal class RouteRetrieveParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class RouteRetrieveParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = RouteRetrieveParams.builder().routeId("routeID").build() - assertThat(params).isNotNull - // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("routeID") + + assertThat(params._pathParam(0)).isEqualTo("routeID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..46f764f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveResponseTest.kt @@ -0,0 +1,531 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.route + +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 RouteRetrieveResponseTest { + + @Test + fun create() { + val routeRetrieveResponse = + RouteRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RouteRetrieveResponse.Data.builder() + .entry( + RouteRetrieveResponse.Data.Entry.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .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(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() + ) + .build() + + assertThat(routeRetrieveResponse.code()).isEqualTo(0L) + assertThat(routeRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(routeRetrieveResponse.text()).isEqualTo("text") + assertThat(routeRetrieveResponse.version()).isEqualTo(0L) + assertThat(routeRetrieveResponse.data()) + .isEqualTo( + RouteRetrieveResponse.Data.builder() + .entry( + RouteRetrieveResponse.Data.Entry.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val routeRetrieveResponse = + RouteRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RouteRetrieveResponse.Data.builder() + .entry( + RouteRetrieveResponse.Data.Entry.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .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(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() + ) + .build() + + val roundtrippedRouteRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(routeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRouteRetrieveResponse).isEqualTo(routeRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParamsTest.kt similarity index 58% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParamsTest.kt index 6f4a70b..190f192 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RouteIdsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.routeidsforagency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RouteIdsForAgencyListParamsTest { +internal class RouteIdsForAgencyListParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class RouteIdsForAgencyListParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = RouteIdsForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + + assertThat(params._pathParam(0)).isEqualTo("agencyID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..09d6987 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponseTest.kt @@ -0,0 +1,496 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routeidsforagency + +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 RouteIdsForAgencyListResponseTest { + + @Test + fun create() { + val routeIdsForAgencyListResponse = + RouteIdsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RouteIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .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(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() + ) + .build() + + assertThat(routeIdsForAgencyListResponse.code()).isEqualTo(0L) + assertThat(routeIdsForAgencyListResponse.currentTime()).isEqualTo(0L) + assertThat(routeIdsForAgencyListResponse.text()).isEqualTo("text") + assertThat(routeIdsForAgencyListResponse.version()).isEqualTo(0L) + assertThat(routeIdsForAgencyListResponse.data()) + .isEqualTo( + RouteIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val routeIdsForAgencyListResponse = + RouteIdsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RouteIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .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(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() + ) + .build() + + val roundtrippedRouteIdsForAgencyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(routeIdsForAgencyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRouteIdsForAgencyListResponse) + .isEqualTo(routeIdsForAgencyListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParamsTest.kt index c9c18f8..c4bea65 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.routesforagency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RoutesForAgencyListParamsTest { +internal class RoutesForAgencyListParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class RoutesForAgencyListParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = RoutesForAgencyListParams.builder().agencyId("40").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("40") + + assertThat(params._pathParam(0)).isEqualTo("40") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..0792a24 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponseTest.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforagency + +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 RoutesForAgencyListResponseTest { + + @Test + fun create() { + val routesForAgencyListResponse = + RoutesForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RoutesForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + RoutesForAgencyListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .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(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() + ) + .build() + + assertThat(routesForAgencyListResponse.code()).isEqualTo(0L) + assertThat(routesForAgencyListResponse.currentTime()).isEqualTo(0L) + assertThat(routesForAgencyListResponse.text()).isEqualTo("text") + assertThat(routesForAgencyListResponse.version()).isEqualTo(0L) + assertThat(routesForAgencyListResponse.data()) + .isEqualTo( + RoutesForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + RoutesForAgencyListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val routesForAgencyListResponse = + RoutesForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RoutesForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + RoutesForAgencyListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .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(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() + ) + .build() + + val roundtrippedRoutesForAgencyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(routesForAgencyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRoutesForAgencyListResponse).isEqualTo(routesForAgencyListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParamsTest.kt similarity index 55% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParamsTest.kt index 895f0e8..f5bbb0c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/RoutesForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.routesforlocation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class RoutesForLocationListParamsTest { +internal class RoutesForLocationListParamsTest { @Test fun create() { @@ -31,22 +31,29 @@ class RoutesForLocationListParamsTest { .query("query") .radius(0.0) .build() - val expected = QueryParams.builder() - expected.put("lat", "0.0") - expected.put("lon", "0.0") - expected.put("latSpan", "0.0") - expected.put("lonSpan", "0.0") - expected.put("query", "query") - expected.put("radius", "0.0") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("lat", "0.0") + .put("lon", "0.0") + .put("latSpan", "0.0") + .put("lonSpan", "0.0") + .put("query", "query") + .put("radius", "0.0") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = RoutesForLocationListParams.builder().lat(0.0).lon(0.0).build() - val expected = QueryParams.builder() - expected.put("lat", "0.0") - expected.put("lon", "0.0") - assertThat(params._queryParams()).isEqualTo(expected.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/routesforlocation/RoutesForLocationListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponseTest.kt new file mode 100644 index 0000000..bcb6de2 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponseTest.kt @@ -0,0 +1,538 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforlocation + +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 RoutesForLocationListResponseTest { + + @Test + fun create() { + val routesForLocationListResponse = + RoutesForLocationListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RoutesForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + RoutesForLocationListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .outOfRange(true) + .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(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() + ) + .build() + + assertThat(routesForLocationListResponse.code()).isEqualTo(0L) + assertThat(routesForLocationListResponse.currentTime()).isEqualTo(0L) + assertThat(routesForLocationListResponse.text()).isEqualTo("text") + assertThat(routesForLocationListResponse.version()).isEqualTo(0L) + assertThat(routesForLocationListResponse.data()) + .isEqualTo( + RoutesForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + RoutesForLocationListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .outOfRange(true) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val routesForLocationListResponse = + RoutesForLocationListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + RoutesForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + RoutesForLocationListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .outOfRange(true) + .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(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() + ) + .build() + + val roundtrippedRoutesForLocationListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(routesForLocationListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRoutesForLocationListResponse) + .isEqualTo(routesForLocationListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParamsTest.kt similarity index 62% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParamsTest.kt index 75b741c..62d37ac 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForRouteRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParamsTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.scheduleforroute import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class ScheduleForRouteRetrieveParamsTest { +internal class ScheduleForRouteRetrieveParamsTest { @Test fun create() { @@ -17,6 +17,15 @@ class ScheduleForRouteRetrieveParamsTest { .build() } + @Test + fun pathParams() { + val params = ScheduleForRouteRetrieveParams.builder().routeId("1_100223").build() + + assertThat(params._pathParam(0)).isEqualTo("1_100223") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -24,25 +33,18 @@ class ScheduleForRouteRetrieveParamsTest { .routeId("1_100223") .date(LocalDate.parse("2019-12-27")) .build() - val expected = QueryParams.builder() - expected.put("date", "2019-12-27") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("date", "2019-12-27").build()) } @Test fun queryParamsWithoutOptionalFields() { val params = ScheduleForRouteRetrieveParams.builder().routeId("1_100223").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = ScheduleForRouteRetrieveParams.builder().routeId("1_100223").build() - assertThat(params).isNotNull - // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("1_100223") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } 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 new file mode 100644 index 0000000..da850ec --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponseTest.kt @@ -0,0 +1,270 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforroute + +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 + +internal class ScheduleForRouteRetrieveResponseTest { + + @Test + fun create() { + val scheduleForRouteRetrieveResponse = + ScheduleForRouteRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ScheduleForRouteRetrieveResponse.Data.builder() + .entry( + ScheduleForRouteRetrieveResponse.Data.Entry.builder() + .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() + .directionId("directionId") + .addStopId("string") + .addTripHeadsign("string") + .addTripId("string") + .addTripsWithStopTime( + ScheduleForRouteRetrieveResponse.Data.Entry + .StopTripGrouping + .TripsWithStopTime + .builder() + .addStopTime( + ScheduleForRouteRetrieveResponse.Data.Entry + .StopTripGrouping + .TripsWithStopTime + .StopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .stopId("stopId") + .tripId("tripId") + .serviceId("serviceId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripId("tripId") + .build() + ) + .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() + ) + .build() + + assertThat(scheduleForRouteRetrieveResponse.code()).isEqualTo(0L) + assertThat(scheduleForRouteRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(scheduleForRouteRetrieveResponse.text()).isEqualTo("text") + assertThat(scheduleForRouteRetrieveResponse.version()).isEqualTo(0L) + assertThat(scheduleForRouteRetrieveResponse.data()) + .isEqualTo( + ScheduleForRouteRetrieveResponse.Data.builder() + .entry( + ScheduleForRouteRetrieveResponse.Data.Entry.builder() + .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() + .directionId("directionId") + .addStopId("string") + .addTripHeadsign("string") + .addTripId("string") + .addTripsWithStopTime( + ScheduleForRouteRetrieveResponse.Data.Entry.StopTripGrouping + .TripsWithStopTime + .builder() + .addStopTime( + ScheduleForRouteRetrieveResponse.Data.Entry + .StopTripGrouping + .TripsWithStopTime + .StopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .stopId("stopId") + .tripId("tripId") + .serviceId("serviceId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripId("tripId") + .build() + ) + .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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val scheduleForRouteRetrieveResponse = + ScheduleForRouteRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ScheduleForRouteRetrieveResponse.Data.builder() + .entry( + ScheduleForRouteRetrieveResponse.Data.Entry.builder() + .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() + .directionId("directionId") + .addStopId("string") + .addTripHeadsign("string") + .addTripId("string") + .addTripsWithStopTime( + ScheduleForRouteRetrieveResponse.Data.Entry + .StopTripGrouping + .TripsWithStopTime + .builder() + .addStopTime( + ScheduleForRouteRetrieveResponse.Data.Entry + .StopTripGrouping + .TripsWithStopTime + .StopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .stopId("stopId") + .tripId("tripId") + .serviceId("serviceId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripId("tripId") + .build() + ) + .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() + ) + .build() + + val roundtrippedScheduleForRouteRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(scheduleForRouteRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedScheduleForRouteRetrieveResponse) + .isEqualTo(scheduleForRouteRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt similarity index 61% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt index a1704c2..2be4584 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ScheduleForStopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.scheduleforstop import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class ScheduleForStopRetrieveParamsTest { +internal class ScheduleForStopRetrieveParamsTest { @Test fun create() { @@ -17,6 +17,15 @@ class ScheduleForStopRetrieveParamsTest { .build() } + @Test + fun pathParams() { + val params = ScheduleForStopRetrieveParams.builder().stopId("stopID").build() + + assertThat(params._pathParam(0)).isEqualTo("stopID") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -24,25 +33,18 @@ class ScheduleForStopRetrieveParamsTest { .stopId("stopID") .date(LocalDate.parse("2019-12-27")) .build() - val expected = QueryParams.builder() - expected.put("date", "2019-12-27") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("date", "2019-12-27").build()) } @Test fun queryParamsWithoutOptionalFields() { val params = ScheduleForStopRetrieveParams.builder().stopId("stopID").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = ScheduleForStopRetrieveParams.builder().stopId("stopID").build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().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 new file mode 100644 index 0000000..6a1cef0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponseTest.kt @@ -0,0 +1,636 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforstop + +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 ScheduleForStopRetrieveResponseTest { + + @Test + fun create() { + val scheduleForStopRetrieveResponse = + ScheduleForStopRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ScheduleForStopRetrieveResponse.Data.builder() + .entry( + ScheduleForStopRetrieveResponse.Data.Entry.builder() + .date(0L) + .stopId("stopId") + .addStopRouteSchedule( + ScheduleForStopRetrieveResponse.Data.Entry.StopRouteSchedule + .builder() + .routeId("routeId") + .addStopRouteDirectionSchedule( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .builder() + .addScheduleStopTime( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleStopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .serviceId("serviceId") + .tripId("tripId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripHeadsign("tripHeadsign") + .addScheduleFrequency( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleFrequency + .builder() + .endTime(0L) + .headway(0) + .serviceDate(0L) + .serviceId("serviceId") + .startTime(0L) + .tripId("tripId") + .build() + ) + .build() + ) + .build() + ) + .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(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() + ) + .build() + + assertThat(scheduleForStopRetrieveResponse.code()).isEqualTo(0L) + assertThat(scheduleForStopRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(scheduleForStopRetrieveResponse.text()).isEqualTo("text") + assertThat(scheduleForStopRetrieveResponse.version()).isEqualTo(0L) + assertThat(scheduleForStopRetrieveResponse.data()) + .isEqualTo( + ScheduleForStopRetrieveResponse.Data.builder() + .entry( + ScheduleForStopRetrieveResponse.Data.Entry.builder() + .date(0L) + .stopId("stopId") + .addStopRouteSchedule( + ScheduleForStopRetrieveResponse.Data.Entry.StopRouteSchedule + .builder() + .routeId("routeId") + .addStopRouteDirectionSchedule( + ScheduleForStopRetrieveResponse.Data.Entry.StopRouteSchedule + .StopRouteDirectionSchedule + .builder() + .addScheduleStopTime( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleStopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .serviceId("serviceId") + .tripId("tripId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripHeadsign("tripHeadsign") + .addScheduleFrequency( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleFrequency + .builder() + .endTime(0L) + .headway(0) + .serviceDate(0L) + .serviceId("serviceId") + .startTime(0L) + .tripId("tripId") + .build() + ) + .build() + ) + .build() + ) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val scheduleForStopRetrieveResponse = + ScheduleForStopRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ScheduleForStopRetrieveResponse.Data.builder() + .entry( + ScheduleForStopRetrieveResponse.Data.Entry.builder() + .date(0L) + .stopId("stopId") + .addStopRouteSchedule( + ScheduleForStopRetrieveResponse.Data.Entry.StopRouteSchedule + .builder() + .routeId("routeId") + .addStopRouteDirectionSchedule( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .builder() + .addScheduleStopTime( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleStopTime + .builder() + .arrivalEnabled(true) + .arrivalTime(0L) + .departureEnabled(true) + .departureTime(0L) + .serviceId("serviceId") + .tripId("tripId") + .stopHeadsign("stopHeadsign") + .build() + ) + .tripHeadsign("tripHeadsign") + .addScheduleFrequency( + ScheduleForStopRetrieveResponse.Data.Entry + .StopRouteSchedule + .StopRouteDirectionSchedule + .ScheduleFrequency + .builder() + .endTime(0L) + .headway(0) + .serviceDate(0L) + .serviceId("serviceId") + .startTime(0L) + .tripId("tripId") + .build() + ) + .build() + ) + .build() + ) + .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(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() + ) + .build() + + val roundtrippedScheduleForStopRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(scheduleForStopRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedScheduleForStopRetrieveResponse) + .isEqualTo(scheduleForStopRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParamsTest.kt similarity index 58% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParamsTest.kt index 0f323d3..f72eb3f 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.searchforroute import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class SearchForRouteListParamsTest { +internal class SearchForRouteListParamsTest { @Test fun create() { @@ -16,17 +16,19 @@ class SearchForRouteListParamsTest { @Test fun queryParams() { val params = SearchForRouteListParams.builder().input("input").maxCount(0L).build() - val expected = QueryParams.builder() - expected.put("input", "input") - expected.put("maxCount", "0") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("input", "input").put("maxCount", "0").build()) } @Test fun queryParamsWithoutOptionalFields() { val params = SearchForRouteListParams.builder().input("input").build() - val expected = QueryParams.builder() - expected.put("input", "input") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("input", "input").build()) } } 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 new file mode 100644 index 0000000..81b4649 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponseTest.kt @@ -0,0 +1,537 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforroute + +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 SearchForRouteListResponseTest { + + @Test + fun create() { + val searchForRouteListResponse = + SearchForRouteListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + SearchForRouteListResponse.Data.builder() + .limitExceeded(true) + .addList( + SearchForRouteListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .outOfRange(true) + .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(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() + ) + .build() + + assertThat(searchForRouteListResponse.code()).isEqualTo(0L) + assertThat(searchForRouteListResponse.currentTime()).isEqualTo(0L) + assertThat(searchForRouteListResponse.text()).isEqualTo("text") + assertThat(searchForRouteListResponse.version()).isEqualTo(0L) + assertThat(searchForRouteListResponse.data()) + .contains( + SearchForRouteListResponse.Data.builder() + .limitExceeded(true) + .addList( + SearchForRouteListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .outOfRange(true) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val searchForRouteListResponse = + SearchForRouteListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + SearchForRouteListResponse.Data.builder() + .limitExceeded(true) + .addList( + SearchForRouteListResponse.Data.List.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + .outOfRange(true) + .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(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() + ) + .build() + + val roundtrippedSearchForRouteListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(searchForRouteListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSearchForRouteListResponse).isEqualTo(searchForRouteListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParamsTest.kt similarity index 58% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParamsTest.kt index 2581cf1..aca21f5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/SearchForStopListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.searchforstop import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class SearchForStopListParamsTest { +internal class SearchForStopListParamsTest { @Test fun create() { @@ -16,17 +16,19 @@ class SearchForStopListParamsTest { @Test fun queryParams() { val params = SearchForStopListParams.builder().input("input").maxCount(0L).build() - val expected = QueryParams.builder() - expected.put("input", "input") - expected.put("maxCount", "0") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("input", "input").put("maxCount", "0").build()) } @Test fun queryParamsWithoutOptionalFields() { val params = SearchForStopListParams.builder().input("input").build() - val expected = QueryParams.builder() - expected.put("input", "input") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("input", "input").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 new file mode 100644 index 0000000..0efc4a6 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponseTest.kt @@ -0,0 +1,540 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforstop + +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 SearchForStopListResponseTest { + + @Test + fun create() { + val searchForStopListResponse = + SearchForStopListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + SearchForStopListResponse.Data.builder() + .limitExceeded(true) + .addList( + SearchForStopListResponse.Data.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() + ) + .outOfRange(true) + .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(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() + ) + .build() + + assertThat(searchForStopListResponse.code()).isEqualTo(0L) + assertThat(searchForStopListResponse.currentTime()).isEqualTo(0L) + assertThat(searchForStopListResponse.text()).isEqualTo("text") + assertThat(searchForStopListResponse.version()).isEqualTo(0L) + assertThat(searchForStopListResponse.data()) + .contains( + SearchForStopListResponse.Data.builder() + .limitExceeded(true) + .addList( + SearchForStopListResponse.Data.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() + ) + .outOfRange(true) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val searchForStopListResponse = + SearchForStopListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + SearchForStopListResponse.Data.builder() + .limitExceeded(true) + .addList( + SearchForStopListResponse.Data.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() + ) + .outOfRange(true) + .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(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() + ) + .build() + + val roundtrippedSearchForStopListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(searchForStopListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSearchForStopListResponse).isEqualTo(searchForStopListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveParamsTest.kt index 9ddb3bf..2300caf 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ShapeRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.shape import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ShapeRetrieveParamsTest { +internal class ShapeRetrieveParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class ShapeRetrieveParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = ShapeRetrieveParams.builder().shapeId("shapeID").build() - assertThat(params).isNotNull - // path param "shapeId" - assertThat(params.getPathParam(0)).isEqualTo("shapeID") + + assertThat(params._pathParam(0)).isEqualTo("shapeID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..cbd2651 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponseTest.kt @@ -0,0 +1,510 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.shape + +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 ShapeRetrieveResponseTest { + + @Test + fun create() { + val shapeRetrieveResponse = + ShapeRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ShapeRetrieveResponse.Data.builder() + .entry( + ShapeRetrieveResponse.Data.Entry.builder() + .length(0L) + .points("points") + .levels("levels") + .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(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() + ) + .build() + + assertThat(shapeRetrieveResponse.code()).isEqualTo(0L) + assertThat(shapeRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(shapeRetrieveResponse.text()).isEqualTo("text") + assertThat(shapeRetrieveResponse.version()).isEqualTo(0L) + assertThat(shapeRetrieveResponse.data()) + .isEqualTo( + ShapeRetrieveResponse.Data.builder() + .entry( + ShapeRetrieveResponse.Data.Entry.builder() + .length(0L) + .points("points") + .levels("levels") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val shapeRetrieveResponse = + ShapeRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + ShapeRetrieveResponse.Data.builder() + .entry( + ShapeRetrieveResponse.Data.Entry.builder() + .length(0L) + .points("points") + .levels("levels") + .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(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() + ) + .build() + + val roundtrippedShapeRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(shapeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedShapeRetrieveResponse).isEqualTo(shapeRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveParamsTest.kt index 2ca4aab..60c24a1 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stop import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class StopRetrieveParamsTest { +internal class StopRetrieveParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class StopRetrieveParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = StopRetrieveParams.builder().stopId("stopID").build() - assertThat(params).isNotNull - // path param "stopId" - assertThat(params.getPathParam(0)).isEqualTo("stopID") + + assertThat(params._pathParam(0)).isEqualTo("stopID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..9120c5f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveResponseTest.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stop + +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 StopRetrieveResponseTest { + + @Test + fun create() { + val stopRetrieveResponse = + StopRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopRetrieveResponse.Data.builder() + .entry( + StopRetrieveResponse.Data.Entry.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() + .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(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() + ) + .build() + + assertThat(stopRetrieveResponse.code()).isEqualTo(0L) + assertThat(stopRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(stopRetrieveResponse.text()).isEqualTo("text") + assertThat(stopRetrieveResponse.version()).isEqualTo(0L) + assertThat(stopRetrieveResponse.data()) + .isEqualTo( + StopRetrieveResponse.Data.builder() + .entry( + StopRetrieveResponse.Data.Entry.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() + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stopRetrieveResponse = + StopRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopRetrieveResponse.Data.builder() + .entry( + StopRetrieveResponse.Data.Entry.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() + .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(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() + ) + .build() + + val roundtrippedStopRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stopRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStopRetrieveResponse).isEqualTo(stopRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParamsTest.kt index e9f8805..c0f8cfc 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopIdsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopidsforagency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class StopIdsForAgencyListParamsTest { +internal class StopIdsForAgencyListParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class StopIdsForAgencyListParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = StopIdsForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + + assertThat(params._pathParam(0)).isEqualTo("agencyID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..f11d550 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponseTest.kt @@ -0,0 +1,495 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopidsforagency + +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 StopIdsForAgencyListResponseTest { + + @Test + fun create() { + val stopIdsForAgencyListResponse = + StopIdsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .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(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() + ) + .build() + + assertThat(stopIdsForAgencyListResponse.code()).isEqualTo(0L) + assertThat(stopIdsForAgencyListResponse.currentTime()).isEqualTo(0L) + assertThat(stopIdsForAgencyListResponse.text()).isEqualTo("text") + assertThat(stopIdsForAgencyListResponse.version()).isEqualTo(0L) + assertThat(stopIdsForAgencyListResponse.data()) + .isEqualTo( + StopIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stopIdsForAgencyListResponse = + StopIdsForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopIdsForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList("string") + .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(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() + ) + .build() + + val roundtrippedStopIdsForAgencyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stopIdsForAgencyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStopIdsForAgencyListResponse).isEqualTo(stopIdsForAgencyListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParamsTest.kt index 5df5004..aa6e543 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopsforagency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class StopsForAgencyListParamsTest { +internal class StopsForAgencyListParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class StopsForAgencyListParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = StopsForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") + + assertThat(params._pathParam(0)).isEqualTo("agencyID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..29422fd --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponseTest.kt @@ -0,0 +1,522 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforagency + +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 StopsForAgencyListResponseTest { + + @Test + fun create() { + val stopsForAgencyListResponse = + StopsForAgencyListResponse.builder() + .code(0L) + .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() + .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(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() + ) + .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()) + .isEqualTo( + 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(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() + ) + assertThat(stopsForAgencyListResponse.outOfRange()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stopsForAgencyListResponse = + StopsForAgencyListResponse.builder() + .code(0L) + .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() + .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(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() + ) + .outOfRange(true) + .build() + + val roundtrippedStopsForAgencyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stopsForAgencyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStopsForAgencyListResponse).isEqualTo(stopsForAgencyListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParamsTest.kt similarity index 55% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParamsTest.kt index e88198b..768453e 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForLocationListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopsforlocation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class StopsForLocationListParamsTest { +internal class StopsForLocationListParamsTest { @Test fun create() { @@ -31,22 +31,29 @@ class StopsForLocationListParamsTest { .query("query") .radius(0.0) .build() - val expected = QueryParams.builder() - expected.put("lat", "0.0") - expected.put("lon", "0.0") - expected.put("latSpan", "0.0") - expected.put("lonSpan", "0.0") - expected.put("query", "query") - expected.put("radius", "0.0") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("lat", "0.0") + .put("lon", "0.0") + .put("latSpan", "0.0") + .put("lonSpan", "0.0") + .put("query", "query") + .put("radius", "0.0") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = StopsForLocationListParams.builder().lat(0.0).lon(0.0).build() - val expected = QueryParams.builder() - expected.put("lat", "0.0") - expected.put("lon", "0.0") - assertThat(params._queryParams()).isEqualTo(expected.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/stopsforlocation/StopsForLocationListResponseTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponseTest.kt new file mode 100644 index 0000000..f0d41a0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponseTest.kt @@ -0,0 +1,540 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforlocation + +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 StopsForLocationListResponseTest { + + @Test + fun create() { + val stopsForLocationListResponse = + StopsForLocationListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopsForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + StopsForLocationListResponse.Data.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() + .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(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() + ) + .outOfRange(true) + .build() + ) + .build() + + assertThat(stopsForLocationListResponse.code()).isEqualTo(0L) + assertThat(stopsForLocationListResponse.currentTime()).isEqualTo(0L) + assertThat(stopsForLocationListResponse.text()).isEqualTo("text") + assertThat(stopsForLocationListResponse.version()).isEqualTo(0L) + assertThat(stopsForLocationListResponse.data()) + .isEqualTo( + StopsForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + StopsForLocationListResponse.Data.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() + .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(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() + ) + .outOfRange(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stopsForLocationListResponse = + StopsForLocationListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + StopsForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + StopsForLocationListResponse.Data.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() + .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(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() + ) + .outOfRange(true) + .build() + ) + .build() + + val roundtrippedStopsForLocationListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stopsForLocationListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStopsForLocationListResponse).isEqualTo(stopsForLocationListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParamsTest.kt similarity index 60% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParamsTest.kt index 69c1b8f..a40d30a 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/StopsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.stopsforroute import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class StopsForRouteListParamsTest { +internal class StopsForRouteListParamsTest { @Test fun create() { @@ -17,6 +17,15 @@ class StopsForRouteListParamsTest { .build() } + @Test + fun pathParams() { + val params = StopsForRouteListParams.builder().routeId("routeID").build() + + assertThat(params._pathParam(0)).isEqualTo("routeID") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -25,26 +34,21 @@ class StopsForRouteListParamsTest { .includePolylines(true) .time("time") .build() - val expected = QueryParams.builder() - expected.put("includePolylines", "true") - expected.put("time", "time") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder().put("includePolylines", "true").put("time", "time").build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = StopsForRouteListParams.builder().routeId("routeID").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = StopsForRouteListParams.builder().routeId("routeID").build() - assertThat(params).isNotNull - // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("routeID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().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 new file mode 100644 index 0000000..7e35cf7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponseTest.kt @@ -0,0 +1,596 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforroute + +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 StopsForRouteListResponseTest { + + @Test + fun create() { + val stopsForRouteListResponse = + StopsForRouteListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .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() + ) + .addPolyline( + StopsForRouteListResponse.Data.Entry.StopGrouping + .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") + .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(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() + ) + .build() + + assertThat(stopsForRouteListResponse.code()).isEqualTo(0L) + assertThat(stopsForRouteListResponse.currentTime()).isEqualTo(0L) + assertThat(stopsForRouteListResponse.text()).isEqualTo("text") + assertThat(stopsForRouteListResponse.version()).isEqualTo(0L) + 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() + ) + .addPolyline( + StopsForRouteListResponse.Data.Entry.StopGrouping.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") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stopsForRouteListResponse = + StopsForRouteListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .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() + ) + .addPolyline( + StopsForRouteListResponse.Data.Entry.StopGrouping + .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") + .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(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() + ) + .build() + + val roundtrippedStopsForRouteListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stopsForRouteListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStopsForRouteListResponse).isEqualTo(stopsForRouteListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveParamsTest.kt index cd59a34..fc93c04 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveParamsTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.trip import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class TripRetrieveParamsTest { +internal class TripRetrieveParamsTest { @Test fun create() { @@ -13,12 +13,11 @@ class TripRetrieveParamsTest { } @Test - fun getPathParam() { + fun pathParams() { val params = TripRetrieveParams.builder().tripId("tripID").build() - assertThat(params).isNotNull - // path param "tripId" - assertThat(params.getPathParam(0)).isEqualTo("tripID") + + assertThat(params._pathParam(0)).isEqualTo("tripID") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } 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 new file mode 100644 index 0000000..0886e40 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveResponseTest.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.trip + +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 TripRetrieveResponseTest { + + @Test + fun create() { + val tripRetrieveResponse = + TripRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripRetrieveResponse.Data.builder() + .entry( + TripRetrieveResponse.Data.Entry.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .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(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() + ) + .build() + + assertThat(tripRetrieveResponse.code()).isEqualTo(0L) + assertThat(tripRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(tripRetrieveResponse.text()).isEqualTo("text") + assertThat(tripRetrieveResponse.version()).isEqualTo(0L) + assertThat(tripRetrieveResponse.data()) + .isEqualTo( + TripRetrieveResponse.Data.builder() + .entry( + TripRetrieveResponse.Data.Entry.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tripRetrieveResponse = + TripRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripRetrieveResponse.Data.builder() + .entry( + TripRetrieveResponse.Data.Entry.builder() + .id("id") + .routeId("routeId") + .serviceId("serviceId") + .blockId("blockId") + .directionId("directionId") + .peakOffpeak(0L) + .routeShortName("routeShortName") + .shapeId("shapeId") + .timeZone("timeZone") + .tripHeadsign("tripHeadsign") + .tripShortName("tripShortName") + .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(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() + ) + .build() + + val roundtrippedTripRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tripRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTripRetrieveResponse).isEqualTo(tripRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParamsTest.kt similarity index 58% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParamsTest.kt index 13efd64..8e7aade 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripDetailRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.tripdetails import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class TripDetailRetrieveParamsTest { +internal class TripDetailRetrieveParamsTest { @Test fun create() { @@ -20,6 +20,15 @@ class TripDetailRetrieveParamsTest { .build() } + @Test + fun pathParams() { + val params = TripDetailRetrieveParams.builder().tripId("tripID").build() + + assertThat(params._pathParam(0)).isEqualTo("tripID") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -31,29 +40,27 @@ class TripDetailRetrieveParamsTest { .serviceDate(0L) .time(0L) .build() - val expected = QueryParams.builder() - expected.put("includeSchedule", "true") - expected.put("includeStatus", "true") - expected.put("includeTrip", "true") - expected.put("serviceDate", "0") - expected.put("time", "0") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("includeSchedule", "true") + .put("includeStatus", "true") + .put("includeTrip", "true") + .put("serviceDate", "0") + .put("time", "0") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = TripDetailRetrieveParams.builder().tripId("tripID").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = TripDetailRetrieveParams.builder().tripId("tripID").build() - assertThat(params).isNotNull - // path param "tripId" - assertThat(params.getPathParam(0)).isEqualTo("tripID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } 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 new file mode 100644 index 0000000..494b05a --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponseTest.kt @@ -0,0 +1,702 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripdetails + +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 TripDetailRetrieveResponseTest { + + @Test + fun create() { + val tripDetailRetrieveResponse = + TripDetailRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripDetailRetrieveResponse.Data.builder() + .entry( + TripDetailRetrieveResponse.Data.Entry.builder() + .tripId("tripId") + .frequency("frequency") + .schedule( + TripDetailRetrieveResponse.Data.Entry.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripDetailRetrieveResponse.Data.Entry.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .serviceDate(0L) + .addSituationId("string") + .status( + TripDetailRetrieveResponse.Data.Entry.Status.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( + TripDetailRetrieveResponse.Data.Entry.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripDetailRetrieveResponse.Data.Entry.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + .build() + + assertThat(tripDetailRetrieveResponse.code()).isEqualTo(0L) + assertThat(tripDetailRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(tripDetailRetrieveResponse.text()).isEqualTo("text") + assertThat(tripDetailRetrieveResponse.version()).isEqualTo(0L) + assertThat(tripDetailRetrieveResponse.data()) + .isEqualTo( + TripDetailRetrieveResponse.Data.builder() + .entry( + TripDetailRetrieveResponse.Data.Entry.builder() + .tripId("tripId") + .frequency("frequency") + .schedule( + TripDetailRetrieveResponse.Data.Entry.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripDetailRetrieveResponse.Data.Entry.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .serviceDate(0L) + .addSituationId("string") + .status( + TripDetailRetrieveResponse.Data.Entry.Status.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( + TripDetailRetrieveResponse.Data.Entry.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripDetailRetrieveResponse.Data.Entry.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tripDetailRetrieveResponse = + TripDetailRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripDetailRetrieveResponse.Data.builder() + .entry( + TripDetailRetrieveResponse.Data.Entry.builder() + .tripId("tripId") + .frequency("frequency") + .schedule( + TripDetailRetrieveResponse.Data.Entry.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripDetailRetrieveResponse.Data.Entry.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .serviceDate(0L) + .addSituationId("string") + .status( + TripDetailRetrieveResponse.Data.Entry.Status.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( + TripDetailRetrieveResponse.Data.Entry.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripDetailRetrieveResponse.Data.Entry.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + .build() + + val roundtrippedTripDetailRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tripDetailRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTripDetailRetrieveResponse).isEqualTo(tripDetailRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParamsTest.kt similarity index 58% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParamsTest.kt index 1792d80..d1b8d5d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripForVehicleRetrieveParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.tripforvehicle import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class TripForVehicleRetrieveParamsTest { +internal class TripForVehicleRetrieveParamsTest { @Test fun create() { @@ -19,6 +19,15 @@ class TripForVehicleRetrieveParamsTest { .build() } + @Test + fun pathParams() { + val params = TripForVehicleRetrieveParams.builder().vehicleId("vehicleID").build() + + assertThat(params._pathParam(0)).isEqualTo("vehicleID") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -29,28 +38,26 @@ class TripForVehicleRetrieveParamsTest { .includeTrip(true) .time(0L) .build() - val expected = QueryParams.builder() - expected.put("includeSchedule", "true") - expected.put("includeStatus", "true") - expected.put("includeTrip", "true") - expected.put("time", "0") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("includeSchedule", "true") + .put("includeStatus", "true") + .put("includeTrip", "true") + .put("time", "0") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = TripForVehicleRetrieveParams.builder().vehicleId("vehicleID").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = TripForVehicleRetrieveParams.builder().vehicleId("vehicleID").build() - assertThat(params).isNotNull - // path param "vehicleId" - assertThat(params.getPathParam(0)).isEqualTo("vehicleID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } 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 new file mode 100644 index 0000000..a6b673c --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponseTest.kt @@ -0,0 +1,707 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripforvehicle + +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 TripForVehicleRetrieveResponseTest { + + @Test + fun create() { + val tripForVehicleRetrieveResponse = + TripForVehicleRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripForVehicleRetrieveResponse.Data.builder() + .entry( + TripForVehicleRetrieveResponse.Data.Entry.builder() + .tripId("tripId") + .frequency("frequency") + .schedule( + TripForVehicleRetrieveResponse.Data.Entry.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripForVehicleRetrieveResponse.Data.Entry.Schedule + .StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .serviceDate(0L) + .addSituationId("string") + .status( + TripForVehicleRetrieveResponse.Data.Entry.Status.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( + TripForVehicleRetrieveResponse.Data.Entry.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripForVehicleRetrieveResponse.Data.Entry.Status + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + .build() + + assertThat(tripForVehicleRetrieveResponse.code()).isEqualTo(0L) + assertThat(tripForVehicleRetrieveResponse.currentTime()).isEqualTo(0L) + assertThat(tripForVehicleRetrieveResponse.text()).isEqualTo("text") + assertThat(tripForVehicleRetrieveResponse.version()).isEqualTo(0L) + assertThat(tripForVehicleRetrieveResponse.data()) + .isEqualTo( + TripForVehicleRetrieveResponse.Data.builder() + .entry( + TripForVehicleRetrieveResponse.Data.Entry.builder() + .tripId("tripId") + .frequency("frequency") + .schedule( + TripForVehicleRetrieveResponse.Data.Entry.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripForVehicleRetrieveResponse.Data.Entry.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .serviceDate(0L) + .addSituationId("string") + .status( + TripForVehicleRetrieveResponse.Data.Entry.Status.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( + TripForVehicleRetrieveResponse.Data.Entry.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripForVehicleRetrieveResponse.Data.Entry.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tripForVehicleRetrieveResponse = + TripForVehicleRetrieveResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripForVehicleRetrieveResponse.Data.builder() + .entry( + TripForVehicleRetrieveResponse.Data.Entry.builder() + .tripId("tripId") + .frequency("frequency") + .schedule( + TripForVehicleRetrieveResponse.Data.Entry.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripForVehicleRetrieveResponse.Data.Entry.Schedule + .StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .serviceDate(0L) + .addSituationId("string") + .status( + TripForVehicleRetrieveResponse.Data.Entry.Status.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( + TripForVehicleRetrieveResponse.Data.Entry.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripForVehicleRetrieveResponse.Data.Entry.Status + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .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(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() + ) + .build() + + val roundtrippedTripForVehicleRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tripForVehicleRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTripForVehicleRetrieveResponse) + .isEqualTo(tripForVehicleRetrieveResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParamsTest.kt new file mode 100644 index 0000000..c44330e --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParamsTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforlocation + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class TripsForLocationListParamsTest { + + @Test + fun create() { + TripsForLocationListParams.builder() + .lat(0.0f) + .latSpan(0.0f) + .lon(0.0f) + .lonSpan(0.0f) + .includeSchedule(true) + .includeTrip(true) + .time(0L) + .build() + } + + @Test + fun queryParams() { + val params = + TripsForLocationListParams.builder() + .lat(0.0f) + .latSpan(0.0f) + .lon(0.0f) + .lonSpan(0.0f) + .includeSchedule(true) + .includeTrip(true) + .time(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("lat", "0.0") + .put("latSpan", "0.0") + .put("lon", "0.0") + .put("lonSpan", "0.0") + .put("includeSchedule", "true") + .put("includeTrip", "true") + .put("time", "0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + TripsForLocationListParams.builder() + .lat(0.0f) + .latSpan(0.0f) + .lon(0.0f) + .lonSpan(0.0f) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("lat", "0.0") + .put("latSpan", "0.0") + .put("lon", "0.0") + .put("lonSpan", "0.0") + .build() + ) + } +} 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 new file mode 100644 index 0000000..06f3ecd --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponseTest.kt @@ -0,0 +1,708 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforlocation + +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 TripsForLocationListResponseTest { + + @Test + fun create() { + val tripsForLocationListResponse = + TripsForLocationListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripsForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + TripsForLocationListResponse.Data.List.builder() + .schedule( + TripsForLocationListResponse.Data.List.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripsForLocationListResponse.Data.List.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .status( + TripsForLocationListResponse.Data.List.Status.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( + TripsForLocationListResponse.Data.List.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripsForLocationListResponse.Data.List.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .tripId("tripId") + .frequency("frequency") + .serviceDate(0L) + .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(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() + ) + .outOfRange(true) + .build() + ) + .build() + + assertThat(tripsForLocationListResponse.code()).isEqualTo(0L) + assertThat(tripsForLocationListResponse.currentTime()).isEqualTo(0L) + assertThat(tripsForLocationListResponse.text()).isEqualTo("text") + assertThat(tripsForLocationListResponse.version()).isEqualTo(0L) + assertThat(tripsForLocationListResponse.data()) + .isEqualTo( + TripsForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + TripsForLocationListResponse.Data.List.builder() + .schedule( + TripsForLocationListResponse.Data.List.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripsForLocationListResponse.Data.List.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .status( + TripsForLocationListResponse.Data.List.Status.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( + TripsForLocationListResponse.Data.List.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripsForLocationListResponse.Data.List.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .tripId("tripId") + .frequency("frequency") + .serviceDate(0L) + .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(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() + ) + .outOfRange(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tripsForLocationListResponse = + TripsForLocationListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripsForLocationListResponse.Data.builder() + .limitExceeded(true) + .addList( + TripsForLocationListResponse.Data.List.builder() + .schedule( + TripsForLocationListResponse.Data.List.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripsForLocationListResponse.Data.List.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .status( + TripsForLocationListResponse.Data.List.Status.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( + TripsForLocationListResponse.Data.List.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripsForLocationListResponse.Data.List.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .tripId("tripId") + .frequency("frequency") + .serviceDate(0L) + .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(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() + ) + .outOfRange(true) + .build() + ) + .build() + + val roundtrippedTripsForLocationListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tripsForLocationListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTripsForLocationListResponse).isEqualTo(tripsForLocationListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParamsTest.kt similarity index 58% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParamsTest.kt index 85d5cea..87926b8 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/TripsForRouteListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParamsTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.tripsforroute import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class TripsForRouteListParamsTest { +internal class TripsForRouteListParamsTest { @Test fun create() { @@ -18,6 +18,15 @@ class TripsForRouteListParamsTest { .build() } + @Test + fun pathParams() { + val params = TripsForRouteListParams.builder().routeId("routeID").build() + + assertThat(params._pathParam(0)).isEqualTo("routeID") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = @@ -27,27 +36,25 @@ class TripsForRouteListParamsTest { .includeStatus(true) .time(0L) .build() - val expected = QueryParams.builder() - expected.put("includeSchedule", "true") - expected.put("includeStatus", "true") - expected.put("time", "0") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("includeSchedule", "true") + .put("includeStatus", "true") + .put("time", "0") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = TripsForRouteListParams.builder().routeId("routeID").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = TripsForRouteListParams.builder().routeId("routeID").build() - assertThat(params).isNotNull - // path param "routeId" - assertThat(params.getPathParam(0)).isEqualTo("routeID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().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 new file mode 100644 index 0000000..28c9587 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponseTest.kt @@ -0,0 +1,704 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforroute + +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 TripsForRouteListResponseTest { + + @Test + fun create() { + val tripsForRouteListResponse = + TripsForRouteListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripsForRouteListResponse.Data.builder() + .limitExceeded(true) + .addList( + TripsForRouteListResponse.Data.List.builder() + .schedule( + TripsForRouteListResponse.Data.List.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripsForRouteListResponse.Data.List.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .status( + TripsForRouteListResponse.Data.List.Status.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( + TripsForRouteListResponse.Data.List.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripsForRouteListResponse.Data.List.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .tripId("tripId") + .frequency("frequency") + .serviceDate(0L) + .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(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() + ) + .build() + + assertThat(tripsForRouteListResponse.code()).isEqualTo(0L) + assertThat(tripsForRouteListResponse.currentTime()).isEqualTo(0L) + assertThat(tripsForRouteListResponse.text()).isEqualTo("text") + assertThat(tripsForRouteListResponse.version()).isEqualTo(0L) + assertThat(tripsForRouteListResponse.data()) + .isEqualTo( + TripsForRouteListResponse.Data.builder() + .limitExceeded(true) + .addList( + TripsForRouteListResponse.Data.List.builder() + .schedule( + TripsForRouteListResponse.Data.List.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripsForRouteListResponse.Data.List.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .status( + TripsForRouteListResponse.Data.List.Status.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( + TripsForRouteListResponse.Data.List.Status.LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripsForRouteListResponse.Data.List.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .tripId("tripId") + .frequency("frequency") + .serviceDate(0L) + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tripsForRouteListResponse = + TripsForRouteListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + TripsForRouteListResponse.Data.builder() + .limitExceeded(true) + .addList( + TripsForRouteListResponse.Data.List.builder() + .schedule( + TripsForRouteListResponse.Data.List.Schedule.builder() + .nextTripId("nextTripId") + .previousTripId("previousTripId") + .addStopTime( + TripsForRouteListResponse.Data.List.Schedule.StopTime + .builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + .timeZone("timeZone") + .frequency("frequency") + .build() + ) + .status( + TripsForRouteListResponse.Data.List.Status.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( + TripsForRouteListResponse.Data.List.Status + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + TripsForRouteListResponse.Data.List.Status.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .tripId("tripId") + .frequency("frequency") + .serviceDate(0L) + .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(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() + ) + .build() + + val roundtrippedTripsForRouteListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tripsForRouteListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTripsForRouteListResponse).isEqualTo(tripsForRouteListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParamsTest.kt similarity index 57% rename from onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt rename to onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParamsTest.kt index cf6f7e1..d71fee1 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/VehiclesForAgencyListParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParamsTest.kt @@ -1,40 +1,42 @@ // File generated from our OpenAPI spec by Stainless. -package org.onebusaway.models +package org.onebusaway.models.vehiclesforagency import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.onebusaway.core.http.QueryParams -class VehiclesForAgencyListParamsTest { +internal class VehiclesForAgencyListParamsTest { @Test fun create() { VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() } + @Test + fun pathParams() { + val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").build() + + assertThat(params._pathParam(0)).isEqualTo("agencyID") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + @Test fun queryParams() { val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() - val expected = QueryParams.builder() - expected.put("time", "time") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("time", "time").build()) } @Test fun queryParamsWithoutOptionalFields() { val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) - } - @Test - fun getPathParam() { - val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").build() - assertThat(params).isNotNull - // path param "agencyId" - assertThat(params.getPathParam(0)).isEqualTo("agencyID") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().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 new file mode 100644 index 0000000..401640e --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponseTest.kt @@ -0,0 +1,684 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.vehiclesforagency + +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 VehiclesForAgencyListResponseTest { + + @Test + fun create() { + val vehiclesForAgencyListResponse = + VehiclesForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + VehiclesForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + VehiclesForAgencyListResponse.Data.List.builder() + .lastLocationUpdateTime(0L) + .lastUpdateTime(0L) + .location( + VehiclesForAgencyListResponse.Data.List.Location.builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .tripId("tripId") + .tripStatus( + VehiclesForAgencyListResponse.Data.List.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( + VehiclesForAgencyListResponse.Data.List.TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + VehiclesForAgencyListResponse.Data.List.TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .vehicleId("vehicleId") + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .status("status") + .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(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() + ) + .build() + + assertThat(vehiclesForAgencyListResponse.code()).isEqualTo(0L) + assertThat(vehiclesForAgencyListResponse.currentTime()).isEqualTo(0L) + assertThat(vehiclesForAgencyListResponse.text()).isEqualTo("text") + assertThat(vehiclesForAgencyListResponse.version()).isEqualTo(0L) + assertThat(vehiclesForAgencyListResponse.data()) + .isEqualTo( + VehiclesForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + VehiclesForAgencyListResponse.Data.List.builder() + .lastLocationUpdateTime(0L) + .lastUpdateTime(0L) + .location( + VehiclesForAgencyListResponse.Data.List.Location.builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .tripId("tripId") + .tripStatus( + VehiclesForAgencyListResponse.Data.List.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( + VehiclesForAgencyListResponse.Data.List.TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + VehiclesForAgencyListResponse.Data.List.TripStatus.Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .vehicleId("vehicleId") + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .status("status") + .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(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() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val vehiclesForAgencyListResponse = + VehiclesForAgencyListResponse.builder() + .code(0L) + .currentTime(0L) + .text("text") + .version(0L) + .data( + VehiclesForAgencyListResponse.Data.builder() + .limitExceeded(true) + .addList( + VehiclesForAgencyListResponse.Data.List.builder() + .lastLocationUpdateTime(0L) + .lastUpdateTime(0L) + .location( + VehiclesForAgencyListResponse.Data.List.Location.builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .tripId("tripId") + .tripStatus( + VehiclesForAgencyListResponse.Data.List.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( + VehiclesForAgencyListResponse.Data.List.TripStatus + .LastKnownLocation + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .lastKnownOrientation(0.0) + .nextStop("nextStop") + .nextStopTimeOffset(0L) + .orientation(0.0) + .position( + VehiclesForAgencyListResponse.Data.List.TripStatus + .Position + .builder() + .lat(0.0) + .lon(0.0) + .build() + ) + .scheduledDistanceAlongTrip(0.0) + .addSituationId("string") + .vehicleId("vehicleId") + .build() + ) + .vehicleId("vehicleId") + .occupancyCapacity(0L) + .occupancyCount(0L) + .occupancyStatus("occupancyStatus") + .phase("phase") + .status("status") + .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(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() + ) + .build() + + val roundtrippedVehiclesForAgencyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(vehiclesForAgencyListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVehiclesForAgencyListResponse) + .isEqualTo(vehiclesForAgencyListResponse) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt index 5b505b3..40931f5 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt @@ -2,19 +2,18 @@ package org.onebusaway.services -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.get -import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatThrownBy -import org.assertj.core.api.InstanceOfAssertFactories +import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.parallel.ResourceLock import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient import org.onebusaway.core.JsonValue @@ -23,24 +22,29 @@ import org.onebusaway.core.jsonMapper import org.onebusaway.errors.BadRequestException import org.onebusaway.errors.InternalServerException import org.onebusaway.errors.NotFoundException -import org.onebusaway.errors.OnebusawaySdkError import org.onebusaway.errors.OnebusawaySdkException import org.onebusaway.errors.PermissionDeniedException import org.onebusaway.errors.RateLimitException import org.onebusaway.errors.UnauthorizedException import org.onebusaway.errors.UnexpectedStatusCodeException import org.onebusaway.errors.UnprocessableEntityException -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse -import org.onebusaway.models.References @WireMockTest -class ErrorHandlingTest { +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ErrorHandlingTest { - private val JSON_MAPPER: JsonMapper = jsonMapper() + companion object { - private val ONEBUSAWAY_SDK_ERROR: OnebusawaySdkError = - OnebusawaySdkError.builder().putAdditionalProperty("key", JsonValue.from("value")).build() + private val ERROR_JSON: JsonValue = JsonValue.from(mapOf("errorProperty" to "42")) + + private val ERROR_JSON_BYTES: ByteArray = jsonMapper().writeValueAsBytes(ERROR_JSON) + + private const val HEADER_NAME: String = "Error-Header" + + private const val HEADER_VALUE: String = "42" + + private const val NOT_JSON: String = "Not JSON" + } private lateinit var client: OnebusawaySdkClient @@ -48,485 +52,158 @@ class ErrorHandlingTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = OnebusawaySdkOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") .build() } @Test - fun currentTimesRetrieve200() { - val params = CurrentTimeRetrieveParams.builder().build() - - val expected = - CurrentTimeRetrieveResponse.builder() - .code(0L) - .currentTime(0L) - .text("text") - .version(0L) - .data( - CurrentTimeRetrieveResponse.Data.builder() - .entry( - CurrentTimeRetrieveResponse.Data.Entry.builder() - .readableTime("readableTime") - .time(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() - ) - .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(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() - ) - .build() - - stubFor(get(anyUrl()).willReturn(ok().withBody(toJson(expected)))) - - assertThat(client.currentTime().retrieve(params)).isEqualTo(expected) - } - - @Test - fun currentTimesRetrieve400() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve400() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(400).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertBadRequest( - e, - Headers.builder().put("Foo", "Bar").build(), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve401() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve401() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(401).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertUnauthorized( - e, - Headers.builder().put("Foo", "Bar").build(), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve403() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve403() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(403).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertPermissionDenied( - e, - Headers.builder().put("Foo", "Bar").build(), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve404() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve404() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(404).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertNotFound(e, Headers.builder().put("Foo", "Bar").build(), ONEBUSAWAY_SDK_ERROR) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve422() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve422() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(422).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertUnprocessableEntity( - e, - Headers.builder().put("Foo", "Bar").build(), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve429() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve429() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(429).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertRateLimit( - e, - Headers.builder().put("Foo", "Bar").build(), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun currentTimesRetrieve500() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve500() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(500).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertInternalServer( - e, - Headers.builder().put("Foo", "Bar").build(), - ONEBUSAWAY_SDK_ERROR - ) - }) + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun unexpectedStatusCode() { - val params = CurrentTimeRetrieveParams.builder().build() - + fun currentTimeRetrieve999() { + val currentTimeService = client.currentTime() stubFor( get(anyUrl()) .willReturn( - status(999).withHeader("Foo", "Bar").withBody(toJson(ONEBUSAWAY_SDK_ERROR)) + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) ) - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertUnexpectedStatusCodeException( - e, - 999, - Headers.builder().put("Foo", "Bar").build(), - toJson(ONEBUSAWAY_SDK_ERROR) - ) - }) - } - - @Test - fun invalidBody() { - val params = CurrentTimeRetrieveParams.builder().build() - - stubFor(get(anyUrl()).willReturn(status(200).withBody("Not JSON"))) + val e = assertThrows { currentTimeService.retrieve() } - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertThat(e) - .isInstanceOf(OnebusawaySdkException::class.java) - .hasMessage("Error reading response") - }) + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun invalidErrorBody() { - val params = CurrentTimeRetrieveParams.builder().build() - - stubFor(get(anyUrl()).willReturn(status(400).withBody("Not JSON"))) - - assertThatThrownBy({ client.currentTime().retrieve(params) }) - .satisfies({ e -> - assertBadRequest(e, Headers.builder().build(), OnebusawaySdkError.builder().build()) - }) - } - - private fun toJson(body: T): ByteArray { - return JSON_MAPPER.writeValueAsBytes(body) - } - - private fun assertUnexpectedStatusCodeException( - throwable: Throwable, - statusCode: Int, - headers: Headers, - responseBody: ByteArray - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnexpectedStatusCodeException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(statusCode) - assertThat(e.body()).isEqualTo(String(responseBody)) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertBadRequest( - throwable: Throwable, - headers: Headers, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(BadRequestException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertUnauthorized( - throwable: Throwable, - headers: Headers, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(UnauthorizedException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertPermissionDenied( - throwable: Throwable, - headers: Headers, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(PermissionDeniedException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertNotFound(throwable: Throwable, headers: Headers, error: OnebusawaySdkError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertUnprocessableEntity( - throwable: Throwable, - headers: Headers, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnprocessableEntityException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } + fun currentTimeRetrieveInvalidJsonBody() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) - private fun assertRateLimit(throwable: Throwable, headers: Headers, error: OnebusawaySdkError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } + val e = assertThrows { currentTimeService.retrieve() } - private fun assertInternalServer( - throwable: Throwable, - headers: Headers, - error: OnebusawaySdkError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(InternalServerException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) + assertThat(e).hasMessage("Error reading response") } private fun Headers.toMap(): Map> = diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt index b16e585..3b0ccc7 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt @@ -2,7 +2,6 @@ package org.onebusaway.services -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get @@ -14,17 +13,14 @@ import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock import org.onebusaway.client.OnebusawaySdkClient import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient -import org.onebusaway.core.jsonMapper -import org.onebusaway.models.CurrentTimeRetrieveParams -import org.onebusaway.models.CurrentTimeRetrieveResponse -import org.onebusaway.models.References +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams @WireMockTest -class ServiceParamsTest { - - private val JSON_MAPPER: JsonMapper = jsonMapper() +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ServiceParamsTest { private lateinit var client: OnebusawaySdkClient @@ -32,197 +28,27 @@ class ServiceParamsTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = OnebusawaySdkOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) .build() } @Test - fun currentTimesRetrieveWithAdditionalParams() { - val additionalHeaders = mutableMapOf>() - - additionalHeaders.put("x-test-header", listOf("abc1234")) - - val additionalQueryParams = mutableMapOf>() + fun retrieve() { + val currentTimeService = client.currentTime() + stubFor(get(anyUrl()).willReturn(ok("{}"))) - additionalQueryParams.put("test_query_param", listOf("def567")) - - val params = + currentTimeService.retrieve( CurrentTimeRetrieveParams.builder() - .additionalHeaders(additionalHeaders) - .additionalQueryParams(additionalQueryParams) + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") .build() - - val apiResponse = - CurrentTimeRetrieveResponse.builder() - .code(0L) - .currentTime(0L) - .text("text") - .version(0L) - .data( - CurrentTimeRetrieveResponse.Data.builder() - .entry( - CurrentTimeRetrieveResponse.Data.Entry.builder() - .readableTime("readableTime") - .time(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() - ) - .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(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() - ) - .build() - - stubFor( - get(anyUrl()) - .withHeader("x-test-header", equalTo("abc1234")) - .withQueryParam("test_query_param", equalTo("def567")) - .willReturn(ok(JSON_MAPPER.writeValueAsString(apiResponse))) ) - client.currentTime().retrieve(params) - - verify(getRequestedFor(anyUrl())) + verify( + getRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + ) } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncTest.kt new file mode 100644 index 0000000..ab52483 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class AgenciesWithCoverageServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val agenciesWithCoverageServiceAsync = client.agenciesWithCoverage() + + val agenciesWithCoveragesFuture = agenciesWithCoverageServiceAsync.list() + + val agenciesWithCoverages = agenciesWithCoveragesFuture.get() + agenciesWithCoverages.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgencyServiceAsyncTest.kt new file mode 100644 index 0000000..ca796c7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/AgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class AgencyServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val agencyServiceAsync = client.agency() + + val agencyFuture = agencyServiceAsync.retrieve("agencyID") + + val agency = agencyFuture.get() + agency.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncTest.kt new file mode 100644 index 0000000..88ee5d0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.time.OffsetDateTime +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.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ArrivalAndDepartureServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val arrivalAndDepartureServiceAsync = client.arrivalAndDeparture() + + val arrivalAndDepartureFuture = + arrivalAndDepartureServiceAsync.retrieve( + ArrivalAndDepartureRetrieveParams.builder() + .stopId("1_75403") + .serviceDate(0L) + .tripId("tripId") + .stopSequence(0L) + .time(0L) + .vehicleId("vehicleId") + .build() + ) + + val arrivalAndDeparture = arrivalAndDepartureFuture.get() + arrivalAndDeparture.validate() + } + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val arrivalAndDepartureServiceAsync = client.arrivalAndDeparture() + + val arrivalAndDeparturesFuture = + arrivalAndDepartureServiceAsync.list( + ArrivalAndDepartureListParams.builder() + .stopId("1_75403") + .minutesAfter(0L) + .minutesBefore(0L) + .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val arrivalAndDepartures = arrivalAndDeparturesFuture.get() + arrivalAndDepartures.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/BlockServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/BlockServiceAsyncTest.kt new file mode 100644 index 0000000..f738843 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/BlockServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class BlockServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val blockServiceAsync = client.block() + + val blockFuture = blockServiceAsync.retrieve("blockID") + + val block = blockFuture.get() + block.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ConfigServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ConfigServiceAsyncTest.kt new file mode 100644 index 0000000..4278265 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ConfigServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class ConfigServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val configServiceAsync = client.config() + + val configFuture = configServiceAsync.retrieve() + + val config = configFuture.get() + config.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncTest.kt new file mode 100644 index 0000000..c79a952 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class CurrentTimeServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val currentTimeServiceAsync = client.currentTime() + + val currentTimeFuture = currentTimeServiceAsync.retrieve() + + val currentTime = currentTimeFuture.get() + currentTime.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncTest.kt new file mode 100644 index 0000000..f8ae311 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// 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.reportproblemwithstop.ReportProblemWithStopRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ReportProblemWithStopServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val reportProblemWithStopServiceAsync = client.reportProblemWithStop() + + val responseWrapperFuture = + reportProblemWithStopServiceAsync.retrieve( + ReportProblemWithStopRetrieveParams.builder() + .stopId("stopID") + .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) + .userComment("userComment") + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) + .build() + ) + + val responseWrapper = responseWrapperFuture.get() + responseWrapper.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncTest.kt new file mode 100644 index 0000000..ba06e6a --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncTest.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.reportproblemwithtrip.ReportProblemWithTripRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ReportProblemWithTripServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val reportProblemWithTripServiceAsync = client.reportProblemWithTrip() + + val responseWrapperFuture = + reportProblemWithTripServiceAsync.retrieve( + ReportProblemWithTripRetrieveParams.builder() + .tripId("tripID") + .code(ReportProblemWithTripRetrieveParams.Code.VEHICLE_NEVER_CAME) + .serviceDate(0L) + .stopId("stopID") + .userComment("userComment") + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) + .userOnVehicle(true) + .userVehicleNumber("userVehicleNumber") + .vehicleId("vehicleID") + .build() + ) + + val responseWrapper = responseWrapperFuture.get() + responseWrapper.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..a075e7d --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class RouteIdsForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routeIdsForAgencyServiceAsync = client.routeIdsForAgency() + + val routeIdsForAgenciesFuture = routeIdsForAgencyServiceAsync.list("agencyID") + + val routeIdsForAgencies = routeIdsForAgenciesFuture.get() + routeIdsForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteServiceAsyncTest.kt new file mode 100644 index 0000000..c4658cb --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RouteServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class RouteServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routeServiceAsync = client.route() + + val routeFuture = routeServiceAsync.retrieve("routeID") + + val route = routeFuture.get() + route.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..9c31691 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class RoutesForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routesForAgencyServiceAsync = client.routesForAgency() + + val routesForAgenciesFuture = routesForAgencyServiceAsync.list("40") + + val routesForAgencies = routesForAgenciesFuture.get() + routesForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncTest.kt new file mode 100644 index 0000000..c1ef31c --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// 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.routesforlocation.RoutesForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class RoutesForLocationServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routesForLocationServiceAsync = client.routesForLocation() + + val routesForLocationsFuture = + routesForLocationServiceAsync.list( + RoutesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .build() + ) + + val routesForLocations = routesForLocationsFuture.get() + routesForLocations.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncTest.kt new file mode 100644 index 0000000..9774596 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.time.LocalDate +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.scheduleforroute.ScheduleForRouteRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ScheduleForRouteServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val scheduleForRouteServiceAsync = client.scheduleForRoute() + + val scheduleForRouteFuture = + scheduleForRouteServiceAsync.retrieve( + ScheduleForRouteRetrieveParams.builder() + .routeId("1_100223") + .date(LocalDate.parse("2019-12-27")) + .build() + ) + + val scheduleForRoute = scheduleForRouteFuture.get() + scheduleForRoute.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncTest.kt new file mode 100644 index 0000000..eb498fe --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.time.LocalDate +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.scheduleforstop.ScheduleForStopRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ScheduleForStopServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val scheduleForStopServiceAsync = client.scheduleForStop() + + val scheduleForStopFuture = + scheduleForStopServiceAsync.retrieve( + ScheduleForStopRetrieveParams.builder() + .stopId("stopID") + .date(LocalDate.parse("2019-12-27")) + .build() + ) + + val scheduleForStop = scheduleForStopFuture.get() + scheduleForStop.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncTest.kt new file mode 100644 index 0000000..8003d54 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// 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.searchforroute.SearchForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class SearchForRouteServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val searchForRouteServiceAsync = client.searchForRoute() + + val searchForRoutesFuture = + searchForRouteServiceAsync.list( + SearchForRouteListParams.builder().input("input").maxCount(0L).build() + ) + + val searchForRoutes = searchForRoutesFuture.get() + searchForRoutes.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncTest.kt new file mode 100644 index 0000000..22a892f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// 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.searchforstop.SearchForStopListParams + +@ExtendWith(TestServerExtension::class) +internal class SearchForStopServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val searchForStopServiceAsync = client.searchForStop() + + val searchForStopsFuture = + searchForStopServiceAsync.list( + SearchForStopListParams.builder().input("input").maxCount(0L).build() + ) + + val searchForStops = searchForStopsFuture.get() + searchForStops.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ShapeServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ShapeServiceAsyncTest.kt new file mode 100644 index 0000000..fdd7f7f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/ShapeServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class ShapeServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val shapeServiceAsync = client.shape() + + val shapeFuture = shapeServiceAsync.retrieve("shapeID") + + val shape = shapeFuture.get() + shape.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..a5e4bc1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class StopIdsForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopIdsForAgencyServiceAsync = client.stopIdsForAgency() + + val stopIdsForAgenciesFuture = stopIdsForAgencyServiceAsync.list("agencyID") + + val stopIdsForAgencies = stopIdsForAgenciesFuture.get() + stopIdsForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopServiceAsyncTest.kt new file mode 100644 index 0000000..4f96081 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class StopServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopServiceAsync = client.stop() + + val stopFuture = stopServiceAsync.retrieve("stopID") + + val stop = stopFuture.get() + stop.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..d23e9f6 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class StopsForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForAgencyServiceAsync = client.stopsForAgency() + + val stopsForAgenciesFuture = stopsForAgencyServiceAsync.list("agencyID") + + val stopsForAgencies = stopsForAgenciesFuture.get() + stopsForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncTest.kt new file mode 100644 index 0000000..9af0137 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// 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.stopsforlocation.StopsForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class StopsForLocationServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForLocationServiceAsync = client.stopsForLocation() + + val stopsForLocationsFuture = + stopsForLocationServiceAsync.list( + StopsForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .build() + ) + + val stopsForLocations = stopsForLocationsFuture.get() + stopsForLocations.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncTest.kt new file mode 100644 index 0000000..f659ea4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncTest.kt @@ -0,0 +1,35 @@ +// 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.stopsforroute.StopsForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class StopsForRouteServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForRouteServiceAsync = client.stopsForRoute() + + val stopsForRoutesFuture = + stopsForRouteServiceAsync.list( + StopsForRouteListParams.builder() + .routeId("routeID") + .includePolylines(true) + .time("time") + .build() + ) + + val stopsForRoutes = stopsForRoutesFuture.get() + stopsForRoutes.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncTest.kt new file mode 100644 index 0000000..28e9c20 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// 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.tripdetails.TripDetailRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class TripDetailServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripDetailServiceAsync = client.tripDetails() + + val tripDetailFuture = + tripDetailServiceAsync.retrieve( + TripDetailRetrieveParams.builder() + .tripId("tripID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .serviceDate(0L) + .time(0L) + .build() + ) + + val tripDetail = tripDetailFuture.get() + tripDetail.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncTest.kt new file mode 100644 index 0000000..7069748 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncTest.kt @@ -0,0 +1,37 @@ +// 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.tripforvehicle.TripForVehicleRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class TripForVehicleServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripForVehicleServiceAsync = client.tripForVehicle() + + val tripForVehicleFuture = + tripForVehicleServiceAsync.retrieve( + TripForVehicleRetrieveParams.builder() + .vehicleId("vehicleID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .time(0L) + .build() + ) + + val tripForVehicle = tripForVehicleFuture.get() + tripForVehicle.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripServiceAsyncTest.kt new file mode 100644 index 0000000..d223e77 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripServiceAsyncTest.kt @@ -0,0 +1,27 @@ +// 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 + +@ExtendWith(TestServerExtension::class) +internal class TripServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripServiceAsync = client.trip() + + val tripFuture = tripServiceAsync.retrieve("tripID") + + val trip = tripFuture.get() + trip.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncTest.kt new file mode 100644 index 0000000..debd1d8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncTest.kt @@ -0,0 +1,39 @@ +// 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.tripsforlocation.TripsForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class TripsForLocationServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripsForLocationServiceAsync = client.tripsForLocation() + + val tripsForLocationsFuture = + tripsForLocationServiceAsync.list( + TripsForLocationListParams.builder() + .lat(0.0f) + .latSpan(0.0f) + .lon(0.0f) + .lonSpan(0.0f) + .includeSchedule(true) + .includeTrip(true) + .time(0L) + .build() + ) + + val tripsForLocations = tripsForLocationsFuture.get() + tripsForLocations.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncTest.kt new file mode 100644 index 0000000..f9241a5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncTest.kt @@ -0,0 +1,36 @@ +// 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.tripsforroute.TripsForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class TripsForRouteServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripsForRouteServiceAsync = client.tripsForRoute() + + val tripsForRoutesFuture = + tripsForRouteServiceAsync.list( + TripsForRouteListParams.builder() + .routeId("routeID") + .includeSchedule(true) + .includeStatus(true) + .time(0L) + .build() + ) + + val tripsForRoutes = tripsForRoutesFuture.get() + tripsForRoutes.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncTest.kt new file mode 100644 index 0000000..5860ee8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// 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.vehiclesforagency.VehiclesForAgencyListParams + +@ExtendWith(TestServerExtension::class) +internal class VehiclesForAgencyServiceAsyncTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val vehiclesForAgencyServiceAsync = client.vehiclesForAgency() + + val vehiclesForAgenciesFuture = + vehiclesForAgencyServiceAsync.list( + VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() + ) + + val vehiclesForAgencies = vehiclesForAgenciesFuture.get() + vehiclesForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt index a4753b7..2970c2b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt @@ -6,21 +6,21 @@ 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.AgenciesWithCoverageListParams @ExtendWith(TestServerExtension::class) -class AgenciesWithCoverageServiceTest { +internal class AgenciesWithCoverageServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val agenciesWithCoverageService = client.agenciesWithCoverage() - val agenciesWithCoverageListResponse = - agenciesWithCoverageService.list(AgenciesWithCoverageListParams.builder().build()) - println(agenciesWithCoverageListResponse) + + val agenciesWithCoverages = agenciesWithCoverageService.list() + + agenciesWithCoverages.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt index 63c9d69..3d53110 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt @@ -6,21 +6,21 @@ 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.AgencyRetrieveParams @ExtendWith(TestServerExtension::class) -class AgencyServiceTest { +internal class AgencyServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val agencyService = client.agency() - val agencyRetrieveResponse = - agencyService.retrieve(AgencyRetrieveParams.builder().agencyId("agencyID").build()) - println(agencyRetrieveResponse) + + val agency = agencyService.retrieve("agencyID") + + agency.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt index 9e3e729..3aac305 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt @@ -7,21 +7,22 @@ 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.ArrivalAndDepartureListParams -import org.onebusaway.models.ArrivalAndDepartureRetrieveParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams @ExtendWith(TestServerExtension::class) -class ArrivalAndDepartureServiceTest { +internal class ArrivalAndDepartureServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val arrivalAndDepartureService = client.arrivalAndDeparture() - val arrivalAndDepartureRetrieveResponse = + + val arrivalAndDeparture = arrivalAndDepartureService.retrieve( ArrivalAndDepartureRetrieveParams.builder() .stopId("1_75403") @@ -32,18 +33,20 @@ class ArrivalAndDepartureServiceTest { .vehicleId("vehicleId") .build() ) - println(arrivalAndDepartureRetrieveResponse) + + arrivalAndDeparture.validate() } @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val arrivalAndDepartureService = client.arrivalAndDeparture() - val arrivalAndDepartureListResponse = + + val arrivalAndDepartures = arrivalAndDepartureService.list( ArrivalAndDepartureListParams.builder() .stopId("1_75403") @@ -52,6 +55,7 @@ class ArrivalAndDepartureServiceTest { .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - println(arrivalAndDepartureListResponse) + + arrivalAndDepartures.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt index 14682c9..0d6577c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt @@ -6,21 +6,21 @@ 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.BlockRetrieveParams @ExtendWith(TestServerExtension::class) -class BlockServiceTest { +internal class BlockServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val blockService = client.block() - val blockRetrieveResponse = - blockService.retrieve(BlockRetrieveParams.builder().blockId("blockID").build()) - println(blockRetrieveResponse) + + val block = blockService.retrieve("blockID") + + block.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt index 70704a4..44a28ec 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt @@ -6,20 +6,21 @@ 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.ConfigRetrieveParams @ExtendWith(TestServerExtension::class) -class ConfigServiceTest { +internal class ConfigServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val configService = client.config() - val configRetrieveResponse = configService.retrieve(ConfigRetrieveParams.builder().build()) - println(configRetrieveResponse) + + val config = configService.retrieve() + + config.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt index 10b9f47..65d5853 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt @@ -6,21 +6,21 @@ 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.CurrentTimeRetrieveParams @ExtendWith(TestServerExtension::class) -class CurrentTimeServiceTest { +internal class CurrentTimeServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val currentTimeService = client.currentTime() - val currentTimeRetrieveResponse = - currentTimeService.retrieve(CurrentTimeRetrieveParams.builder().build()) - println(currentTimeRetrieveResponse) + + val currentTime = currentTimeService.retrieve() + + currentTime.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt index 3c67aff..b4e46ca 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt @@ -6,31 +6,32 @@ 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.ReportProblemWithStopRetrieveParams +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams @ExtendWith(TestServerExtension::class) -class ReportProblemWithStopServiceTest { +internal class ReportProblemWithStopServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val reportProblemWithStopService = client.reportProblemWithStop() + val responseWrapper = reportProblemWithStopService.retrieve( ReportProblemWithStopRetrieveParams.builder() .stopId("stopID") .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) .userComment("userComment") - .userLat(0.0) - .userLocationAccuracy(0.0) - .userLon(0.0) + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) .build() ) - println(responseWrapper) + responseWrapper.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt index ae4a9fc..057847d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt @@ -6,19 +6,20 @@ 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.ReportProblemWithTripRetrieveParams +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams @ExtendWith(TestServerExtension::class) -class ReportProblemWithTripServiceTest { +internal class ReportProblemWithTripServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val reportProblemWithTripService = client.reportProblemWithTrip() + val responseWrapper = reportProblemWithTripService.retrieve( ReportProblemWithTripRetrieveParams.builder() @@ -27,15 +28,15 @@ class ReportProblemWithTripServiceTest { .serviceDate(0L) .stopId("stopID") .userComment("userComment") - .userLat(0.0) - .userLocationAccuracy(0.0) - .userLon(0.0) + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) .userOnVehicle(true) .userVehicleNumber("userVehicleNumber") .vehicleId("vehicleID") .build() ) - println(responseWrapper) + responseWrapper.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt index 295d8b9..bafe347 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt @@ -6,23 +6,21 @@ 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.RouteIdsForAgencyListParams @ExtendWith(TestServerExtension::class) -class RouteIdsForAgencyServiceTest { +internal class RouteIdsForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val routeIdsForAgencyService = client.routeIdsForAgency() - val routeIdsForAgencyListResponse = - routeIdsForAgencyService.list( - RouteIdsForAgencyListParams.builder().agencyId("agencyID").build() - ) - println(routeIdsForAgencyListResponse) + + val routeIdsForAgencies = routeIdsForAgencyService.list("agencyID") + + routeIdsForAgencies.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt index 26ff366..38e8475 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt @@ -6,21 +6,21 @@ 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.RouteRetrieveParams @ExtendWith(TestServerExtension::class) -class RouteServiceTest { +internal class RouteServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val routeService = client.route() - val routeRetrieveResponse = - routeService.retrieve(RouteRetrieveParams.builder().routeId("routeID").build()) - println(routeRetrieveResponse) + + val route = routeService.retrieve("routeID") + + route.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt index 873ce86..2972560 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt @@ -6,21 +6,21 @@ 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.RoutesForAgencyListParams @ExtendWith(TestServerExtension::class) -class RoutesForAgencyServiceTest { +internal class RoutesForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val routesForAgencyService = client.routesForAgency() - val routesForAgencyListResponse = - routesForAgencyService.list(RoutesForAgencyListParams.builder().agencyId("40").build()) - println(routesForAgencyListResponse) + + val routesForAgencies = routesForAgencyService.list("40") + + routesForAgencies.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt index f93bec8..376eeee 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt @@ -6,20 +6,21 @@ 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.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams @ExtendWith(TestServerExtension::class) -class RoutesForLocationServiceTest { +internal class RoutesForLocationServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val routesForLocationService = client.routesForLocation() - val routesForLocationListResponse = + + val routesForLocations = routesForLocationService.list( RoutesForLocationListParams.builder() .lat(0.0) @@ -30,6 +31,7 @@ class RoutesForLocationServiceTest { .radius(0.0) .build() ) - println(routesForLocationListResponse) + + routesForLocations.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt index c44474c..f9bc244 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt @@ -7,26 +7,28 @@ 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.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams @ExtendWith(TestServerExtension::class) -class ScheduleForRouteServiceTest { +internal class ScheduleForRouteServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val scheduleForRouteService = client.scheduleForRoute() - val scheduleForRouteRetrieveResponse = + + val scheduleForRoute = scheduleForRouteService.retrieve( ScheduleForRouteRetrieveParams.builder() .routeId("1_100223") .date(LocalDate.parse("2019-12-27")) .build() ) - println(scheduleForRouteRetrieveResponse) + + scheduleForRoute.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt index 95db8e9..caf1b82 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt @@ -7,26 +7,28 @@ 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.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams @ExtendWith(TestServerExtension::class) -class ScheduleForStopServiceTest { +internal class ScheduleForStopServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val scheduleForStopService = client.scheduleForStop() - val scheduleForStopRetrieveResponse = + + val scheduleForStop = scheduleForStopService.retrieve( ScheduleForStopRetrieveParams.builder() .stopId("stopID") .date(LocalDate.parse("2019-12-27")) .build() ) - println(scheduleForStopRetrieveResponse) + + scheduleForStop.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt index ad95562..712475d 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt @@ -6,23 +6,25 @@ 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.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListParams @ExtendWith(TestServerExtension::class) -class SearchForRouteServiceTest { +internal class SearchForRouteServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val searchForRouteService = client.searchForRoute() - val searchForRouteListResponse = + + val searchForRoutes = searchForRouteService.list( SearchForRouteListParams.builder().input("input").maxCount(0L).build() ) - println(searchForRouteListResponse) + + searchForRoutes.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt index 3fcdb97..1ce37be 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt @@ -6,23 +6,25 @@ 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.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListParams @ExtendWith(TestServerExtension::class) -class SearchForStopServiceTest { +internal class SearchForStopServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val searchForStopService = client.searchForStop() - val searchForStopListResponse = + + val searchForStops = searchForStopService.list( SearchForStopListParams.builder().input("input").maxCount(0L).build() ) - println(searchForStopListResponse) + + searchForStops.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt index 25f3dab..c2a6daf 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt @@ -6,21 +6,21 @@ 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.ShapeRetrieveParams @ExtendWith(TestServerExtension::class) -class ShapeServiceTest { +internal class ShapeServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val shapeService = client.shape() - val shapeRetrieveResponse = - shapeService.retrieve(ShapeRetrieveParams.builder().shapeId("shapeID").build()) - println(shapeRetrieveResponse) + + val shape = shapeService.retrieve("shapeID") + + shape.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt index 5c32068..a1aa457 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt @@ -6,23 +6,21 @@ 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.StopIdsForAgencyListParams @ExtendWith(TestServerExtension::class) -class StopIdsForAgencyServiceTest { +internal class StopIdsForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopIdsForAgencyService = client.stopIdsForAgency() - val stopIdsForAgencyListResponse = - stopIdsForAgencyService.list( - StopIdsForAgencyListParams.builder().agencyId("agencyID").build() - ) - println(stopIdsForAgencyListResponse) + + val stopIdsForAgencies = stopIdsForAgencyService.list("agencyID") + + stopIdsForAgencies.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt index 191397a..de4e314 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt @@ -6,21 +6,21 @@ 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.StopRetrieveParams @ExtendWith(TestServerExtension::class) -class StopServiceTest { +internal class StopServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopService = client.stop() - val stopRetrieveResponse = - stopService.retrieve(StopRetrieveParams.builder().stopId("stopID").build()) - println(stopRetrieveResponse) + + val stop = stopService.retrieve("stopID") + + stop.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt index c3a7cc9..8be4373 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt @@ -6,23 +6,21 @@ 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.StopsForAgencyListParams @ExtendWith(TestServerExtension::class) -class StopsForAgencyServiceTest { +internal class StopsForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopsForAgencyService = client.stopsForAgency() - val stopsForAgencyListResponse = - stopsForAgencyService.list( - StopsForAgencyListParams.builder().agencyId("agencyID").build() - ) - println(stopsForAgencyListResponse) + + val stopsForAgencies = stopsForAgencyService.list("agencyID") + + stopsForAgencies.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt index d56ef06..be4b08c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt @@ -6,20 +6,21 @@ 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.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams @ExtendWith(TestServerExtension::class) -class StopsForLocationServiceTest { +internal class StopsForLocationServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopsForLocationService = client.stopsForLocation() - val stopsForLocationListResponse = + + val stopsForLocations = stopsForLocationService.list( StopsForLocationListParams.builder() .lat(0.0) @@ -30,6 +31,7 @@ class StopsForLocationServiceTest { .radius(0.0) .build() ) - println(stopsForLocationListResponse) + + stopsForLocations.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt index a8ce387..4622d42 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt @@ -6,20 +6,21 @@ 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.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListParams @ExtendWith(TestServerExtension::class) -class StopsForRouteServiceTest { +internal class StopsForRouteServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val stopsForRouteService = client.stopsForRoute() - val stopsForRouteListResponse = + + val stopsForRoutes = stopsForRouteService.list( StopsForRouteListParams.builder() .routeId("routeID") @@ -27,6 +28,7 @@ class StopsForRouteServiceTest { .time("time") .build() ) - println(stopsForRouteListResponse) + + stopsForRoutes.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt index fbd85e5..1f41a5c 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt @@ -6,20 +6,21 @@ 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.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams @ExtendWith(TestServerExtension::class) -class TripDetailServiceTest { +internal class TripDetailServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripDetailService = client.tripDetails() - val tripDetailRetrieveResponse = + + val tripDetail = tripDetailService.retrieve( TripDetailRetrieveParams.builder() .tripId("tripID") @@ -30,6 +31,7 @@ class TripDetailServiceTest { .time(0L) .build() ) - println(tripDetailRetrieveResponse) + + tripDetail.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt index 5842671..b44b32f 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt @@ -6,20 +6,21 @@ 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.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams @ExtendWith(TestServerExtension::class) -class TripForVehicleServiceTest { +internal class TripForVehicleServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripForVehicleService = client.tripForVehicle() - val tripForVehicleRetrieveResponse = + + val tripForVehicle = tripForVehicleService.retrieve( TripForVehicleRetrieveParams.builder() .vehicleId("vehicleID") @@ -29,6 +30,7 @@ class TripForVehicleServiceTest { .time(0L) .build() ) - println(tripForVehicleRetrieveResponse) + + tripForVehicle.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt index 994e4b0..597d6c9 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt @@ -6,21 +6,21 @@ 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.TripRetrieveParams @ExtendWith(TestServerExtension::class) -class TripServiceTest { +internal class TripServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripService = client.trip() - val tripRetrieveResponse = - tripService.retrieve(TripRetrieveParams.builder().tripId("tripID").build()) - println(tripRetrieveResponse) + + val trip = tripService.retrieve("tripID") + + trip.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt index 9ceb3fb..1042ce0 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt @@ -6,31 +6,33 @@ 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.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams @ExtendWith(TestServerExtension::class) -class TripsForLocationServiceTest { +internal class TripsForLocationServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripsForLocationService = client.tripsForLocation() - val tripsForLocationListResponse = + + val tripsForLocations = tripsForLocationService.list( TripsForLocationListParams.builder() - .lat(0.0) - .latSpan(0.0) - .lon(0.0) - .lonSpan(0.0) + .lat(0.0f) + .latSpan(0.0f) + .lon(0.0f) + .lonSpan(0.0f) .includeSchedule(true) .includeTrip(true) .time(0L) .build() ) - println(tripsForLocationListResponse) + + tripsForLocations.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt index afe7a9f..01f0580 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt @@ -6,20 +6,21 @@ 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.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListParams @ExtendWith(TestServerExtension::class) -class TripsForRouteServiceTest { +internal class TripsForRouteServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val tripsForRouteService = client.tripsForRoute() - val tripsForRouteListResponse = + + val tripsForRoutes = tripsForRouteService.list( TripsForRouteListParams.builder() .routeId("routeID") @@ -28,6 +29,7 @@ class TripsForRouteServiceTest { .time(0L) .build() ) - println(tripsForRouteListResponse) + + tripsForRoutes.validate() } } diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt index 36a099f..1bb2a0b 100644 --- a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt @@ -6,23 +6,25 @@ 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.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams @ExtendWith(TestServerExtension::class) -class VehiclesForAgencyServiceTest { +internal class VehiclesForAgencyServiceTest { @Test - fun callList() { + fun list() { val client = OnebusawaySdkOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val vehiclesForAgencyService = client.vehiclesForAgency() - val vehiclesForAgencyListResponse = + + val vehiclesForAgencies = vehiclesForAgencyService.list( VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() ) - println(vehiclesForAgencyListResponse) + + vehiclesForAgencies.validate() } } diff --git a/onebusaway-sdk-java-example/build.gradle.kts b/onebusaway-sdk-java-example/build.gradle.kts index a310e71..9e8670d 100644 --- a/onebusaway-sdk-java-example/build.gradle.kts +++ b/onebusaway-sdk-java-example/build.gradle.kts @@ -1,9 +1,12 @@ plugins { - id("onebusaway-sdk.kotlin") - id("java") + id("onebusaway-sdk.java") application } +repositories { + mavenCentral() +} + dependencies { implementation(project(":onebusaway-sdk-java")) } diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java index 5e8d626..0ac5c77 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/AgenciesWithCoverage.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams; +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse; public class AgenciesWithCoverage { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java index fd80deb..0b7d2c6 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Agency.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.agency.AgencyRetrieveParams; +import org.onebusaway.models.agency.AgencyRetrieveResponse; public class Agency { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java index ec62a01..2e3fed1 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalAndDepartureForStop.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams; +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveResponse; public class ArrivalAndDepartureForStop { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java index 5343f7d..03aaab8 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ArrivalsAndDeparturesForStop.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams; +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListResponse; public class ArrivalsAndDeparturesForStop { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java index afc4611..457c310 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Block.java @@ -3,7 +3,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.errors.OnebusawaySdkServiceException; -import org.onebusaway.models.*; +import org.onebusaway.models.block.BlockRetrieveParams; +import org.onebusaway.models.block.BlockRetrieveResponse; public class Block { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java index db9bc4a..432e2bf 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/CurrentTime.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; public class CurrentTime { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java index 906af64..b936b15 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Route.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.route.RouteRetrieveParams; +import org.onebusaway.models.route.RouteRetrieveResponse; public class Route { @@ -26,9 +27,8 @@ public static void main(String[] args) { try { - RouteRetrieveParams params = org.onebusaway.models.RouteRetrieveParams.builder() - .routeId(routeId) - .build(); + RouteRetrieveParams params = + RouteRetrieveParams.builder().routeId(routeId).build(); RouteRetrieveResponse route = client.route().retrieve(params); diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java index e34a32b..4d81bee 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RouteForAgency.java @@ -3,7 +3,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.errors.OnebusawaySdkServiceException; -import org.onebusaway.models.*; +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams; +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse; public class RouteForAgency { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java index bd5eb0e..a211730 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/RoutesForLocation.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams; +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse; public class RoutesForLocation { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java index cc0cc04..1fe00d1 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/ScheduleForRoute.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams; +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse; public class ScheduleForRoute { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java index a4d6840..6fd0c09 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForRoute.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.searchforroute.SearchForRouteListParams; +import org.onebusaway.models.searchforroute.SearchForRouteListResponse; public class SearchForRoute { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java index cc8a08a..2d9ce45 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/SearchForStop.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.searchforstop.SearchForStopListParams; +import org.onebusaway.models.searchforstop.SearchForStopListResponse; public class SearchForStop { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java index a3971a2..a5f15c1 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Shape.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.shape.ShapeRetrieveParams; +import org.onebusaway.models.shape.ShapeRetrieveResponse; public class Shape { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java index 352ab02..984f293 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Stop.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.stop.StopRetrieveParams; +import org.onebusaway.models.stop.StopRetrieveResponse; public class Stop { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java index 8fb4045..893303d 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForLocation.java @@ -6,6 +6,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.models.*; +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams; +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse; public class StopsForLocation { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java index 0819576..528fb41 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsForRoute.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.stopsforroute.StopsForRouteListParams; +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse; public class StopsForRoute { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java index 36b1795..8142333 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/StopsIdsForAgency.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams; +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse; public class StopsIdsForAgency { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java index 68f7c6d..d23931f 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/Trip.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.trip.TripRetrieveParams; +import org.onebusaway.models.trip.TripRetrieveResponse; public class Trip { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java index cbd86df..cedeaef 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripDetails.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams; +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse; public class TripDetails { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java index d997a02..f39a8f8 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripForVehicle.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams; +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse; public class TripForVehicle { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java index 886ee1e..51ec025 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/TripsForRoute.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.tripsforroute.TripsForRouteListParams; +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse; public class TripsForRoute { diff --git a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java index 0d40893..0d25be4 100644 --- a/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java +++ b/onebusaway-sdk-java-example/src/main/java/org/onebusaway/example/VehiclesForAgency.java @@ -2,7 +2,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -import org.onebusaway.models.*; +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams; +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse; public class VehiclesForAgency { diff --git a/onebusaway-sdk-java/build.gradle.kts b/onebusaway-sdk-java/build.gradle.kts index 6d1a5d0..0e3ac39 100644 --- a/onebusaway-sdk-java/build.gradle.kts +++ b/onebusaway-sdk-java/build.gradle.kts @@ -6,3 +6,24 @@ plugins { dependencies { api(project(":onebusaway-sdk-java-client-okhttp")) } + +// Redefine `dokkaJavadoc` to: +// - Depend on the root project's task for merging the docs of all the projects +// - Forward that task's output to this task's output +tasks.named("dokkaJavadoc").configure { + actions.clear() + + val dokkaJavadocCollector = rootProject.tasks["dokkaJavadocCollector"] + dependsOn(dokkaJavadocCollector) + + val outputDirectory = project.layout.buildDirectory.dir("dokka/javadoc") + doLast { + copy { + from(dokkaJavadocCollector.outputs.files) + into(outputDirectory) + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } + } + + outputs.dir(outputDirectory) +} diff --git a/scripts/format b/scripts/format index c6239fa..456a69d 100755 --- a/scripts/format +++ b/scripts/format @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Running spotlessApply" -./gradlew --build-cache --parallel --no-daemon spotlessApply +./gradlew spotlessApply diff --git a/scripts/lint b/scripts/lint index 58753d0..e3a5f5e 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Build classes" -./gradlew --build-cache --parallel --no-daemon build testClasses -x test +./gradlew build testClasses -x test diff --git a/scripts/test b/scripts/test index 72ed033..6b750a7 100755 --- a/scripts/test +++ b/scripts/test @@ -53,4 +53,4 @@ else fi echo "==> Running tests" -./gradlew --build-cache --parallel --no-daemon test +./gradlew test From bc00694f7ced6aa7458386eb1f8f3ccc3f813e89 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 7 Jul 2025 23:33:45 +0000 Subject: [PATCH 11/11] release: 0.1.0-alpha.24 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 21 +++++++++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1c0bb88..380b6f9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.23" + ".": "0.1.0-alpha.24" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6abeafe..ae94241 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## 0.1.0-alpha.24 (2025-07-07) + +Full Changelog: [v0.1.0-alpha.23...v0.1.0-alpha.24](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.23...v0.1.0-alpha.24) + +### Features + +* **api:** api update ([a9266bd](https://github.com/OneBusAway/java-sdk/commit/a9266bd3053952157431e4aee9b36aae6b637164)) +* **api:** manual updates ([#74](https://github.com/OneBusAway/java-sdk/issues/74)) ([ddda17b](https://github.com/OneBusAway/java-sdk/commit/ddda17b7186ef701720740c946250b5fa902a4cc)) + + +### Chores + +* **internal:** codegen related update ([8f6f893](https://github.com/OneBusAway/java-sdk/commit/8f6f893129b9b061d933432fc8ecc36be5e5ad7f)) +* **internal:** codegen related update ([#71](https://github.com/OneBusAway/java-sdk/issues/71)) ([c5e90c0](https://github.com/OneBusAway/java-sdk/commit/c5e90c0cda29a9131fd81e60d22711794a2f0a71)) +* **internal:** codegen related update ([#73](https://github.com/OneBusAway/java-sdk/issues/73)) ([a45c6b0](https://github.com/OneBusAway/java-sdk/commit/a45c6b0bc2f45328c1365db12b9ed2fca0d85ce6)) +* **internal:** codegen related update ([#75](https://github.com/OneBusAway/java-sdk/issues/75)) ([a433a99](https://github.com/OneBusAway/java-sdk/commit/a433a99937fdc1729f36a4e7d16a8d90137758e8)) +* **internal:** codegen related update ([#76](https://github.com/OneBusAway/java-sdk/issues/76)) ([a8f595e](https://github.com/OneBusAway/java-sdk/commit/a8f595e2ee1038f8161ab784fd189d074f375d07)) +* **internal:** codegen related update ([#77](https://github.com/OneBusAway/java-sdk/issues/77)) ([14ea7b7](https://github.com/OneBusAway/java-sdk/commit/14ea7b7438268138410dca70f28807ec06f5c5b0)) +* **internal:** codegen related update ([#78](https://github.com/OneBusAway/java-sdk/issues/78)) ([51a4c8c](https://github.com/OneBusAway/java-sdk/commit/51a4c8cab3782706a773525083c4b17da4543064)) +* **internal:** update example values ([#72](https://github.com/OneBusAway/java-sdk/issues/72)) ([9f7aadf](https://github.com/OneBusAway/java-sdk/commit/9f7aadf0b9229f441f1dbfed4b64035f195c3b1e)) + ## 0.1.0-alpha.23 (2024-11-29) Full Changelog: [v0.1.0-alpha.22...v0.1.0-alpha.23](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.22...v0.1.0-alpha.23) diff --git a/README.md b/README.md index c12dcb0..a9ef60f 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.23) -[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.23/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.23) +[![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.24) +[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.24/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.24) @@ -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.23). +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.24). @@ -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.23") +implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.24") ``` ### Maven @@ -35,7 +35,7 @@ implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.23") org.onebusaway onebusaway-sdk-java - 0.1.0-alpha.23 + 0.1.0-alpha.24 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 534d0c5..a036b20 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "org.onebusaway" - version = "0.1.0-alpha.23" // x-release-please-version + version = "0.1.0-alpha.24" // x-release-please-version } subprojects {