diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..bd8e261 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1 +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libxkbcommon0 \ + ca-certificates \ + ca-certificates-java \ + make \ + curl \ + git \ + openjdk-17-jdk-headless \ + unzip \ + libc++1 \ + vim \ + && apt-get clean autoclean + +# Ensure UTF-8 encoding +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + +WORKDIR /workspace + +COPY . /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d55fc4d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + "build": { + "dockerfile": "Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..022b841 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..85f6d22 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,103 @@ +name: CI +on: + push: + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' + +jobs: + lint: + timeout-minutes: 15 + name: lint + runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run lints + run: ./scripts/lint + + build: + timeout-minutes: 15 + name: build + permissions: + contents: read + id-token: write + runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build SDK + run: ./scripts/build + + - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/open-transit-java' + id: github-oidc + uses: actions/github-script@v6 + with: + script: core.setOutput('github_token', await core.getIDToken()); + + - name: Build and upload Maven artifacts + if: github.repository == 'stainless-sdks/open-transit-java' + env: + URL: https://pkg.stainless.com/s + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + PROJECT: open-transit-java + run: ./scripts/upload-artifacts + test: + timeout-minutes: 15 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Run tests + run: ./scripts/test diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml new file mode 100644 index 0000000..c295df8 --- /dev/null +++ b/.github/workflows/publish-sonatype.yml @@ -0,0 +1,41 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to Sonatype in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/OneBusAway/java-sdk/actions/workflows/publish-sonatype.yml +name: Publish Sonatype +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Publish to Sonatype + 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" --no-configuration-cache + env: + SONATYPE_USERNAME: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + 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 new file mode 100644 index 0000000..fac0542 --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,24 @@ +name: Release Doctor +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'OneBusAway/java-sdk' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + SONATYPE_USERNAME: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.ONEBUSAWAY_SDK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + 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 }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1346e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.prism.log +.gradle +.idea +.kotlin +build/ +codegen.log +kls_database.db diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..c5407a0 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0-alpha.45" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 0000000..ad9cf70 --- /dev/null +++ b/.stats.yml @@ -0,0 +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/LICENSE b/LICENSE new file mode 100644 index 0000000..26680ba --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2026 Onebusaway SDK + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index dbf4d13..bf0bb88 100644 --- a/README.md +++ b/README.md @@ -1 +1,601 @@ -# open-transit-java \ No newline at end of file +# Onebusaway SDK Java API Library + + + +[![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.45) +[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.45/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.45) + + + +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.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.45). + + + +## Installation + + + +### Gradle + +```kotlin +implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.45") +``` + +### Maven + +```xml + + org.onebusaway + onebusaway-sdk-java + 0.1.0-alpha.45 + +``` + + + +## Requirements + +This library requires Java 8 or later. + +## Usage + +```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 `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties +// Or 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 system properties or environment variables: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +// Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties +// Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); +``` + +Or manually: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + .apiKey("My API Key") + .build(); +``` + +Or using a combination of the two approaches: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + // Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties + // Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables + .fromEnv() + .apiKey("My API Key") + .build(); +``` + +See this table for the available options: + +| Setter | System property | Environment variable | Required | Default value | +| --------- | -------------------------------- | ------------------------- | -------- | ----------------------------------------- | +| `apiKey` | `onebusawaysdk.onebusawayApiKey` | `ONEBUSAWAY_API_KEY` | true | - | +| `baseUrl` | `onebusawaysdk.baseUrl` | `ONEBUSAWAY_SDK_BASE_URL` | true | `"https://api.pugetsound.onebusaway.org"` | + +System properties take precedence over environment variables. + +> [!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. + +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: + +```java +import org.onebusaway.client.OnebusawaySdkClient; + +OnebusawaySdkClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + +## Requests and responses + +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. + +For example, `client.currentTime().retrieve(...)` should be called with an instance of `CurrentTimeRetrieveParams`, and it will return an instance of `CurrentTimeRetrieveResponse`. + +## 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. + +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. + +Because each class is immutable, builder modification will _never_ affect already built class instances. + +## Asynchronous execution + +The default client is synchronous. To switch to asynchronous execution, call the `async()` method: + +```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; + +// Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties +// Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); + +CompletableFuture currentTime = client.async().currentTime().retrieve(); +``` + +Or create an asynchronous client from the beginning: + +```java +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; + +// Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties +// Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +OnebusawaySdkClientAsync client = OnebusawaySdkOkHttpClientAsync.fromEnv(); + +CompletableFuture currentTime = client.currentTime().retrieve(); +``` + +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. + +## Raw responses + +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. + +To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: + +```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; + +HttpResponseFor currentTime = client.currentTime().withRawResponse().retrieve(); + +int statusCode = currentTime.statusCode(); +Headers headers = currentTime.headers(); +``` + +You can still deserialize the response into an instance of a Java class if needed: + +```java +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; + +CurrentTimeRetrieveResponse parsedCurrentTime = currentTime.parse(); +``` + +## Error handling + +The SDK throws custom unchecked exception types: + +- [`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. + +- [`OnebusawaySdkRetryableException`](onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkRetryableException.kt): Generic error indicating a failure that could be retried by the client. + +- [`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 +``` + +Or to `debug` for more verbose logging: + +```sh +export ONEBUSAWAY_SDK_LOG=debug +``` + +## ProGuard and R8 + +Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `onebusaway-sdk-java-core` is published with a [configuration file](onebusaway-sdk-java-core/src/main/resources/META-INF/proguard/onebusaway-sdk-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). + +ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary. + +## 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. + +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). + +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). + +> [!CAUTION] +> We make no guarantee that the SDK works correctly when the Jackson version check is disabled. + +## Network options + +### Retries + +The SDK automatically retries 2 times by default, with a short exponential backoff between requests. + +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 request. + +To set a custom number of retries, configure the client using the `maxRetries` method: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + .fromEnv() + .maxRetries(4) + .build(); +``` + +### Timeouts + +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; +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + .fromEnv() + .timeout(Duration.ofSeconds(30)) + .build(); +``` + +### Proxies + +To route requests through a proxy, configure the client using the `proxy` method: + +```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( + Proxy.Type.HTTP, new InetSocketAddress( + "https://example.com", 8080 + ) + )) + .build(); +``` + +### HTTPS + +> [!NOTE] +> Most applications should not call these methods, and instead use the system defaults. The defaults include +> special optimizations that can be lost if the implementations are modified. + +To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods: + +```java +import org.onebusaway.client.OnebusawaySdkClient; +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; + +OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() + .fromEnv() + // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa. + .sslSocketFactory(yourSSLSocketFactory) + .trustManager(yourTrustManager) + .hostnameVerifier(yourHostnameVerifier) + .build(); +``` + +### 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. + +To use a customized `OkHttpClient`: + +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 + +### Completely custom HTTP client + +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.currenttime.CurrentTimeRetrieveParams; + +CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build(); +``` + +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. + +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: + +```java +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; + +CurrentTimeRetrieveParams params = CurrentTimeRetrieveParams.builder().build(); +``` + +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: + +```java +import java.util.List; +import java.util.Map; +import org.onebusaway.core.JsonValue; + +// 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 + ) +)); +``` + +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. + +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: + +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. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..8b844a0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## Reporting Security Issues + +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@stainless.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Onebusaway SDK, please follow the respective company's security reporting guidelines. + +### Onebusaway SDK Terms and Policies + +Please contact info@onebusaway.org for any questions or concerns regarding the security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 0000000..3a6a7b4 --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${SONATYPE_USERNAME}" ]; then + errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${SONATYPE_PASSWORD}" ]; then + errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_KEY}" ]; then + errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_PASSWORD}" ]; then + errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..a0cf580 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,36 @@ +plugins { + id("org.jetbrains.dokka") version "2.0.0" +} + +repositories { + mavenCentral() +} + +allprojects { + group = "org.onebusaway" + version = "0.1.0-alpha.45" // x-release-please-version +} + +subprojects { + // These are populated with dependencies by `buildSrc` scripts. + tasks.register("format") { + group = "Verification" + description = "Formats all source files." + } + tasks.register("lint") { + group = "Verification" + description = "Verifies all source files are formatted." + } + apply(plugin = "org.jetbrains.dokka") +} + +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 new file mode 100644 index 0000000..c6dc92e --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + `kotlin-dsl` + kotlin("jvm") version "1.9.20" + id("com.vanniktech.maven.publish") version "0.28.0" +} + +repositories { + gradlePluginPortal() + mavenCentral() +} + +dependencies { + 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 new file mode 100644 index 0000000..70fc33f --- /dev/null +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts @@ -0,0 +1,127 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + +plugins { + `java-library` +} + +repositories { + mavenCentral() +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.withType().configureEach { + options.compilerArgs.add("-Werror") + options.release.set(8) +} + +tasks.named("jar") { + manifest { + attributes(mapOf( + "Implementation-Title" to project.name, + "Implementation-Version" to project.version + )) + } +} + +tasks.withType().configureEach { + useJUnitPlatform() + + // Run tests in parallel to some degree. + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 + + testLogging { + exceptionFormat = TestExceptionFormat.FULL + } +} + +val palantir by configurations.creating +dependencies { + palantir("com.palantir.javaformat:palantir-java-format:2.73.0") +} + +fun registerPalantir( + name: String, + description: String, +) { + val javaName = "${name}Java" + tasks.register(javaName) { + group = "Verification" + this.description = description + + classpath = palantir + mainClass = "com.palantir.javaformat.java.Main" + + // Avoid an `IllegalAccessError` on Java 9+. + jvmArgs( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ) + + // Use paths relative to the current module. + val argumentFile = + project.layout.buildDirectory.file("palantir-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("palantir-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val javaFiles = project.fileTree("src") { include("**/*.java") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file. + onlyIf { javaFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(javaFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--palantir\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } else { + // `--dry-run` and `--replace` (for in-place formatting) are mutually exclusive. + argumentFile.appendText("--replace\n") + } + + // Write the modified files to the argument file. + javaFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { javaFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(javaName)) + } +} + +registerPalantir(name = "format", description = "Formats all Java source files.") +registerPalantir(name = "lint", description = "Verifies all Java source files are formatted.") diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts new file mode 100644 index 0000000..5fab5a6 --- /dev/null +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts @@ -0,0 +1,106 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion + +plugins { + id("onebusaway-sdk.java") + kotlin("jvm") +} + +repositories { + mavenCentral() +} + +kotlin { + jvmToolchain { + 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" + } +} + +tasks.withType().configureEach { + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") +} + +val ktfmt by configurations.creating +dependencies { + ktfmt("com.facebook:ktfmt:0.56") +} + +fun registerKtfmt( + name: String, + description: String, +) { + val kotlinName = "${name}Kotlin" + tasks.register(kotlinName) { + group = "Verification" + this.description = description + + classpath = ktfmt + mainClass = "com.facebook.ktfmt.cli.Main" + + // Use paths relative to the current module. + val argumentFile = project.layout.buildDirectory.file("ktfmt-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("ktfmt-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val kotlinFiles = project.fileTree("src") { include("**/*.kt") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file (otherwise Ktfmt will fail). + onlyIf { kotlinFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(kotlinFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--kotlinlang-style\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } + + // Write the modified files to the argument file. + kotlinFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { kotlinFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(kotlinName)) + } +} + +registerKtfmt(name = "format", description = "Formats all Kotlin source files.") +registerKtfmt(name = "lint", description = "Verifies all Kotlin source files are formatted.") diff --git a/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts b/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts new file mode 100644 index 0000000..18d7a04 --- /dev/null +++ b/buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts @@ -0,0 +1,72 @@ +import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinJvm +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.SonatypeHost + +plugins { + id("com.vanniktech.maven.publish") +} + +publishing { + repositories { + if (project.hasProperty("publishLocal")) { + maven { + name = "LocalFileSystem" + url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo") + } + } + } +} + +repositories { + gradlePluginPortal() + mavenCentral() +} + +extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY") +extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID") +extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD") + +configure { + if (!project.hasProperty("publishLocal")) { + signAllPublications() + 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") + description.set("The OneBusAway REST API. For use with servers like\nhttps://api.pugetsound.onebusaway.org") + url.set("https://developer.onebusaway.org") + + licenses { + license { + name.set("Apache-2.0") + } + } + + developers { + developer { + name.set("Onebusaway SDK") + email.set("info@onebusaway.org") + } + } + + scm { + connection.set("scm:git:git://github.com/OneBusAway/java-sdk.git") + developerConnection.set("scm:git:git://github.com/OneBusAway/java-sdk.git") + url.set("https://github.com/OneBusAway/java-sdk") + } + } +} + +tasks.withType().configureEach { + isZip64 = true +} diff --git a/examples/.keep b/examples/.keep new file mode 100644 index 0000000..d8c73e9 --- /dev/null +++ b/examples/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store example files demonstrating usage of this SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..6680f9c --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +org.gradle.caching=true +org.gradle.configuration-cache=true +org.gradle.parallel=true +org.gradle.daemon=false +# These options improve our compilation and test performance. They are inherited by the Kotlin daemon. +org.gradle.jvmargs=\ + -Xms2g \ + -Xmx8g \ + -XX:+UseParallelGC \ + -XX:InitialCodeCacheSize=256m \ + -XX:ReservedCodeCacheSize=1G \ + -XX:MetaspaceSize=512m \ + -XX:MaxMetaspaceSize=2G \ + -XX:TieredStopAtLevel=1 \ + -XX:GCTimeRatio=4 \ + -XX:CICompilerCount=4 \ + -XX:+OptimizeStringConcat \ + -XX:+UseStringDeduplication diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..a4b76b9 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..cea7a79 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..f3b75f3 --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# 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/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# 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 -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 + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..9d21a21 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@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 ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/onebusaway-sdk-java-client-okhttp/build.gradle.kts b/onebusaway-sdk-java-client-okhttp/build.gradle.kts new file mode 100644 index 0000000..ecc7ea4 --- /dev/null +++ b/onebusaway-sdk-java-client-okhttp/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + id("onebusaway-sdk.kotlin") + id("onebusaway-sdk.publish") +} + +dependencies { + api(project(":onebusaway-sdk-java-core")) + + implementation("com.squareup.okhttp3:okhttp:4.12.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") + + testImplementation(kotlin("test")) + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") +} 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 new file mode 100644 index 0000000..839b3c6 --- /dev/null +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt @@ -0,0 +1,259 @@ +package org.onebusaway.client.okhttp + +import java.io.IOException +import java.io.InputStream +import java.net.Proxy +import java.time.Duration +import java.util.concurrent.CancellationException +import java.util.concurrent.CompletableFuture +import java.util.concurrent.ExecutorService +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import okhttp3.Call +import okhttp3.Callback +import okhttp3.Dispatcher +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaType +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.Timeout +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.HttpClient +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpRequestBody +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.errors.OnebusawaySdkIoException + +class OkHttpClient +private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val call = newCall(request, requestOptions) + + return try { + call.execute().toResponse() + } catch (e: IOException) { + throw OnebusawaySdkIoException("Request failed", e) + } finally { + request.body?.close() + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val future = CompletableFuture() + + val call = newCall(request, requestOptions) + call.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)) + } + } + ) + + future.whenComplete { _, e -> + if (e is CancellationException) { + call.cancel() + } + request.body?.close() + } + + return future + } + + override fun close() { + okHttpClient.dispatcher.executorService.shutdown() + okHttpClient.connectionPool.evictAll() + okHttpClient.cache?.close() + } + + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + 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)) + } + + requestOptions.timeout?.let { + clientBuilder + .connectTimeout(it.connect()) + .readTimeout(it.read()) + .writeTimeout(it.write()) + .callTimeout(it.request()) + } + + val client = clientBuilder.build() + return client.newCall(request.toRequest(client)) + } + + private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { + var body: RequestBody? = body?.toRequestBody() + if (body == null && requiresBody(method)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.names().forEach { name -> + headers.values(name).forEach { builder.addHeader(name, it) } + } + + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.addHeader( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.addHeader( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + + return builder.build() + } + + /** `OkHttpClient` always requires a request body for some methods. */ + private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + + private fun HttpRequest.toUrl(): String { + val builder = baseUrl.toHttpUrl().newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } + + return builder.toString() + } + + private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? = mediaType + + override fun contentLength(): Long = length + + override fun isOneShot(): Boolean = !repeatable() + + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) + } + } + + private fun Response.toResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int = code + + override fun headers(): Headers = headers + + override fun body(): InputStream = body!!.byteStream() + + override fun close() = body!!.close() + } + } + + private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() + } + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var timeout: Timeout = Timeout.default() + private var proxy: Proxy? = null + private var dispatcherExecutorService: ExecutorService? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + 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 dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + fun build(): OkHttpClient = + OkHttpClient( + okhttp3.OkHttpClient.Builder() + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) + .proxy(proxy) + .apply { + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + + val sslSocketFactory = sslSocketFactory + val trustManager = trustManager + if (sslSocketFactory != null && trustManager != null) { + sslSocketFactory(sslSocketFactory, trustManager) + } else { + check((sslSocketFactory != null) == (trustManager != null)) { + "Both or none of `sslSocketFactory` and `trustManager` must be set, but only one was set" + } + } + + hostnameVerifier?.let(::hostnameVerifier) + } + .build() + .apply { + // We usually make all our requests to the same host so it makes sense to + // raise the per-host limit to the overall limit. + dispatcher.maxRequestsPerHost = dispatcher.maxRequests + } + ) + } +} 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 new file mode 100644 index 0000000..1399e4c --- /dev/null +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.client.okhttp + +import com.fasterxml.jackson.databind.json.JsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import java.util.Optional +import java.util.concurrent.ExecutorService +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.client.OnebusawaySdkClient +import org.onebusaway.client.OnebusawaySdkClientImpl +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.Sleeper +import org.onebusaway.core.Timeout +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.HttpClient +import org.onebusaway.core.http.QueryParams +import org.onebusaway.core.jsonMapper + +/** + * A class that allows building an instance of [OnebusawaySdkClient] with [OkHttpClient] as the + * underlying [HttpClient]. + */ +class OnebusawaySdkOkHttpClient private constructor() { + + companion object { + + /** Returns a mutable builder for constructing an instance of [OnebusawaySdkClient]. */ + @JvmStatic fun builder() = Builder() + + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + @JvmStatic fun fromEnv(): OnebusawaySdkClient = builder().fromEnv().build() + } + + /** A builder for [OnebusawaySdkOkHttpClient]. */ + class Builder internal constructor() { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) + + /** + * 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) + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [org.onebusaway.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.pugetsound.onebusaway.org`. + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.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) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * 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 request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + 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() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) + .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 new file mode 100644 index 0000000..9a4f625 --- /dev/null +++ b/onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.client.okhttp + +import com.fasterxml.jackson.databind.json.JsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import java.util.Optional +import java.util.concurrent.ExecutorService +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.client.OnebusawaySdkClientAsync +import org.onebusaway.client.OnebusawaySdkClientAsyncImpl +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.Sleeper +import org.onebusaway.core.Timeout +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.HttpClient +import org.onebusaway.core.http.QueryParams +import org.onebusaway.core.jsonMapper + +/** + * A class that allows building an instance of [OnebusawaySdkClientAsync] with [OkHttpClient] as the + * underlying [HttpClient]. + */ +class OnebusawaySdkOkHttpClientAsync private constructor() { + + companion object { + + /** Returns a mutable builder for constructing an instance of [OnebusawaySdkClientAsync]. */ + @JvmStatic fun builder() = Builder() + + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + @JvmStatic fun fromEnv(): OnebusawaySdkClientAsync = builder().fromEnv().build() + } + + /** A builder for [OnebusawaySdkOkHttpClientAsync]. */ + class Builder internal constructor() { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) + + /** + * 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) + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [org.onebusaway.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.pugetsound.onebusaway.org`. + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.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) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * 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 request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + 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() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) + .build() + ) + } +} diff --git a/onebusaway-sdk-java-client-okhttp/src/test/kotlin/org/onebusaway/client/okhttp/OkHttpClientTest.kt b/onebusaway-sdk-java-client-okhttp/src/test/kotlin/org/onebusaway/client/okhttp/OkHttpClientTest.kt new file mode 100644 index 0000000..5b02533 --- /dev/null +++ b/onebusaway-sdk-java-client-okhttp/src/test/kotlin/org/onebusaway/client/okhttp/OkHttpClientTest.kt @@ -0,0 +1,44 @@ +package org.onebusaway.client.okhttp + +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class OkHttpClientTest { + + private lateinit var baseUrl: String + private lateinit var httpClient: OkHttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + httpClient = OkHttpClient.builder().build() + } + + @Test + fun executeAsync_whenFutureCancelled_cancelsUnderlyingCall() { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val responseFuture = + httpClient.executeAsync( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build() + ) + val call = httpClient.okHttpClient.dispatcher.runningCalls().single() + + responseFuture.cancel(false) + + // Should have cancelled the underlying call + assertThat(call.isCanceled()).isTrue() + } +} diff --git a/onebusaway-sdk-java-core/build.gradle.kts b/onebusaway-sdk-java-core/build.gradle.kts new file mode 100644 index 0000000..c020c89 --- /dev/null +++ b/onebusaway-sdk-java-core/build.gradle.kts @@ -0,0 +1,41 @@ +plugins { + id("onebusaway-sdk.kotlin") + 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.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.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") + + testImplementation(kotlin("test")) + 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.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 new file mode 100644 index 0000000..5706000 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.client + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.services.blocking.AgenciesWithCoverageService +import org.onebusaway.services.blocking.AgencyService +import org.onebusaway.services.blocking.ArrivalAndDepartureService +import org.onebusaway.services.blocking.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 + +/** + * 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 + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OnebusawaySdkClient + + fun agenciesWithCoverage(): AgenciesWithCoverageService + + fun agency(): AgencyService + + fun vehiclesForAgency(): VehiclesForAgencyService + + fun config(): ConfigService + + fun currentTime(): CurrentTimeService + + fun stopsForLocation(): StopsForLocationService + + fun stopsForRoute(): StopsForRouteService + + fun stopsForAgency(): StopsForAgencyService + + fun stop(): StopService + + fun stopIdsForAgency(): StopIdsForAgencyService + + fun scheduleForStop(): ScheduleForStopService + + fun route(): RouteService + + fun routeIdsForAgency(): RouteIdsForAgencyService + + fun routesForLocation(): RoutesForLocationService + + fun routesForAgency(): RoutesForAgencyService + + fun scheduleForRoute(): ScheduleForRouteService + + fun arrivalAndDeparture(): ArrivalAndDepartureService + + fun trip(): TripService + + fun tripsForLocation(): TripsForLocationService + + fun tripDetails(): TripDetailService + + fun tripForVehicle(): TripForVehicleService + + fun tripsForRoute(): TripsForRouteService + + fun reportProblemWithStop(): ReportProblemWithStopService + + fun reportProblemWithTrip(): ReportProblemWithTripService + + fun searchForStop(): SearchForStopService + + fun searchForRoute(): SearchForRouteService + + 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() + + /** + * A view of [OnebusawaySdkClient] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OnebusawaySdkClient.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 new file mode 100644 index 0000000..ddd6cf9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.client + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync +import org.onebusaway.services.async.AgencyServiceAsync +import org.onebusaway.services.async.ArrivalAndDepartureServiceAsync +import org.onebusaway.services.async.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 + +/** + * 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 + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): OnebusawaySdkClientAsync + + fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync + + fun agency(): AgencyServiceAsync + + fun vehiclesForAgency(): VehiclesForAgencyServiceAsync + + fun config(): ConfigServiceAsync + + fun currentTime(): CurrentTimeServiceAsync + + fun stopsForLocation(): StopsForLocationServiceAsync + + fun stopsForRoute(): StopsForRouteServiceAsync + + fun stopsForAgency(): StopsForAgencyServiceAsync + + fun stop(): StopServiceAsync + + fun stopIdsForAgency(): StopIdsForAgencyServiceAsync + + fun scheduleForStop(): ScheduleForStopServiceAsync + + fun route(): RouteServiceAsync + + fun routeIdsForAgency(): RouteIdsForAgencyServiceAsync + + fun routesForLocation(): RoutesForLocationServiceAsync + + fun routesForAgency(): RoutesForAgencyServiceAsync + + fun scheduleForRoute(): ScheduleForRouteServiceAsync + + fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync + + fun trip(): TripServiceAsync + + fun tripsForLocation(): TripsForLocationServiceAsync + + fun tripDetails(): TripDetailServiceAsync + + fun tripForVehicle(): TripForVehicleServiceAsync + + fun tripsForRoute(): TripsForRouteServiceAsync + + fun reportProblemWithStop(): ReportProblemWithStopServiceAsync + + fun reportProblemWithTrip(): ReportProblemWithTripServiceAsync + + fun searchForStop(): SearchForStopServiceAsync + + fun searchForRoute(): SearchForRouteServiceAsync + + 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() + + /** + * A view of [OnebusawaySdkClientAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): OnebusawaySdkClientAsync.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 new file mode 100644 index 0000000..78327e2 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt @@ -0,0 +1,449 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.client + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.getPackageVersion +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(private val clientOptions: ClientOptions) : + OnebusawaySdkClientAsync { + + private val clientOptionsWithUserAgent = + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // 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) + } + + private val agency: AgencyServiceAsync by lazy { + AgencyServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val vehiclesForAgency: VehiclesForAgencyServiceAsync by lazy { + VehiclesForAgencyServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val config: ConfigServiceAsync by lazy { + ConfigServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val currentTime: CurrentTimeServiceAsync by lazy { + CurrentTimeServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val stopsForLocation: StopsForLocationServiceAsync by lazy { + StopsForLocationServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val stopsForRoute: StopsForRouteServiceAsync by lazy { + StopsForRouteServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val stopsForAgency: StopsForAgencyServiceAsync by lazy { + StopsForAgencyServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val stop: StopServiceAsync by lazy { StopServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val stopIdsForAgency: StopIdsForAgencyServiceAsync by lazy { + StopIdsForAgencyServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val scheduleForStop: ScheduleForStopServiceAsync by lazy { + ScheduleForStopServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val route: RouteServiceAsync by lazy { + RouteServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val routeIdsForAgency: RouteIdsForAgencyServiceAsync by lazy { + RouteIdsForAgencyServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val routesForLocation: RoutesForLocationServiceAsync by lazy { + RoutesForLocationServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val routesForAgency: RoutesForAgencyServiceAsync by lazy { + RoutesForAgencyServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val scheduleForRoute: ScheduleForRouteServiceAsync by lazy { + ScheduleForRouteServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val arrivalAndDeparture: ArrivalAndDepartureServiceAsync by lazy { + ArrivalAndDepartureServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val trip: TripServiceAsync by lazy { TripServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val tripsForLocation: TripsForLocationServiceAsync by lazy { + TripsForLocationServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val tripDetails: TripDetailServiceAsync by lazy { + TripDetailServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val tripForVehicle: TripForVehicleServiceAsync by lazy { + TripForVehicleServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val tripsForRoute: TripsForRouteServiceAsync by lazy { + TripsForRouteServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val reportProblemWithStop: ReportProblemWithStopServiceAsync by lazy { + ReportProblemWithStopServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val reportProblemWithTrip: ReportProblemWithTripServiceAsync by lazy { + ReportProblemWithTripServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val searchForStop: SearchForStopServiceAsync by lazy { + SearchForStopServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val searchForRoute: SearchForRouteServiceAsync by lazy { + SearchForRouteServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val block: BlockServiceAsync by lazy { + BlockServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val shape: ShapeServiceAsync by lazy { + ShapeServiceAsyncImpl(clientOptionsWithUserAgent) + } + + override fun sync(): OnebusawaySdkClient = sync + + override fun withRawResponse(): OnebusawaySdkClientAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): OnebusawaySdkClientAsync = + OnebusawaySdkClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync = agenciesWithCoverage + + override fun agency(): AgencyServiceAsync = agency + + override fun vehiclesForAgency(): VehiclesForAgencyServiceAsync = vehiclesForAgency + + override fun config(): ConfigServiceAsync = config + + override fun currentTime(): CurrentTimeServiceAsync = currentTime + + override fun stopsForLocation(): StopsForLocationServiceAsync = stopsForLocation + + override fun stopsForRoute(): StopsForRouteServiceAsync = stopsForRoute + + override fun stopsForAgency(): StopsForAgencyServiceAsync = stopsForAgency + + override fun stop(): StopServiceAsync = stop + + override fun stopIdsForAgency(): StopIdsForAgencyServiceAsync = stopIdsForAgency + + override fun scheduleForStop(): ScheduleForStopServiceAsync = scheduleForStop + + override fun route(): RouteServiceAsync = route + + override fun routeIdsForAgency(): RouteIdsForAgencyServiceAsync = routeIdsForAgency + + override fun routesForLocation(): RoutesForLocationServiceAsync = routesForLocation + + override fun routesForAgency(): RoutesForAgencyServiceAsync = routesForAgency + + override fun scheduleForRoute(): ScheduleForRouteServiceAsync = scheduleForRoute + + override fun arrivalAndDeparture(): ArrivalAndDepartureServiceAsync = arrivalAndDeparture + + override fun trip(): TripServiceAsync = trip + + override fun tripsForLocation(): TripsForLocationServiceAsync = tripsForLocation + + override fun tripDetails(): TripDetailServiceAsync = tripDetails + + override fun tripForVehicle(): TripForVehicleServiceAsync = tripForVehicle + + override fun tripsForRoute(): TripsForRouteServiceAsync = tripsForRoute + + override fun reportProblemWithStop(): ReportProblemWithStopServiceAsync = reportProblemWithStop + + override fun reportProblemWithTrip(): ReportProblemWithTripServiceAsync = reportProblemWithTrip + + override fun searchForStop(): SearchForStopServiceAsync = searchForStop + + override fun searchForRoute(): SearchForRouteServiceAsync = searchForRoute + + override fun block(): BlockServiceAsync = block + + override fun shape(): ShapeServiceAsync = shape + + override fun close() = clientOptions.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 withOptions( + modifier: Consumer + ): OnebusawaySdkClientAsync.WithRawResponse = + OnebusawaySdkClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + 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 new file mode 100644 index 0000000..d4e4146 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt @@ -0,0 +1,432 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.client + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.getPackageVersion +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(private val clientOptions: ClientOptions) : OnebusawaySdkClient { + + private val clientOptionsWithUserAgent = + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. + private val async: OnebusawaySdkClientAsync by lazy { + OnebusawaySdkClientAsyncImpl(clientOptions) + } + + private val withRawResponse: OnebusawaySdkClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val agenciesWithCoverage: AgenciesWithCoverageService by lazy { + AgenciesWithCoverageServiceImpl(clientOptionsWithUserAgent) + } + + private val agency: AgencyService by lazy { AgencyServiceImpl(clientOptionsWithUserAgent) } + + private val vehiclesForAgency: VehiclesForAgencyService by lazy { + VehiclesForAgencyServiceImpl(clientOptionsWithUserAgent) + } + + private val config: ConfigService by lazy { ConfigServiceImpl(clientOptionsWithUserAgent) } + + private val currentTime: CurrentTimeService by lazy { + CurrentTimeServiceImpl(clientOptionsWithUserAgent) + } + + private val stopsForLocation: StopsForLocationService by lazy { + StopsForLocationServiceImpl(clientOptionsWithUserAgent) + } + + private val stopsForRoute: StopsForRouteService by lazy { + StopsForRouteServiceImpl(clientOptionsWithUserAgent) + } + + private val stopsForAgency: StopsForAgencyService by lazy { + StopsForAgencyServiceImpl(clientOptionsWithUserAgent) + } + + private val stop: StopService by lazy { StopServiceImpl(clientOptionsWithUserAgent) } + + private val stopIdsForAgency: StopIdsForAgencyService by lazy { + StopIdsForAgencyServiceImpl(clientOptionsWithUserAgent) + } + + private val scheduleForStop: ScheduleForStopService by lazy { + ScheduleForStopServiceImpl(clientOptionsWithUserAgent) + } + + private val route: RouteService by lazy { RouteServiceImpl(clientOptionsWithUserAgent) } + + private val routeIdsForAgency: RouteIdsForAgencyService by lazy { + RouteIdsForAgencyServiceImpl(clientOptionsWithUserAgent) + } + + private val routesForLocation: RoutesForLocationService by lazy { + RoutesForLocationServiceImpl(clientOptionsWithUserAgent) + } + + private val routesForAgency: RoutesForAgencyService by lazy { + RoutesForAgencyServiceImpl(clientOptionsWithUserAgent) + } + + private val scheduleForRoute: ScheduleForRouteService by lazy { + ScheduleForRouteServiceImpl(clientOptionsWithUserAgent) + } + + private val arrivalAndDeparture: ArrivalAndDepartureService by lazy { + ArrivalAndDepartureServiceImpl(clientOptionsWithUserAgent) + } + + private val trip: TripService by lazy { TripServiceImpl(clientOptionsWithUserAgent) } + + private val tripsForLocation: TripsForLocationService by lazy { + TripsForLocationServiceImpl(clientOptionsWithUserAgent) + } + + private val tripDetails: TripDetailService by lazy { + TripDetailServiceImpl(clientOptionsWithUserAgent) + } + + private val tripForVehicle: TripForVehicleService by lazy { + TripForVehicleServiceImpl(clientOptionsWithUserAgent) + } + + private val tripsForRoute: TripsForRouteService by lazy { + TripsForRouteServiceImpl(clientOptionsWithUserAgent) + } + + private val reportProblemWithStop: ReportProblemWithStopService by lazy { + ReportProblemWithStopServiceImpl(clientOptionsWithUserAgent) + } + + private val reportProblemWithTrip: ReportProblemWithTripService by lazy { + ReportProblemWithTripServiceImpl(clientOptionsWithUserAgent) + } + + private val searchForStop: SearchForStopService by lazy { + SearchForStopServiceImpl(clientOptionsWithUserAgent) + } + + private val searchForRoute: SearchForRouteService by lazy { + SearchForRouteServiceImpl(clientOptionsWithUserAgent) + } + + private val block: BlockService by lazy { BlockServiceImpl(clientOptionsWithUserAgent) } + + private val shape: ShapeService by lazy { ShapeServiceImpl(clientOptionsWithUserAgent) } + + override fun async(): OnebusawaySdkClientAsync = async + + override fun withRawResponse(): OnebusawaySdkClient.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): OnebusawaySdkClient = + OnebusawaySdkClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun agenciesWithCoverage(): AgenciesWithCoverageService = agenciesWithCoverage + + override fun agency(): AgencyService = agency + + override fun vehiclesForAgency(): VehiclesForAgencyService = vehiclesForAgency + + override fun config(): ConfigService = config + + override fun currentTime(): CurrentTimeService = currentTime + + override fun stopsForLocation(): StopsForLocationService = stopsForLocation + + override fun stopsForRoute(): StopsForRouteService = stopsForRoute + + override fun stopsForAgency(): StopsForAgencyService = stopsForAgency + + override fun stop(): StopService = stop + + override fun stopIdsForAgency(): StopIdsForAgencyService = stopIdsForAgency + + override fun scheduleForStop(): ScheduleForStopService = scheduleForStop + + override fun route(): RouteService = route + + override fun routeIdsForAgency(): RouteIdsForAgencyService = routeIdsForAgency + + override fun routesForLocation(): RoutesForLocationService = routesForLocation + + override fun routesForAgency(): RoutesForAgencyService = routesForAgency + + override fun scheduleForRoute(): ScheduleForRouteService = scheduleForRoute + + override fun arrivalAndDeparture(): ArrivalAndDepartureService = arrivalAndDeparture + + override fun trip(): TripService = trip + + override fun tripsForLocation(): TripsForLocationService = tripsForLocation + + override fun tripDetails(): TripDetailService = tripDetails + + override fun tripForVehicle(): TripForVehicleService = tripForVehicle + + override fun tripsForRoute(): TripsForRouteService = tripsForRoute + + override fun reportProblemWithStop(): ReportProblemWithStopService = reportProblemWithStop + + override fun reportProblemWithTrip(): ReportProblemWithTripService = reportProblemWithTrip + + override fun searchForStop(): SearchForStopService = searchForStop + + override fun searchForRoute(): SearchForRouteService = searchForRoute + + override fun block(): BlockService = block + + override fun shape(): ShapeService = shape + + override fun close() = clientOptions.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 withOptions( + modifier: Consumer + ): OnebusawaySdkClient.WithRawResponse = + OnebusawaySdkClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + 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 new file mode 100644 index 0000000..e2902a3 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseDeserializer.kt @@ -0,0 +1,44 @@ +package org.onebusaway.core + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +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.JsonNode +import com.fasterxml.jackson.databind.deser.ContextualDeserializer +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import kotlin.reflect.KClass + +abstract class BaseDeserializer(type: KClass) : + StdDeserializer(type.java), ContextualDeserializer { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer { + return this + } + + override fun deserialize(parser: JsonParser, context: DeserializationContext): T { + return parser.codec.deserialize(parser.readValueAsTree()) + } + + protected abstract fun ObjectCodec.deserialize(node: JsonNode): T + + 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): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { + null + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseSerializer.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseSerializer.kt new file mode 100644 index 0000000..9d73a96 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/BaseSerializer.kt @@ -0,0 +1,6 @@ +package org.onebusaway.core + +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import kotlin.reflect.KClass + +abstract class BaseSerializer(type: KClass) : StdSerializer(type.java) 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..8ec084c --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Check.kt @@ -0,0 +1,96 @@ +@file:JvmName("Check") + +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 { + 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}" + } + } + +@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 new file mode 100644 index 0000000..34d4b8b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt @@ -0,0 +1,450 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core + +import com.fasterxml.jackson.databind.json.JsonMapper +import java.time.Clock +import java.time.Duration +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.HttpClient +import org.onebusaway.core.http.PhantomReachableClosingHttpClient +import org.onebusaway.core.http.QueryParams +import org.onebusaway.core.http.RetryingHttpClient + +/** A class representing the SDK client configuration. */ +class ClientOptions +private constructor( + private val originalHttpClient: HttpClient, + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `onebusaway-sdk-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ + @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * 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. + */ + @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [org.onebusaway.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. + */ + @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + @get:JvmName("sleeper") val sleeper: Sleeper, + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + @get:JvmName("clock") val clock: Clock, + private val baseUrl: String?, + /** Headers to send with the request. */ + @get:JvmName("headers") val headers: Headers, + /** Query params to send with the request. */ + @get:JvmName("queryParams") val queryParams: QueryParams, + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + @get:JvmName("responseValidation") val responseValidation: Boolean, + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + @get:JvmName("timeout") val timeout: Timeout, + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * 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 request. + * + * Defaults to 2. + */ + @get:JvmName("maxRetries") val maxRetries: Int, + @get:JvmName("apiKey") val apiKey: String, +) { + + init { + if (checkJacksonVersionCompatibility) { + checkJacksonVersionCompatibility() + } + } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.pugetsound.onebusaway.org`. + */ + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + + 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() + + /** + * Returns options configured using system properties and environment variables. + * + * @see Builder.fromEnv + */ + @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() + } + + /** A builder for [ClientOptions]. */ + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var checkJacksonVersionCompatibility: Boolean = true + private var jsonMapper: JsonMapper = jsonMapper() + private var sleeper: Sleeper? = null + private var clock: Clock = Clock.systemUTC() + private var baseUrl: String? = null + 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 + sleeper = clientOptions.sleeper + 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 + } + + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `onebusaway-sdk-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } + + /** + * 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 { + this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [org.onebusaway.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { this.clock = clock } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.pugetsound.onebusaway.org`. + */ + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { 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()) + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * 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 request. + * + * Defaults to 2. + */ + 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) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + 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 { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + 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() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + + fun timeout(): Timeout = timeout + + /** + * Updates configuration using system properties and environment variables. + * + * See this table for the available options: + * + * |Setter |System property |Environment variable |Required|Default value | + * |---------|--------------------------------|-------------------------|--------|-----------------------------------------| + * |`apiKey` |`onebusawaysdk.onebusawayApiKey`|`ONEBUSAWAY_API_KEY` |true |- | + * |`baseUrl`|`onebusawaysdk.baseUrl` |`ONEBUSAWAY_SDK_BASE_URL`|true |`"https://api.pugetsound.onebusaway.org"`| + * + * System properties take precedence over environment variables. + */ + fun fromEnv() = apply { + (System.getProperty("onebusawaysdk.baseUrl") + ?: System.getenv("ONEBUSAWAY_SDK_BASE_URL")) + ?.let { baseUrl(it) } + (System.getProperty("onebusawaysdk.onebusawayApiKey") + ?: 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 sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) + val apiKey = checkRequired("apiKey", apiKey) + + 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()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime", "JRE") + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + apiKey.let { + if (!it.isEmpty()) { + queryParams.put("key", it) + } + } + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) + + return ClientOptions( + httpClient, + RetryingHttpClient.builder() + .httpClient(httpClient) + .sleeper(sleeper) + .clock(clock) + .maxRetries(maxRetries) + .build(), + checkJacksonVersionCompatibility, + jsonMapper, + sleeper, + clock, + baseUrl, + headers.build(), + queryParams.build(), + responseValidation, + timeout, + maxRetries, + apiKey, + ) + } + } + + /** + * Closes these client options, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client options are + * 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 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() { + httpClient.close() + sleeper.close() + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/DefaultSleeper.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/DefaultSleeper.kt new file mode 100644 index 0000000..b12a722 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/DefaultSleeper.kt @@ -0,0 +1,28 @@ +package org.onebusaway.core + +import java.time.Duration +import java.util.Timer +import java.util.TimerTask +import java.util.concurrent.CompletableFuture + +class DefaultSleeper : Sleeper { + + private val timer = Timer("DefaultSleeper", 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 + } + + override fun close() = timer.cancel() +} 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 new file mode 100644 index 0000000..d00e718 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ObjectMappers.kt @@ -0,0 +1,167 @@ +@file:JvmName("ObjectMappers") + +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.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.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 = + 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) + .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/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/PhantomReachable.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachable.kt new file mode 100644 index 0000000..8391e58 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachable.kt @@ -0,0 +1,56 @@ +@file:JvmName("PhantomReachable") + +package org.onebusaway.core + +import java.lang.reflect.InvocationTargetException +import org.onebusaway.errors.OnebusawaySdkException + +/** + * Closes [closeable] 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, closeable: AutoCloseable) { + check(observed !== closeable) { + "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" + } + closeWhenPhantomReachable(observed, closeable::close) +} + +/** + * 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") + val cleanerRegister = + cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) + val cleanerObject = cleanerCreate.invoke(null); + + { observed, close -> + try { + cleanerRegister.invoke(cleanerObject, observed, Runnable { close() }) + } catch (e: ReflectiveOperationException) { + if (e is InvocationTargetException) { + when (val cause = e.cause) { + is RuntimeException, + is Error -> throw cause + } + } + throw OnebusawaySdkException("Unexpected reflective invocation failure", e) + } + } + } catch (e: ReflectiveOperationException) { + // We're running Java 8, which has no Cleaner. + null + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachableExecutorService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachableExecutorService.kt new file mode 100644 index 0000000..55e1c63 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachableExecutorService.kt @@ -0,0 +1,58 @@ +package org.onebusaway.core + +import java.util.concurrent.Callable +import java.util.concurrent.ExecutorService +import java.util.concurrent.Future +import java.util.concurrent.TimeUnit + +/** + * A delegating wrapper around an [ExecutorService] that shuts it down once it's only phantom + * reachable. + * + * This class ensures the [ExecutorService] is shut down even if the user forgets to do it. + */ +internal class PhantomReachableExecutorService(private val executorService: ExecutorService) : + ExecutorService { + init { + closeWhenPhantomReachable(this) { executorService.shutdown() } + } + + override fun execute(command: Runnable) = executorService.execute(command) + + override fun shutdown() = executorService.shutdown() + + override fun shutdownNow(): MutableList = executorService.shutdownNow() + + override fun isShutdown(): Boolean = executorService.isShutdown + + override fun isTerminated(): Boolean = executorService.isTerminated + + override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean = + executorService.awaitTermination(timeout, unit) + + override fun submit(task: Callable): Future = executorService.submit(task) + + override fun submit(task: Runnable, result: T): Future = + executorService.submit(task, result) + + override fun submit(task: Runnable): Future<*> = executorService.submit(task) + + override fun invokeAll( + tasks: MutableCollection> + ): MutableList> = executorService.invokeAll(tasks) + + override fun invokeAll( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): MutableList> = executorService.invokeAll(tasks, timeout, unit) + + override fun invokeAny(tasks: MutableCollection>): T = + executorService.invokeAny(tasks) + + override fun invokeAny( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): T = executorService.invokeAny(tasks, timeout, unit) +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachableSleeper.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachableSleeper.kt new file mode 100644 index 0000000..b78d846 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/PhantomReachableSleeper.kt @@ -0,0 +1,23 @@ +package org.onebusaway.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable. + * + * This class ensures the [Sleeper] is closed even if the user forgets to do it. + */ +internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper { + + init { + closeWhenPhantomReachable(this, sleeper) + } + + override fun sleep(duration: Duration) = sleeper.sleep(duration) + + override fun sleepAsync(duration: Duration): CompletableFuture = + sleeper.sleepAsync(duration) + + override fun close() = sleeper.close() +} 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..5367d62 --- /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/Properties.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Properties.kt new file mode 100644 index 0000000..716b786 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Properties.kt @@ -0,0 +1,42 @@ +@file:JvmName("Properties") + +package org.onebusaway.core + +import org.onebusaway.client.OnebusawaySdkClient + +fun getOsArch(): String { + val osArch = System.getProperty("os.arch") + + return when (osArch) { + null -> "unknown" + "i386", + "x32", + "x86" -> "x32" + "amd64", + "x86_64" -> "x64" + "arm" -> "arm" + "aarch64" -> "arm64" + else -> "other:$osArch" + } +} + +fun getOsName(): String { + val osName = System.getProperty("os.name") + val vendorUrl = System.getProperty("java.vendor.url") + + return when { + osName == null -> "Unknown" + osName.startsWith("Linux") && vendorUrl == "http://www.android.com/" -> "Android" + osName.startsWith("Linux") -> "Linux" + osName.startsWith("Mac OS") -> "MacOS" + osName.startsWith("Windows") -> "Windows" + else -> "Other:$osName" + } +} + +fun getOsVersion(): String = System.getProperty("os.version", "unknown") + +fun getPackageVersion(): String = + OnebusawaySdkClient::class.java.`package`.implementationVersion ?: "unknown" + +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") 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 new file mode 100644 index 0000000..0967032 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/RequestOptions.kt @@ -0,0 +1,46 @@ +package org.onebusaway.core + +import java.time.Duration + +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { + + companion object { + + private val NONE = builder().build() + + @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: Timeout? = null + + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun timeout(timeout: Timeout) = apply { this.timeout = 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/Sleeper.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Sleeper.kt new file mode 100644 index 0000000..527c2ad --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Sleeper.kt @@ -0,0 +1,21 @@ +package org.onebusaway.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * An interface for delaying execution for a specified amount of time. + * + * Useful for testing and cleaning up resources. + */ +interface Sleeper : AutoCloseable { + + /** Synchronously pauses execution for the given [duration]. */ + fun sleep(duration: Duration) + + /** Asynchronously pauses execution for the given [duration]. */ + fun sleepAsync(duration: Duration): CompletableFuture + + /** 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/Timeout.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt new file mode 100644 index 0000000..8511d1f --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Timeout.kt @@ -0,0 +1,171 @@ +// 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 other is Timeout && + connect == other.connect && + read == other.read && + write == other.write && + request == other.request + } + + override fun hashCode(): Int = Objects.hash(connect, read, write, request) + + 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 new file mode 100644 index 0000000..36f3a92 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Utils.kt @@ -0,0 +1,115 @@ +@file:JvmName("Utils") + +package org.onebusaway.core + +import java.util.Collections +import java.util.SortedMap +import java.util.concurrent.CompletableFuture +import java.util.concurrent.locks.Lock +import org.onebusaway.errors.OnebusawaySdkInvalidDataException + +@JvmSynthetic +internal fun T?.getOrThrow(name: String): T = + this ?: throw OnebusawaySdkInvalidDataException("`${name}` is not present") + +@JvmSynthetic +internal fun List.toImmutable(): List = + if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) + +@JvmSynthetic +internal fun Map.toImmutable(): Map = + if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) + +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() + +@JvmSynthetic +internal fun , V> SortedMap.toImmutable(): SortedMap = + if (isEmpty()) Collections.emptySortedMap() + else Collections.unmodifiableSortedMap(toSortedMap(comparator())) + +/** + * Returns all elements that yield the largest value for the given function, or an empty list if + * there are zero elements. + * + * This is similar to [Sequence.maxByOrNull] except it returns _all_ elements that yield the largest + * value; not just the first one. + */ +@JvmSynthetic +internal fun > 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 + +/** + * Executes the given [action] while holding the lock, returning a [CompletableFuture] with the + * result. + * + * @param action The asynchronous action to execute while holding the lock + * @return A [CompletableFuture] that completes with the result of the action + */ +@JvmSynthetic +internal fun Lock.withLockAsync(action: () -> CompletableFuture): CompletableFuture { + lock() + val future = + try { + action() + } catch (e: Throwable) { + unlock() + throw e + } + future.whenComplete { _, _ -> unlock() } + return future +} 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 new file mode 100644 index 0000000..a630d24 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/Values.kt @@ -0,0 +1,723 @@ +package org.onebusaway.core + +import com.fasterxml.jackson.annotation.JacksonAnnotationsInside +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +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.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.node.JsonNodeType.ARRAY +import com.fasterxml.jackson.databind.node.JsonNodeType.BINARY +import com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN +import com.fasterxml.jackson.databind.node.JsonNodeType.MISSING +import com.fasterxml.jackson.databind.node.JsonNodeType.NULL +import com.fasterxml.jackson.databind.node.JsonNodeType.NUMBER +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.io.InputStream +import java.util.Objects +import java.util.Optional +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 + + /** + * 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) + + /** + * 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 = 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 = + 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() + } + + @JvmSynthetic + 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") + } + + @JvmSynthetic + internal fun getOptional( + name: String + ): Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = + when (this) { + is KnownValue -> Optional.of(value) + is JsonMissing, + is JsonNull -> Optional.empty() + else -> throw OnebusawaySdkInvalidDataException("`$name` is invalid, received $this") + } + + @JvmSynthetic + internal fun map(transform: (T) -> R): JsonField = + when (this) { + is KnownValue -> KnownValue.of(transform(value)) + is JsonValue -> this + } + + @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) { + null -> JsonNull.of() + else -> KnownValue.of(value) + } + } + + /** + * 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() + } + + class Deserializer(private val type: JavaType? = null) : + BaseDeserializer>(JsonField::class) { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer> = Deserializer(context.contextualType?.containedType(0)) + + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> = + type?.let { tryDeserialize(node, type) }?.let { of(it) } + ?: JsonValue.fromJsonNode(node) + + 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() { + + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + + 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() + is JsonNull -> visitor.visitNull() + is JsonBoolean -> visitor.visitBoolean(value) + is JsonNumber -> visitor.visitNumber(value) + is JsonString -> visitor.visitString(value) + is JsonArray -> visitor.visitArray(values) + 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() + + fun visitBoolean(value: Boolean): R = visitDefault() + + fun visitNumber(value: Number): R = visitDefault() + + fun visitString(value: String): R = visitDefault() + + fun visitArray(values: List): R = visitDefault() + + fun visitObject(values: Map): R = visitDefault() + + /** + * 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) { + null -> JsonNull.of() + is JsonValue -> value + 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) { + MISSING -> JsonMissing.of() + NULL -> JsonNull.of() + BOOLEAN -> JsonBoolean.of(node.booleanValue()) + NUMBER -> JsonNumber.of(node.numberValue()) + STRING -> JsonString.of(node.textValue()) + ARRAY -> + JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) + OBJECT -> + JsonObject.of( + node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap() + ) + BINARY, + POJO, + null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") + } + } + + class Deserializer : BaseDeserializer(JsonValue::class) { + + 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 +) : JsonField() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is KnownValue<*> && value contentEquals other.value + } + + override fun hashCode() = contentHash(value) + + 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, + ) { + 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 +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonBoolean && value == other.value + } + + override fun hashCode() = value.hashCode() + + 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 + } + + return other is JsonNumber && value == other.value + } + + override fun hashCode() = value.hashCode() + + 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 +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonString && value == other.value + } + + override fun hashCode() = value.hashCode() + + 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 + @get:JvmName("values") + val values: List +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonArray && values == other.values + } + + override fun hashCode() = values.hashCode() + + 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 + @get:JvmName("values") + val values: Map +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonObject && values == other.values + } + + override fun hashCode() = values.hashCode() + + 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) +annotation class ExcludeMissing + +/** 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?, +) { + + companion object { + + /** + * 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() + } + + /** Returns the filename directive that will be included in the serialized field. */ + fun filename(): Optional = Optional.ofNullable(filename) + + @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, + ) + } + } + + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } + + override fun hashCode(): Int = hashCode + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultipartField<*> && + value == other.value && + contentType == other.contentType && + filename == other.filename + } + + 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 new file mode 100644 index 0000000..a37a603 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/ErrorHandler.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("ErrorHandler") + +package org.onebusaway.core.handlers + +import com.fasterxml.jackson.databind.json.JsonMapper +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.PermissionDeniedException +import org.onebusaway.errors.RateLimitException +import org.onebusaway.errors.UnauthorizedException +import org.onebusaway.errors.UnexpectedStatusCodeException +import org.onebusaway.errors.UnprocessableEntityException + +@JvmSynthetic +internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) + + return object : Handler { + override fun handle(response: HttpResponse): JsonValue = + try { + handler.handle(response) + } catch (e: Exception) { + JsonMissing.of() + } + } +} + +@JvmSynthetic +internal fun errorHandler(errorBodyHandler: Handler): Handler = + object : Handler { + override fun handle(response: HttpResponse): HttpResponse = + when (val statusCode = response.statusCode()) { + in 200..299 -> response + 400 -> + throw BadRequestException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 401 -> + throw UnauthorizedException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 403 -> + throw PermissionDeniedException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 404 -> + throw NotFoundException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 422 -> + throw UnprocessableEntityException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 429 -> + throw RateLimitException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + in 500..599 -> + throw InternalServerException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + else -> + throw UnexpectedStatusCodeException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + } + } 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 new file mode 100644 index 0000000..18b8ac9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/JsonHandler.kt @@ -0,0 +1,20 @@ +@file:JvmName("JsonHandler") + +package org.onebusaway.core.handlers + +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.OnebusawaySdkInvalidDataException + +@JvmSynthetic +internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = + object : Handler { + override fun handle(response: HttpResponse): T = + try { + jsonMapper.readValue(response.body(), jacksonTypeRef()) + } catch (e: Exception) { + throw OnebusawaySdkInvalidDataException("Error reading response", e) + } + } diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/StringHandler.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/StringHandler.kt new file mode 100644 index 0000000..ede64e9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/handlers/StringHandler.kt @@ -0,0 +1,13 @@ +@file:JvmName("StringHandler") + +package org.onebusaway.core.handlers + +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler + +@JvmSynthetic internal fun stringHandler(): Handler = StringHandlerInternal + +private object StringHandlerInternal : Handler { + override fun handle(response: HttpResponse): String = + response.body().readBytes().toString(Charsets.UTF_8) +} 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 new file mode 100644 index 0000000..13da56f --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core.http + +import java.util.TreeMap +import org.onebusaway.core.JsonArray +import org.onebusaway.core.JsonBoolean +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonNull +import org.onebusaway.core.JsonNumber +import org.onebusaway.core.JsonObject +import org.onebusaway.core.JsonString +import org.onebusaway.core.JsonValue +import org.onebusaway.core.toImmutable + +class Headers +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int, +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun names(): Set = map.keys + + fun values(name: String): List = map[name].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private val map: MutableMap> = + TreeMap(String.CASE_INSENSITIVE_ORDER) + private var size: Int = 0 + + fun put(name: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(name, value.value.toString()) + is JsonNumber -> put(name, value.value.toString()) + is JsonString -> put(name, value.value) + is JsonArray -> value.values.forEach { put(name, it) } + is JsonObject -> + value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) } + } + } + + fun put(name: String, value: String) = apply { + map.getOrPut(name) { mutableListOf() }.add(value) + size++ + } + + fun put(name: String, values: Iterable) = apply { values.forEach { put(name, it) } } + + fun putAll(headers: Map>) = apply { headers.forEach(::put) } + + fun putAll(headers: Headers) = apply { + headers.names().forEach { put(it, headers.values(it)) } + } + + fun replace(name: String, value: String) = apply { + remove(name) + put(name, value) + } + + fun replace(name: String, values: Iterable) = apply { + remove(name) + put(name, values) + } + + fun replaceAll(headers: Map>) = apply { + headers.forEach(::replace) + } + + fun replaceAll(headers: Headers) = apply { + headers.names().forEach { replace(it, headers.values(it)) } + } + + fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } + + fun removeAll(names: Set) = apply { names.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + Headers( + map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> + values.toImmutable() + } + .toImmutable(), + size, + ) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && map == other.map + } + + override fun toString(): String = "Headers{map=$map}" +} 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 new file mode 100644 index 0000000..aa57cf6 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt @@ -0,0 +1,26 @@ +package org.onebusaway.core.http + +import java.lang.AutoCloseable +import java.util.concurrent.CompletableFuture +import org.onebusaway.core.RequestOptions + +interface HttpClient : AutoCloseable { + + fun execute( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + 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/HttpMethod.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpMethod.kt new file mode 100644 index 0000000..2e5625a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpMethod.kt @@ -0,0 +1,13 @@ +package org.onebusaway.core.http + +enum class HttpMethod { + GET, + HEAD, + POST, + PUT, + DELETE, + CONNECT, + OPTIONS, + TRACE, + PATCH, +} 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 new file mode 100644 index 0000000..27421c7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequest.kt @@ -0,0 +1,176 @@ +package org.onebusaway.core.http + +import java.net.URLEncoder +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable + +class HttpRequest +private constructor( + @get:JvmName("method") val method: HttpMethod, + @get:JvmName("baseUrl") val baseUrl: String, + @get:JvmName("pathSegments") val pathSegments: List, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, + @get:JvmName("body") val body: HttpRequestBody?, +) { + + fun url(): String = buildString { + append(baseUrl) + + pathSegments.forEach { segment -> + if (!endsWith("/")) { + append("/") + } + append(URLEncoder.encode(segment, "UTF-8")) + } + + if (queryParams.isEmpty()) { + return@buildString + } + + append("?") + var isFirst = true + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { value -> + if (!isFirst) { + append("&") + } + append(URLEncoder.encode(key, "UTF-8")) + append("=") + append(URLEncoder.encode(value, "UTF-8")) + isFirst = false + } + } + } + + fun toBuilder(): Builder = Builder().from(this) + + override fun toString(): String = + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var method: HttpMethod? = null + private var baseUrl: String? = null + private var pathSegments: MutableList = mutableListOf() + 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 + baseUrl = request.baseUrl + pathSegments = request.pathSegments.toMutableList() + headers = request.headers.toBuilder() + queryParams = request.queryParams.toBuilder() + body = request.body + } + + fun method(method: HttpMethod) = apply { this.method = method } + + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + + fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } + + fun addPathSegments(vararg pathSegments: String) = apply { + this.pathSegments.addAll(pathSegments) + } + + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + 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 { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + 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() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + + fun body(body: HttpRequestBody) = apply { this.body = body } + + fun build(): HttpRequest = + HttpRequest( + checkRequired("method", method), + checkRequired("baseUrl", baseUrl), + pathSegments.toImmutable(), + headers.build(), + queryParams.build(), + body, + ) + } +} 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 new file mode 100644 index 0000000..4086d94 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpRequestBody.kt @@ -0,0 +1,25 @@ +package org.onebusaway.core.http + +import java.io.OutputStream +import java.lang.AutoCloseable + +interface HttpRequestBody : AutoCloseable { + + fun writeTo(outputStream: OutputStream) + + fun contentType(): String? + + fun contentLength(): Long + + /** + * Determines if a request can be repeated in a meaningful way, for example before doing a + * retry. + * + * The most typical case when a request can't be retried is if the request body is being + * streamed. In this case the body data isn't available on subsequent attempts. + */ + 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 new file mode 100644 index 0000000..275cbd4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/HttpResponse.kt @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core.http + +import java.io.InputStream + +interface HttpResponse : AutoCloseable { + + fun statusCode(): Int + + fun headers(): Headers + + 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 new file mode 100644 index 0000000..cec4a4b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/PhantomReachableClosingHttpClient.kt @@ -0,0 +1,26 @@ +package org.onebusaway.core.http + +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) + } + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse = + httpClient.execute(request, requestOptions) + + override fun executeAsync( + request: HttpRequest, + 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 new file mode 100644 index 0000000..d10f923 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core.http + +import org.onebusaway.core.JsonArray +import org.onebusaway.core.JsonBoolean +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonNull +import org.onebusaway.core.JsonNumber +import org.onebusaway.core.JsonObject +import org.onebusaway.core.JsonString +import org.onebusaway.core.JsonValue +import org.onebusaway.core.toImmutable + +class QueryParams +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int, +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun keys(): Set = map.keys + + fun values(key: String): List = map[key].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private val map: MutableMap> = mutableMapOf() + private var size: Int = 0 + + fun put(key: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(key, value.value.toString()) + is JsonNumber -> put(key, value.value.toString()) + is JsonString -> put(key, value.value) + is JsonArray -> value.values.forEach { put(key, it) } + is JsonObject -> + value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) } + } + } + + fun put(key: String, value: String) = apply { + map.getOrPut(key) { mutableListOf() }.add(value) + size++ + } + + fun put(key: String, values: Iterable) = apply { values.forEach { put(key, it) } } + + fun putAll(queryParams: Map>) = apply { + queryParams.forEach(::put) + } + + fun putAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { put(it, queryParams.values(it)) } + } + + fun replace(key: String, value: String) = apply { + remove(key) + put(key, value) + } + + fun replace(key: String, values: Iterable) = apply { + remove(key) + put(key, values) + } + + fun replaceAll(queryParams: Map>) = apply { + queryParams.forEach(::replace) + } + + fun replaceAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { replace(it, queryParams.values(it)) } + } + + fun remove(key: String) = apply { size -= map.remove(key).orEmpty().size } + + fun removeAll(keys: Set) = apply { keys.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QueryParams && map == other.map + } + + override fun toString(): String = "QueryParams{map=$map}" +} 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 new file mode 100644 index 0000000..f909e51 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/RetryingHttpClient.kt @@ -0,0 +1,265 @@ +package org.onebusaway.core.http + +import java.io.IOException +import java.time.Clock +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.time.format.DateTimeParseException +import java.time.temporal.ChronoUnit +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.ThreadLocalRandom +import java.util.concurrent.TimeUnit +import java.util.function.Function +import kotlin.math.min +import kotlin.math.pow +import org.onebusaway.core.DefaultSleeper +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.Sleeper +import org.onebusaway.core.checkRequired +import org.onebusaway.errors.OnebusawaySdkIoException +import org.onebusaway.errors.OnebusawaySdkRetryableException + +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 { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.execute(request, requestOptions) + } + + var modifiedRequest = maybeAddIdempotencyHeader(request) + + // Don't send the current retry count in the headers if the caller set their own value. + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") + + var retries = 0 + + while (true) { + if (shouldSendRetryCount) { + modifiedRequest = setRetryCountHeader(modifiedRequest, retries) + } + + val response = + try { + val response = httpClient.execute(modifiedRequest, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } + + response + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable + } + + null + } + + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + sleeper.sleep(backoffDuration) + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.executeAsync(request, requestOptions) + } + + val modifiedRequest = maybeAddIdempotencyHeader(request) + + // Don't send the current retry count in the headers if the caller set their own value. + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") + + var retries = 0 + + fun executeWithRetries( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val requestWithRetryCount = + if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request + + return httpClient + .executeAsync(requestWithRetryCount, requestOptions) + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable?, + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + return sleeper.sleepAsync(backoffDuration).thenCompose { + executeWithRetries(requestWithRetryCount, requestOptions) + } + } + ) { + // Run in the same thread. + it.run() + } + .thenCompose(Function.identity()) + } + + return executeWithRetries(modifiedRequest, requestOptions) + } + + override fun close() { + httpClient.close() + sleeper.close() + } + + private fun isRetryable(request: HttpRequest): Boolean = + // Some requests, such as when a request body is being streamed, cannot be retried because + // the body data aren't available on subsequent attempts. + request.body?.repeatable() ?: true + + 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): 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().values("X-Should-Retry").getOrNull(0) + val statusCode = response.statusCode() + + return when { + // If the server explicitly says whether to retry, obey + shouldRetryHeader == "true" -> true + shouldRetryHeader == "false" -> false + + // Retry on request timeouts + statusCode == 408 -> true + // Retry on lock timeouts + statusCode == 409 -> true + // Retry on rate limits + statusCode == 429 -> true + // Retry internal errors + statusCode >= 500 -> true + else -> false + } + } + + private fun shouldRetry(throwable: Throwable): Boolean = + // Only retry known retryable exceptions, other exceptions are not intended to be retried. + throwable is IOException || + throwable is OnebusawaySdkIoException || + throwable is OnebusawaySdkRetryableException + + 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 + ?.headers() + ?.let { headers -> + headers + .values("Retry-After-Ms") + .getOrNull(0) + ?.toFloatOrNull() + ?.times(TimeUnit.MILLISECONDS.toNanos(1)) + ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> + retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME, + ), + ) + } catch (e: DateTimeParseException) { + null + } + } + } + ?.let { retryAfterNanos -> + // If the API asks us to wait a certain amount of time (and it's a reasonable + // amount), just + // do what it says. + val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) + if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { + return retryAfter + } + } + + // Apply exponential backoff, but not more than the max. + val backoffSeconds = min(0.5 * 2.0.pow(retries - 1), 8.0) + + // Apply some jitter + val jitter = 1.0 - 0.25 * ThreadLocalRandom.current().nextDouble() + + return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) + } + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var sleeper: Sleeper? = null + private var clock: Clock = Clock.systemUTC() + private var maxRetries: Int = 2 + private var idempotencyHeader: String? = null + + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + + fun clock(clock: Clock) = apply { this.clock = clock } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } + + fun build(): HttpClient = + RetryingHttpClient( + checkRequired("httpClient", httpClient), + sleeper ?: DefaultSleeper(), + clock, + maxRetries, + idempotencyHeader, + ) + } +} 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 new file mode 100644 index 0000000..2ed561f --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/BadRequestException.kt @@ -0,0 +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 +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 new file mode 100644 index 0000000..feb6ec9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/InternalServerException.kt @@ -0,0 +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 +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 new file mode 100644 index 0000000..d6aef12 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/NotFoundException.kt @@ -0,0 +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 +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/OnebusawaySdkException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkException.kt new file mode 100644 index 0000000..293f19c --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkException.kt @@ -0,0 +1,5 @@ +package org.onebusaway.errors + +open class OnebusawaySdkException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkInvalidDataException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkInvalidDataException.kt new file mode 100644 index 0000000..42b999e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkInvalidDataException.kt @@ -0,0 +1,6 @@ +package org.onebusaway.errors + +class OnebusawaySdkInvalidDataException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : + OnebusawaySdkException(message, cause) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkIoException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkIoException.kt new file mode 100644 index 0000000..5176f29 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkIoException.kt @@ -0,0 +1,6 @@ +package org.onebusaway.errors + +class OnebusawaySdkIoException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : + OnebusawaySdkException(message, cause) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkRetryableException.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkRetryableException.kt new file mode 100644 index 0000000..888e3ff --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkRetryableException.kt @@ -0,0 +1,15 @@ +package org.onebusaway.errors + +/** + * Exception that indicates a transient error that can be retried. + * + * When this exception is thrown during an HTTP request, the SDK will automatically retry the + * request up to the maximum number of retries. + * + * @param message A descriptive error message + * @param cause The underlying cause of this exception, if any + */ +class OnebusawaySdkRetryableException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : + OnebusawaySdkException(message, cause) 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 new file mode 100644 index 0000000..9e14f04 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/OnebusawaySdkServiceException.kt @@ -0,0 +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 +protected constructor(message: String, cause: Throwable? = null) : + OnebusawaySdkException(message, cause) { + + abstract fun statusCode(): Int + + abstract fun headers(): Headers + + 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 new file mode 100644 index 0000000..28a3b5a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/PermissionDeniedException.kt @@ -0,0 +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 +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 new file mode 100644 index 0000000..8e68c49 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/RateLimitException.kt @@ -0,0 +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 +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 new file mode 100644 index 0000000..79e2116 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnauthorizedException.kt @@ -0,0 +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 +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 new file mode 100644 index 0000000..f4aaa51 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnexpectedStatusCodeException.kt @@ -0,0 +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 +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 new file mode 100644 index 0000000..be66612 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/errors/UnprocessableEntityException.kt @@ -0,0 +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 +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/References.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt new file mode 100644 index 0000000..0a75035 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/References.kt @@ -0,0 +1,5644 @@ +// 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.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.checkKnown +import org.onebusaway.core.checkRequired +import org.onebusaway.core.toImmutable +import org.onebusaway.errors.OnebusawaySdkInvalidDataException + +class References +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + 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 = + 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() + } + + /** A builder for [References]. */ + class Builder internal constructor() { + + 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.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)) + + /** + * 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())).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())).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())).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())).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())).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())).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 [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() }, + 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.toMutableMap(), + ) + } + + 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(mode = JsonCreator.Mode.DISABLED) + 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 [Agency]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .timezone() + * .url() + * ``` + */ + @JvmStatic fun builder() = 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 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(agency: Agency) = apply { + id = agency.id + name = agency.name + timezone = agency.timezone + url = agency.url + disclaimer = agency.disclaimer + email = agency.email + fareUrl = agency.fareUrl + lang = agency.lang + phone = agency.phone + privateService = agency.privateService + additionalProperties = agency.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 [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), + checkRequired("name", name), + checkRequired("timezone", timezone), + checkRequired("url", url), + disclaimer, + email, + fareUrl, + lang, + phone, + privateService, + 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 + } + + return 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + timezone, + url, + disclaimer, + email, + fareUrl, + lang, + phone, + privateService, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Agency{id=$id, name=$name, timezone=$timezone, url=$url, disclaimer=$disclaimer, email=$email, fareUrl=$fareUrl, lang=$lang, phone=$phone, privateService=$privateService, additionalProperties=$additionalProperties}" + } + + class Route + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 [Route]. + * + * The following fields are required: + * ```java + * .id() + * .agencyId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Route]. */ + 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(route: Route) = apply { + id = route.id + agencyId = route.agencyId + type = route.type + color = route.color + description = route.description + longName = route.longName + nullSafeShortName = route.nullSafeShortName + shortName = route.shortName + textColor = route.textColor + url = route.url + additionalProperties = route.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 [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), + checkRequired("agencyId", agencyId), + checkRequired("type", type), + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + 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 + } + + return 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Route{id=$id, agencyId=$agencyId, type=$type, color=$color, description=$description, longName=$longName, nullSafeShortName=$nullSafeShortName, shortName=$shortName, textColor=$textColor, url=$url, additionalProperties=$additionalProperties}" + } + + class Situation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + 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, + ) { + + @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. + * + * @throws OnebusawaySdkInvalidDataException if 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> = + 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 = + 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> = + 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 + + /** + * 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 + + /** + * 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 + + /** + * 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 + + /** + * 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 = + 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() + } + + /** A builder for [Situation]. */ + class Builder internal constructor() { + + 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 url: 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 + url = situation.url + additionalProperties = situation.additionalProperties.toMutableMap() + } + + /** Unique identifier for the situation. */ + 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 } + + /** Unix timestamp of when this situation was created. */ + fun creationTime(creationTime: Long) = creationTime(JsonField.of(creationTime)) + + /** + * 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 + } + + 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())).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())).also { + checkKnown("allAffects", it).add(allAffect) + } + } + + /** Message regarding the consequence of the situation. */ + fun consequenceMessage(consequenceMessage: String) = + consequenceMessage(JsonField.of(consequenceMessage)) + + /** + * 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 + } + + 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())).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 + } + + 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())).also { + checkKnown("publicationWindows", it).add(publicationWindow) + } + } + + /** Reason for the service alert, taken from TPEG codes. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [Reason] value instead. + * 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)) + + /** + * 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 { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [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), + 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, + url, + additionalProperties.toMutableMap(), + ) + } + + 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(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val from: JsonField, + private val to: JsonField, + private val additionalProperties: MutableMap, + ) { + + @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. + * + * @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") + + /** + * 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 + + /** + * 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 = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ActiveWindow]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActiveWindow]. */ + class Builder internal constructor() { + + private var from: JsonField = JsonMissing.of() + private var to: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(activeWindow: ActiveWindow) = apply { + 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)) + + /** + * 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)) + + /** + * 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 { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [ActiveWindow]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ActiveWindow = + 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 + } + + return other is ActiveWindow && + from == other.from && + to == other.to && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(from, to, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActiveWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" + } + + class AllAffect + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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: MutableMap, + ) { + + @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 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 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 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 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 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 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 + + /** + * 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 + + /** + * 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 [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 [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 + + @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 [AllAffect]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AllAffect]. */ + class Builder internal constructor() { + + private var agencyId: JsonField = JsonMissing.of() + private var applicationId: JsonField = JsonMissing.of() + private var directionId: JsonField = JsonMissing.of() + private var routeId: JsonField = JsonMissing.of() + private var stopId: JsonField = JsonMissing.of() + private var tripId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allAffect: AllAffect) = apply { + 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)) + + /** + * 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)) + + /** + * 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 + } + + /** Identifier for the direction. */ + 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 + } + + /** Identifier for the route. */ + 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 } + + /** Identifier for the stop. */ + 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 } + + /** Identifier for the trip. */ + 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 [AllAffect]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AllAffect = + AllAffect( + agencyId, + applicationId, + directionId, + routeId, + stopId, + tripId, + 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 + } + + return other is AllAffect && + agencyId == other.agencyId && + applicationId == other.applicationId && + directionId == other.directionId && + routeId == other.routeId && + stopId == other.stopId && + tripId == other.tripId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + agencyId, + applicationId, + directionId, + routeId, + stopId, + tripId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AllAffect{agencyId=$agencyId, applicationId=$applicationId, directionId=$directionId, routeId=$routeId, stopId=$stopId, tripId=$tripId, additionalProperties=$additionalProperties}" + } + + class Consequence + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val condition: JsonField, + private val conditionDetails: JsonField, + private val additionalProperties: MutableMap, + ) { + + @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 = + conditionDetails.getOptional("conditionDetails") + + /** + * 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 = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Consequence]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Consequence]. */ + class Builder internal constructor() { + + private var condition: JsonField = JsonMissing.of() + private var conditionDetails: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consequence: Consequence) = apply { + condition = consequence.condition + conditionDetails = consequence.conditionDetails + additionalProperties = consequence.additionalProperties.toMutableMap() + } + + /** Condition of the consequence. */ + fun condition(condition: String) = condition(JsonField.of(condition)) + + /** + * 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 + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [Consequence]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Consequence = + 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 + } + + 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(mode = JsonCreator.Mode.DISABLED) + private constructor( + 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 = + 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> = + 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 = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConditionDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConditionDetails]. */ + class Builder internal constructor() { + + private var diversionPath: 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.map { it.toMutableList() } + additionalProperties = conditionDetails.additionalProperties.toMutableMap() + } + + 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 + } + + 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())).also { + checkKnown("diversionStopIds", it).add(diversionStopId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [ConditionDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ConditionDetails = + ConditionDetails( + diversionPath, + (diversionStopIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConditionDetails = apply { + if (validated) { + return@apply + } + + diversionPath().ifPresent { it.validate() } + diversionStopIds() + 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 = + (diversionPath.asKnown().getOrNull()?.validity() ?: 0) + + (diversionStopIds.asKnown().getOrNull()?.size ?: 0) + + class DiversionPath + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("length") + @ExcludeMissing + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) + + /** + * 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 + + /** + * 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 + * [DiversionPath]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DiversionPath]. */ + 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(diversionPath: DiversionPath) = apply { + 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)) + + /** + * 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)) + + /** + * 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)) + + /** + * 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 [DiversionPath]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DiversionPath = + DiversionPath( + length, + levels, + points, + 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 + } + + return other is DiversionPath && + length == other.length && + levels == other.levels && + points == other.points && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(length, levels, points, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DiversionPath{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionDetails && + diversionPath == other.diversionPath && + diversionStopIds == other.diversionStopIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(diversionPath, diversionStopIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConditionDetails{diversionPath=$diversionPath, diversionStopIds=$diversionStopIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Consequence && + condition == other.condition && + conditionDetails == other.conditionDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(condition, conditionDetails, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Consequence{condition=$condition, conditionDetails=$conditionDetails, additionalProperties=$additionalProperties}" + } + + class Description + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lang: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @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. + * + * @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") + + /** + * 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 [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 = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Description]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Description]. */ + class Builder internal constructor() { + + private var lang: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(description: Description) = apply { + lang = description.lang + value = description.value + additionalProperties = description.additionalProperties.toMutableMap() + } + + /** Language of the description. */ + 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 } + + /** Longer description of the situation. */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * 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 { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [Description]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Description = + 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 + } + + return other is Description && + lang == other.lang && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Description{lang=$lang, value=$value, additionalProperties=$additionalProperties}" + } + + class PublicationWindow + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val from: JsonField, + private val to: JsonField, + private val additionalProperties: MutableMap, + ) { + + @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. + * + * @throws OnebusawaySdkInvalidDataException if 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") + + /** + * 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 + + /** + * 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 = + 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() + } + + /** A builder for [PublicationWindow]. */ + class Builder internal constructor() { + + private var from: JsonField? = null + private var to: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(publicationWindow: PublicationWindow) = apply { + 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)) + + /** + * 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)) + + /** + * 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 { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [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.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 + } + + return other is PublicationWindow && + from == other.from && + to == other.to && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(from, to, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PublicationWindow{from=$from, to=$to, additionalProperties=$additionalProperties}" + } + + /** Reason for the service alert, taken from TPEG codes. */ + class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val EQUIPMENT_REASON = of("equipmentReason") + + @JvmField val ENVIRONMENT_REASON = of("environmentReason") + + @JvmField val PERSONNEL_REASON = of("personnelReason") + + @JvmField val MISCELLANEOUS_REASON = of("miscellaneousReason") + + @JvmField val SECURITY_ALERT = of("securityAlert") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + EQUIPMENT_REASON, + ENVIRONMENT_REASON, + PERSONNEL_REASON, + MISCELLANEOUS_REASON, + SECURITY_ALERT, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + EQUIPMENT_REASON, + ENVIRONMENT_REASON, + PERSONNEL_REASON, + MISCELLANEOUS_REASON, + SECURITY_ALERT, + /** + * An enum member indicating that [Reason] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + EQUIPMENT_REASON -> Value.EQUIPMENT_REASON + ENVIRONMENT_REASON -> Value.ENVIRONMENT_REASON + PERSONNEL_REASON -> Value.PERSONNEL_REASON + MISCELLANEOUS_REASON -> Value.MISCELLANEOUS_REASON + SECURITY_ALERT -> Value.SECURITY_ALERT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OnebusawaySdkInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + EQUIPMENT_REASON -> Known.EQUIPMENT_REASON + ENVIRONMENT_REASON -> Known.ENVIRONMENT_REASON + PERSONNEL_REASON -> Known.PERSONNEL_REASON + MISCELLANEOUS_REASON -> Known.MISCELLANEOUS_REASON + SECURITY_ALERT -> Known.SECURITY_ALERT + else -> throw OnebusawaySdkInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OnebusawaySdkInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OnebusawaySdkInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Summary + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lang: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @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. + * + * @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") + + /** + * 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 [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 = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Summary]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Summary]. */ + class Builder internal constructor() { + + private var lang: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(summary: Summary) = apply { + lang = summary.lang + value = summary.value + additionalProperties = summary.additionalProperties.toMutableMap() + } + + /** Language of the summary. */ + 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 } + + /** Short summary of the situation. */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * 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 { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [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 + } + + return other is Summary && + lang == other.lang && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Summary{lang=$lang, value=$value, additionalProperties=$additionalProperties}" + } + + class Url + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lang: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @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. + * + * @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") + + /** + * 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 [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 = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Url]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Url]. */ + class Builder internal constructor() { + + private var lang: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(url: Url) = apply { + lang = url.lang + value = url.value + additionalProperties = url.additionalProperties.toMutableMap() + } + + /** Language of the URL. */ + 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 } + + /** URL for more information about the situation. */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * 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 { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [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 + } + + return other is Url && + lang == other.lang && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(lang, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Url{lang=$lang, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creationTime, + activeWindows, + allAffects, + consequenceMessage, + consequences, + description, + publicationWindows, + reason, + severity, + summary, + url, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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}" + } + + class Stop + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") @ExcludeMissing parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 StopTime + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is StopTime && + arrivalTime == other.arrivalTime && + departureTime == other.departureTime && + distanceAlongTrip == other.distanceAlongTrip && + historicalOccupancy == other.historicalOccupancy && + stopHeadsign == other.stopHeadsign && + stopId == other.stopId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalTime=$arrivalTime, departureTime=$departureTime, distanceAlongTrip=$distanceAlongTrip, historicalOccupancy=$historicalOccupancy, stopHeadsign=$stopHeadsign, stopId=$stopId, additionalProperties=$additionalProperties}" + } + + class Trip + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val routeId: JsonField, + private val serviceId: JsonField, + private val blockId: JsonField, + private val directionId: JsonField, + private val peakOffpeak: JsonField, + private val routeShortName: JsonField, + private val shapeId: JsonField, + private val timeZone: JsonField, + private val tripHeadsign: JsonField, + private val tripShortName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("routeId") @ExcludeMissing routeId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("blockId") @ExcludeMissing blockId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + directionId: JsonField = JsonMissing.of(), + @JsonProperty("peakOffpeak") + @ExcludeMissing + peakOffpeak: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shapeId") @ExcludeMissing shapeId: JsonField = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripShortName") + @ExcludeMissing + tripShortName: JsonField = JsonMissing.of(), + ) : this( + id, + routeId, + serviceId, + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun serviceId(): String = serviceId.getRequired("serviceId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blockId(): Optional = blockId.getOptional("blockId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun directionId(): Optional = directionId.getOptional("directionId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun peakOffpeak(): Optional = peakOffpeak.getOptional("peakOffpeak") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun routeShortName(): Optional = routeShortName.getOptional("routeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun shapeId(): Optional = shapeId.getOptional("shapeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun timeZone(): Optional = timeZone.getOptional("timeZone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tripHeadsign(): Optional = tripHeadsign.getOptional("tripHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tripShortName(): Optional = tripShortName.getOptional("tripShortName") + + /** + * 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + routeId, + serviceId, + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + additionalProperties, + ) + } + + 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 other is References && + agencies == other.agencies && + routes == other.routes && + situations == other.situations && + stops == other.stops && + stopTimes == other.stopTimes && + trips == other.trips && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(agencies, routes, situations, stops, stopTimes, trips, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/ResponseWrapper.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt new file mode 100644 index 0000000..a646686 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/ResponseWrapper.kt @@ -0,0 +1,276 @@ +// 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.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.checkRequired +import org.onebusaway.errors.OnebusawaySdkInvalidDataException + +class ResponseWrapper +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val 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 = + 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() + } + + /** A builder for [ResponseWrapper]. */ + 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 additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(responseWrapper: ResponseWrapper) = apply { + code = responseWrapper.code + currentTime = responseWrapper.currentTime + text = responseWrapper.text + version = responseWrapper.version + additionalProperties = responseWrapper.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 additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 [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.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 + } + + return other is ResponseWrapper && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, additionalProperties) + } + + 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/agencieswithcoverage/AgenciesWithCoverageListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParams.kt new file mode 100644 index 0000000..1346d08 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParams.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agencieswithcoverage + +import java.util.Objects +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 +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AgenciesWithCoverageListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [AgenciesWithCoverageListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgenciesWithCoverageListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(agenciesWithCoverageListParams: AgenciesWithCoverageListParams) = apply { + additionalHeaders = agenciesWithCoverageListParams.additionalHeaders.toBuilder() + additionalQueryParams = agenciesWithCoverageListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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 + } + + return other is AgenciesWithCoverageListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgenciesWithCoverageListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..4b2eab8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListResponse.kt @@ -0,0 +1,891 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is List && + agencyId == other.agencyId && + lat == other.lat && + latSpan == other.latSpan && + lon == other.lon && + lonSpan == other.lonSpan && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(agencyId, lat, latSpan, lon, lonSpan, additionalProperties) + } + + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, additionalProperties) + } + + 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 other is AgenciesWithCoverageListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/agency/AgencyRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveParams.kt new file mode 100644 index 0000000..c1b03ca --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agency + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agencyId(): Optional = Optional.ofNullable(agencyId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AgencyRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AgencyRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AgencyRetrieveParams]. */ + class Builder internal constructor() { + + private var agencyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(agencyRetrieveParams: AgencyRetrieveParams) = apply { + agencyId = agencyRetrieveParams.agencyId + additionalHeaders = agencyRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = agencyRetrieveParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AgencyRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AgencyRetrieveParams = + 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 + } + + return other is AgencyRetrieveParams && + agencyId == other.agencyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(agencyId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AgencyRetrieveParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..05eaaf3 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/agency/AgencyRetrieveResponse.kt @@ -0,0 +1,1067 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + timezone, + url, + disclaimer, + email, + fareUrl, + lang, + phone, + privateService, + additionalProperties, + ) + } + + 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 other is Data && + entry == other.entry && + limitExceeded == other.limitExceeded && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(entry, limitExceeded, references, additionalProperties) + } + + 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 other is AgencyRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/arrivalanddeparture/ArrivalAndDepartureListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParams.kt new file mode 100644 index 0000000..d8a5888 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParams.kt @@ -0,0 +1,270 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 minutesAfter: Long?, + private val minutesBefore: Long?, + private val time: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun stopId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ArrivalAndDepartureListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalAndDepartureListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalAndDepartureListParams]. */ + class Builder internal constructor() { + + private var stopId: String? = null + private var minutesAfter: Long? = null + private var minutesBefore: Long? = null + private var time: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(arrivalAndDepartureListParams: ArrivalAndDepartureListParams) = apply { + 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 } + + /** 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 } + + /** + * Alias for [Builder.minutesAfter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun minutesAfter(minutesAfter: Long) = minutesAfter(minutesAfter as Long?) + + /** Alias for calling [Builder.minutesAfter] with `minutesAfter.orElse(null)`. */ + fun minutesAfter(minutesAfter: Optional) = minutesAfter(minutesAfter.getOrNull()) + + /** Include vehicles having arrived or departed in the previous n minutes. */ + fun minutesBefore(minutesBefore: Long?) = apply { this.minutesBefore = minutesBefore } + + /** + * Alias for [Builder.minutesBefore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun minutesBefore(minutesBefore: Long) = minutesBefore(minutesBefore as Long?) + + /** Alias for calling [Builder.minutesBefore] with `minutesBefore.orElse(null)`. */ + fun minutesBefore(minutesBefore: Optional) = minutesBefore(minutesBefore.getOrNull()) + + /** The specific time for querying the system status. */ + fun time(time: OffsetDateTime?) = apply { this.time = time } + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ArrivalAndDepartureListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ArrivalAndDepartureListParams = + ArrivalAndDepartureListParams( + stopId, + minutesAfter, + minutesBefore, + time, + 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 { + 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 + } + + return other is ArrivalAndDepartureListParams && + stopId == other.stopId && + minutesAfter == other.minutesAfter && + minutesBefore == other.minutesBefore && + time == other.time && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + stopId, + minutesAfter, + minutesBefore, + time, + additionalHeaders, + additionalQueryParams, + ) + + 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/arrivalanddeparture/ArrivalAndDepartureListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt new file mode 100644 index 0000000..0102ccf --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListResponse.kt @@ -0,0 +1,4324 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arrivalsAndDepartures: JsonField>, + private val 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arrivalEnabled: JsonField, + private val blockTripSequence: JsonField, + private val departureEnabled: JsonField, + private val numberOfStopsAway: JsonField, + private val predictedArrivalTime: JsonField, + private val predictedDepartureTime: JsonField, + private val routeId: JsonField, + private val scheduledArrivalTime: JsonField, + private val scheduledDepartureTime: JsonField, + private val serviceDate: JsonField, + private val stopId: JsonField, + private val stopSequence: JsonField, + private val totalStopsInTrip: JsonField, + private val tripHeadsign: JsonField, + private val tripId: JsonField, + private val vehicleId: JsonField, + private val actualTrack: JsonField, + private val distanceFromStop: JsonField, + private val frequency: JsonField, + private val historicalOccupancy: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyStatus: JsonField, + private val predicted: JsonField, + private val predictedArrivalInterval: JsonField, + private val predictedDepartureInterval: JsonField, + private val predictedOccupancy: JsonField, + private val routeLongName: JsonField, + private val routeShortName: JsonField, + private val scheduledArrivalInterval: JsonField, + private val scheduledDepartureInterval: JsonField, + private val scheduledTrack: JsonField, + private val situationIds: JsonField>, + private val status: JsonField, + private val tripStatus: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalEnabled") + @ExcludeMissing + arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + numberOfStopsAway: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + predictedArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + predictedDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + scheduledArrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + scheduledDepartureTime: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("stopSequence") + @ExcludeMissing + stopSequence: JsonField = JsonMissing.of(), + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + totalStopsInTrip: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + @JsonProperty("actualTrack") + @ExcludeMissing + actualTrack: JsonField = JsonMissing.of(), + @JsonProperty("distanceFromStop") + @ExcludeMissing + distanceFromStop: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("historicalOccupancy") + @ExcludeMissing + historicalOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + predictedArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + predictedDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("predictedOccupancy") + @ExcludeMissing + predictedOccupancy: JsonField = JsonMissing.of(), + @JsonProperty("routeLongName") + @ExcludeMissing + routeLongName: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + scheduledArrivalInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + scheduledDepartureInterval: JsonField = JsonMissing.of(), + @JsonProperty("scheduledTrack") + @ExcludeMissing + scheduledTrack: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("tripStatus") + @ExcludeMissing + tripStatus: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + blockTripSequence, + departureEnabled, + numberOfStopsAway, + predictedArrivalTime, + predictedDepartureTime, + routeId, + scheduledArrivalTime, + scheduledDepartureTime, + serviceDate, + stopId, + stopSequence, + totalStopsInTrip, + tripHeadsign, + tripId, + vehicleId, + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + situationIds, + status, + tripStatus, + mutableMapOf(), + ) + + /** + * Indicates if riders can arrive on this transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") + + /** + * Index of this arrival’s trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * Indicates if riders can depart from this transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun departureEnabled(): Boolean = departureEnabled.getRequired("departureEnabled") + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun numberOfStopsAway(): Long = numberOfStopsAway.getRequired("numberOfStopsAway") + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no real-time + * available). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predictedArrivalTime(): Long = + predictedArrivalTime.getRequired("predictedArrivalTime") + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no real-time + * available). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predictedDepartureTime(): Long = + predictedDepartureTime.getRequired("predictedDepartureTime") + + /** + * The ID of the route for the arriving vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * Scheduled arrival time, in milliseconds since Unix epoch. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduledArrivalTime(): Long = + scheduledArrivalTime.getRequired("scheduledArrivalTime") + + /** + * Scheduled departure time, in milliseconds since Unix epoch. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduledDepartureTime(): Long = + scheduledDepartureTime.getRequired("scheduledDepartureTime") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * The ID of the stop the vehicle is arriving at. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun stopSequence(): Long = stopSequence.getRequired("stopSequence") + + /** + * Total number of stops visited on the trip for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalStopsInTrip(): Long = totalStopsInTrip.getRequired("totalStopsInTrip") + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tripHeadsign(): String = tripHeadsign.getRequired("tripHeadsign") + + /** + * The ID of the trip for the arriving vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * ID of the transit vehicle serving this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun vehicleId(): String = vehicleId.getRequired("vehicleId") + + /** + * The actual track information of the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun actualTrack(): Optional = actualTrack.getOptional("actualTrack") + + /** + * Distance of the arriving transit vehicle from the stop, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun distanceFromStop(): Optional = + distanceFromStop.getOptional("distanceFromStop") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Historical occupancy information of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun historicalOccupancy(): Optional = + historicalOccupancy.getOptional("historicalOccupancy") + + /** + * Timestamp of the last update time for this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lastUpdateTime(): Optional = lastUpdateTime.getOptional("lastUpdateTime") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun occupancyStatus(): Optional = + occupancyStatus.getOptional("occupancyStatus") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predicted(): Optional = predicted.getOptional("predicted") + + /** + * Interval for predicted arrival time, if available. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedArrivalInterval(): Optional = + predictedArrivalInterval.getOptional("predictedArrivalInterval") + + /** + * Interval for predicted departure time, if available. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedDepartureInterval(): Optional = + predictedDepartureInterval.getOptional("predictedDepartureInterval") + + /** + * Predicted occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun predictedOccupancy(): Optional = + predictedOccupancy.getOptional("predictedOccupancy") + + /** + * Optional route long name that potentially overrides the route long name in the + * referenced route element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun routeLongName(): Optional = routeLongName.getOptional("routeLongName") + + /** + * Optional route short name that potentially overrides the route short name in the + * referenced route element. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun routeShortName(): Optional = + routeShortName.getOptional("routeShortName") + + /** + * Interval for scheduled arrival time. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledArrivalInterval(): Optional = + scheduledArrivalInterval.getOptional("scheduledArrivalInterval") + + /** + * Interval for scheduled departure time. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledDepartureInterval(): Optional = + scheduledDepartureInterval.getOptional("scheduledDepartureInterval") + + /** + * Scheduled track information of the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun scheduledTrack(): Optional = + scheduledTrack.getOptional("scheduledTrack") + + /** + * References to situation elements (if any) applicable to this arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun situationIds(): Optional> = + situationIds.getOptional("situationIds") + + /** + * Current status of the arrival. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Trip-specific status for the arriving transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tripStatus(): Optional = tripStatus.getOptional("tripStatus") + + /** + * Returns the raw JSON value of [arrivalEnabled]. + * + * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled + + /** + * Returns the raw JSON value of [blockTripSequence]. + * + * Unlike [blockTripSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("blockTripSequence") + @ExcludeMissing + fun _blockTripSequence(): JsonField = blockTripSequence + + /** + * Returns the raw JSON value of [departureEnabled]. + * + * Unlike [departureEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("departureEnabled") + @ExcludeMissing + fun _departureEnabled(): JsonField = departureEnabled + + /** + * Returns the raw JSON value of [numberOfStopsAway]. + * + * Unlike [numberOfStopsAway], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("numberOfStopsAway") + @ExcludeMissing + fun _numberOfStopsAway(): JsonField = numberOfStopsAway + + /** + * Returns the raw JSON value of [predictedArrivalTime]. + * + * Unlike [predictedArrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedArrivalTime") + @ExcludeMissing + fun _predictedArrivalTime(): JsonField = predictedArrivalTime + + /** + * Returns the raw JSON value of [predictedDepartureTime]. + * + * Unlike [predictedDepartureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("predictedDepartureTime") + @ExcludeMissing + fun _predictedDepartureTime(): JsonField = predictedDepartureTime + + /** + * Returns the raw JSON value of [routeId]. + * + * Unlike [routeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routeId") @ExcludeMissing fun _routeId(): JsonField = routeId + + /** + * Returns the raw JSON value of [scheduledArrivalTime]. + * + * Unlike [scheduledArrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledArrivalTime") + @ExcludeMissing + fun _scheduledArrivalTime(): JsonField = scheduledArrivalTime + + /** + * Returns the raw JSON value of [scheduledDepartureTime]. + * + * Unlike [scheduledDepartureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scheduledDepartureTime") + @ExcludeMissing + fun _scheduledDepartureTime(): JsonField = scheduledDepartureTime + + /** + * Returns the raw JSON value of [serviceDate]. + * + * Unlike [serviceDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceDate") + @ExcludeMissing + fun _serviceDate(): JsonField = serviceDate + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stopId") @ExcludeMissing fun _stopId(): JsonField = stopId + + /** + * Returns the raw JSON value of [stopSequence]. + * + * Unlike [stopSequence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopSequence") + @ExcludeMissing + fun _stopSequence(): JsonField = stopSequence + + /** + * Returns the raw JSON value of [totalStopsInTrip]. + * + * Unlike [totalStopsInTrip], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("totalStopsInTrip") + @ExcludeMissing + fun _totalStopsInTrip(): JsonField = totalStopsInTrip + + /** + * Returns the raw JSON value of [tripHeadsign]. + * + * Unlike [tripHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripHeadsign") + @ExcludeMissing + fun _tripHeadsign(): JsonField = tripHeadsign + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tripId") @ExcludeMissing fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [vehicleId]. + * + * Unlike [vehicleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicleId") + @ExcludeMissing + fun _vehicleId(): JsonField = vehicleId + + /** + * Returns the raw JSON value of [actualTrack]. + * + * Unlike [actualTrack], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("actualTrack") + @ExcludeMissing + fun _actualTrack(): JsonField = actualTrack + + /** + * Returns the raw JSON value of [distanceFromStop]. + * + * Unlike [distanceFromStop], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("distanceFromStop") + @ExcludeMissing + fun _distanceFromStop(): JsonField = distanceFromStop + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [historicalOccupancy]. + * + * Unlike [historicalOccupancy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("historicalOccupancy") + @ExcludeMissing + fun _historicalOccupancy(): JsonField = historicalOccupancy + + /** + * Returns the raw JSON value of [lastUpdateTime]. + * + * Unlike [lastUpdateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lastUpdateTime") + @ExcludeMissing + fun _lastUpdateTime(): JsonField = lastUpdateTime + + /** + * Returns the raw JSON value of [occupancyStatus]. + * + * Unlike [occupancyStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("occupancyStatus") + @ExcludeMissing + fun _occupancyStatus(): JsonField = occupancyStatus + + /** + * Returns the raw JSON value of [predicted]. + * + * Unlike [predicted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predicted") + @ExcludeMissing + fun _predicted(): JsonField = predicted + + /** + * Returns the raw JSON value of [predictedArrivalInterval]. + * + * Unlike [predictedArrivalInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("predictedArrivalInterval") + @ExcludeMissing + fun _predictedArrivalInterval(): JsonField = predictedArrivalInterval + + /** + * Returns the raw JSON value of [predictedDepartureInterval]. + * + * Unlike [predictedDepartureInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("predictedDepartureInterval") + @ExcludeMissing + fun _predictedDepartureInterval(): JsonField = predictedDepartureInterval + + /** + * Returns the raw JSON value of [predictedOccupancy]. + * + * Unlike [predictedOccupancy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictedOccupancy") + @ExcludeMissing + fun _predictedOccupancy(): JsonField = predictedOccupancy + + /** + * Returns the raw JSON value of [routeLongName]. + * + * Unlike [routeLongName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeLongName") + @ExcludeMissing + fun _routeLongName(): JsonField = routeLongName + + /** + * Returns the raw JSON value of [routeShortName]. + * + * Unlike [routeShortName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routeShortName") + @ExcludeMissing + fun _routeShortName(): JsonField = routeShortName + + /** + * Returns the raw JSON value of [scheduledArrivalInterval]. + * + * Unlike [scheduledArrivalInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledArrivalInterval") + @ExcludeMissing + fun _scheduledArrivalInterval(): JsonField = scheduledArrivalInterval + + /** + * Returns the raw JSON value of [scheduledDepartureInterval]. + * + * Unlike [scheduledDepartureInterval], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scheduledDepartureInterval") + @ExcludeMissing + fun _scheduledDepartureInterval(): JsonField = scheduledDepartureInterval + + /** + * Returns the raw JSON value of [scheduledTrack]. + * + * Unlike [scheduledTrack], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scheduledTrack") + @ExcludeMissing + fun _scheduledTrack(): JsonField = scheduledTrack + + /** + * Returns the raw JSON value of [situationIds]. + * + * Unlike [situationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("situationIds") + @ExcludeMissing + fun _situationIds(): JsonField> = situationIds + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [tripStatus]. + * + * Unlike [tripStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripStatus") + @ExcludeMissing + fun _tripStatus(): JsonField = tripStatus + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalsAndDeparture]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .blockTripSequence() + * .departureEnabled() + * .numberOfStopsAway() + * .predictedArrivalTime() + * .predictedDepartureTime() + * .routeId() + * .scheduledArrivalTime() + * .scheduledDepartureTime() + * .serviceDate() + * .stopId() + * .stopSequence() + * .totalStopsInTrip() + * .tripHeadsign() + * .tripId() + * .vehicleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalsAndDeparture]. */ + class Builder internal constructor() { + + private var arrivalEnabled: JsonField? = null + private var blockTripSequence: JsonField? = null + private var departureEnabled: JsonField? = null + private var numberOfStopsAway: JsonField? = null + private var predictedArrivalTime: JsonField? = null + private var predictedDepartureTime: JsonField? = null + private var routeId: JsonField? = null + private var scheduledArrivalTime: JsonField? = null + private var scheduledDepartureTime: JsonField? = null + private var serviceDate: JsonField? = null + private var stopId: JsonField? = null + private var stopSequence: JsonField? = null + private var totalStopsInTrip: JsonField? = null + private var tripHeadsign: JsonField? = null + private var tripId: JsonField? = null + private var vehicleId: JsonField? = null + private var actualTrack: JsonField = JsonMissing.of() + private var distanceFromStop: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var historicalOccupancy: JsonField = JsonMissing.of() + private var lastUpdateTime: JsonField = JsonMissing.of() + private var occupancyStatus: JsonField = JsonMissing.of() + private var predicted: JsonField = JsonMissing.of() + private var predictedArrivalInterval: JsonField = JsonMissing.of() + private var predictedDepartureInterval: JsonField = JsonMissing.of() + private var predictedOccupancy: JsonField = JsonMissing.of() + private var routeLongName: JsonField = JsonMissing.of() + private var routeShortName: JsonField = JsonMissing.of() + private var scheduledArrivalInterval: JsonField = JsonMissing.of() + private var scheduledDepartureInterval: JsonField = JsonMissing.of() + private var scheduledTrack: JsonField = JsonMissing.of() + private var situationIds: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var tripStatus: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(arrivalsAndDeparture: ArrivalsAndDeparture) = apply { + arrivalEnabled = arrivalsAndDeparture.arrivalEnabled + blockTripSequence = arrivalsAndDeparture.blockTripSequence + departureEnabled = arrivalsAndDeparture.departureEnabled + numberOfStopsAway = arrivalsAndDeparture.numberOfStopsAway + predictedArrivalTime = arrivalsAndDeparture.predictedArrivalTime + predictedDepartureTime = arrivalsAndDeparture.predictedDepartureTime + routeId = arrivalsAndDeparture.routeId + scheduledArrivalTime = arrivalsAndDeparture.scheduledArrivalTime + scheduledDepartureTime = arrivalsAndDeparture.scheduledDepartureTime + serviceDate = arrivalsAndDeparture.serviceDate + stopId = arrivalsAndDeparture.stopId + stopSequence = arrivalsAndDeparture.stopSequence + totalStopsInTrip = arrivalsAndDeparture.totalStopsInTrip + tripHeadsign = arrivalsAndDeparture.tripHeadsign + tripId = arrivalsAndDeparture.tripId + vehicleId = arrivalsAndDeparture.vehicleId + actualTrack = arrivalsAndDeparture.actualTrack + distanceFromStop = arrivalsAndDeparture.distanceFromStop + frequency = arrivalsAndDeparture.frequency + historicalOccupancy = arrivalsAndDeparture.historicalOccupancy + lastUpdateTime = arrivalsAndDeparture.lastUpdateTime + occupancyStatus = arrivalsAndDeparture.occupancyStatus + predicted = arrivalsAndDeparture.predicted + predictedArrivalInterval = arrivalsAndDeparture.predictedArrivalInterval + predictedDepartureInterval = arrivalsAndDeparture.predictedDepartureInterval + predictedOccupancy = arrivalsAndDeparture.predictedOccupancy + routeLongName = arrivalsAndDeparture.routeLongName + routeShortName = arrivalsAndDeparture.routeShortName + scheduledArrivalInterval = arrivalsAndDeparture.scheduledArrivalInterval + scheduledDepartureInterval = arrivalsAndDeparture.scheduledDepartureInterval + scheduledTrack = arrivalsAndDeparture.scheduledTrack + situationIds = arrivalsAndDeparture.situationIds.map { it.toMutableList() } + status = arrivalsAndDeparture.status + tripStatus = arrivalsAndDeparture.tripStatus + additionalProperties = + arrivalsAndDeparture.additionalProperties.toMutableMap() + } + + /** Indicates if riders can arrive on this transit vehicle. */ + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) + + /** + * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun arrivalEnabled(arrivalEnabled: JsonField) = apply { + this.arrivalEnabled = arrivalEnabled + } + + /** + * Index of this arrival’s trip into the sequence of trips for the active block. + */ + fun blockTripSequence(blockTripSequence: Long) = + blockTripSequence(JsonField.of(blockTripSequence)) + + /** + * Sets [Builder.blockTripSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.blockTripSequence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun blockTripSequence(blockTripSequence: JsonField) = apply { + this.blockTripSequence = blockTripSequence + } + + /** Indicates if riders can depart from this transit vehicle. */ + fun departureEnabled(departureEnabled: Boolean) = + departureEnabled(JsonField.of(departureEnabled)) + + /** + * Sets [Builder.departureEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.departureEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun departureEnabled(departureEnabled: JsonField) = apply { + this.departureEnabled = departureEnabled + } + + /** + * Number of stops between the arriving transit vehicle and the current stop + * (excluding the current stop). + */ + fun numberOfStopsAway(numberOfStopsAway: Long) = + numberOfStopsAway(JsonField.of(numberOfStopsAway)) + + /** + * Sets [Builder.numberOfStopsAway] to an arbitrary JSON value. + * + * You should usually call [Builder.numberOfStopsAway] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun numberOfStopsAway(numberOfStopsAway: JsonField) = apply { + this.numberOfStopsAway = numberOfStopsAway + } + + /** + * Predicted arrival time, in milliseconds since Unix epoch (zero if no + * real-time available). + */ + fun predictedArrivalTime(predictedArrivalTime: Long) = + predictedArrivalTime(JsonField.of(predictedArrivalTime)) + + /** + * Sets [Builder.predictedArrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedArrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedArrivalTime(predictedArrivalTime: JsonField) = apply { + this.predictedArrivalTime = predictedArrivalTime + } + + /** + * Predicted departure time, in milliseconds since Unix epoch (zero if no + * real-time available). + */ + fun predictedDepartureTime(predictedDepartureTime: Long) = + predictedDepartureTime(JsonField.of(predictedDepartureTime)) + + /** + * Sets [Builder.predictedDepartureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedDepartureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedDepartureTime(predictedDepartureTime: JsonField) = apply { + this.predictedDepartureTime = predictedDepartureTime + } + + /** The ID of the route for the arriving vehicle. */ + fun routeId(routeId: String) = routeId(JsonField.of(routeId)) + + /** + * Sets [Builder.routeId] to an arbitrary JSON value. + * + * You should usually call [Builder.routeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routeId(routeId: JsonField) = apply { this.routeId = routeId } + + /** Scheduled arrival time, in milliseconds since Unix epoch. */ + fun scheduledArrivalTime(scheduledArrivalTime: Long) = + scheduledArrivalTime(JsonField.of(scheduledArrivalTime)) + + /** + * Sets [Builder.scheduledArrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledArrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledArrivalTime(scheduledArrivalTime: JsonField) = apply { + this.scheduledArrivalTime = scheduledArrivalTime + } + + /** Scheduled departure time, in milliseconds since Unix epoch. */ + fun scheduledDepartureTime(scheduledDepartureTime: Long) = + scheduledDepartureTime(JsonField.of(scheduledDepartureTime)) + + /** + * Sets [Builder.scheduledDepartureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDepartureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledDepartureTime(scheduledDepartureTime: JsonField) = apply { + this.scheduledDepartureTime = scheduledDepartureTime + } + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + */ + fun serviceDate(serviceDate: Long) = serviceDate(JsonField.of(serviceDate)) + + /** + * Sets [Builder.serviceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceDate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceDate(serviceDate: JsonField) = apply { + this.serviceDate = serviceDate + } + + /** The ID of the stop the vehicle is arriving at. */ + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + /** + * Index of the stop into the sequence of stops that make up the trip for this + * arrival. + */ + fun stopSequence(stopSequence: Long) = stopSequence(JsonField.of(stopSequence)) + + /** + * Sets [Builder.stopSequence] to an arbitrary JSON value. + * + * You should usually call [Builder.stopSequence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun stopSequence(stopSequence: JsonField) = apply { + this.stopSequence = stopSequence + } + + /** Total number of stops visited on the trip for this arrival. */ + fun totalStopsInTrip(totalStopsInTrip: Long) = + totalStopsInTrip(JsonField.of(totalStopsInTrip)) + + /** + * Sets [Builder.totalStopsInTrip] to an arbitrary JSON value. + * + * You should usually call [Builder.totalStopsInTrip] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun totalStopsInTrip(totalStopsInTrip: JsonField) = apply { + this.totalStopsInTrip = totalStopsInTrip + } + + /** + * Optional trip headsign that potentially overrides the trip headsign in the + * referenced trip element. + */ + fun tripHeadsign(tripHeadsign: String) = + tripHeadsign(JsonField.of(tripHeadsign)) + + /** + * Sets [Builder.tripHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.tripHeadsign] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripHeadsign(tripHeadsign: JsonField) = apply { + this.tripHeadsign = tripHeadsign + } + + /** The ID of the trip for the arriving vehicle. */ + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + /** ID of the transit vehicle serving this trip. */ + fun vehicleId(vehicleId: String) = vehicleId(JsonField.of(vehicleId)) + + /** + * Sets [Builder.vehicleId] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun vehicleId(vehicleId: JsonField) = apply { + this.vehicleId = vehicleId + } + + /** The actual track information of the arriving transit vehicle. */ + fun actualTrack(actualTrack: String) = actualTrack(JsonField.of(actualTrack)) + + /** + * Sets [Builder.actualTrack] to an arbitrary JSON value. + * + * You should usually call [Builder.actualTrack] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun actualTrack(actualTrack: JsonField) = apply { + this.actualTrack = actualTrack + } + + /** Distance of the arriving transit vehicle from the stop, in meters. */ + fun distanceFromStop(distanceFromStop: Double) = + distanceFromStop(JsonField.of(distanceFromStop)) + + /** + * Sets [Builder.distanceFromStop] to an arbitrary JSON value. + * + * You should usually call [Builder.distanceFromStop] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun distanceFromStop(distanceFromStop: JsonField) = apply { + this.distanceFromStop = distanceFromStop + } + + /** Information about frequency-based scheduling, if applicable to the trip. */ + fun frequency(frequency: String) = frequency(JsonField.of(frequency)) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Historical occupancy information of the transit vehicle. */ + fun historicalOccupancy(historicalOccupancy: String) = + historicalOccupancy(JsonField.of(historicalOccupancy)) + + /** + * Sets [Builder.historicalOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.historicalOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun historicalOccupancy(historicalOccupancy: JsonField) = apply { + this.historicalOccupancy = historicalOccupancy + } + + /** Timestamp of the last update time for this arrival. */ + fun lastUpdateTime(lastUpdateTime: Long) = + lastUpdateTime(JsonField.of(lastUpdateTime)) + + /** + * Sets [Builder.lastUpdateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdateTime] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastUpdateTime(lastUpdateTime: JsonField) = apply { + this.lastUpdateTime = lastUpdateTime + } + + /** Current occupancy status of the transit vehicle. */ + fun occupancyStatus(occupancyStatus: String) = + occupancyStatus(JsonField.of(occupancyStatus)) + + /** + * Sets [Builder.occupancyStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.occupancyStatus] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun occupancyStatus(occupancyStatus: JsonField) = apply { + this.occupancyStatus = occupancyStatus + } + + /** Indicates if real-time arrival info is available for this trip. */ + fun predicted(predicted: Boolean) = predicted(JsonField.of(predicted)) + + /** + * Sets [Builder.predicted] to an arbitrary JSON value. + * + * You should usually call [Builder.predicted] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun predicted(predicted: JsonField) = apply { + this.predicted = predicted + } + + /** Interval for predicted arrival time, if available. */ + fun predictedArrivalInterval(predictedArrivalInterval: String) = + predictedArrivalInterval(JsonField.of(predictedArrivalInterval)) + + /** + * Sets [Builder.predictedArrivalInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedArrivalInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedArrivalInterval(predictedArrivalInterval: JsonField) = + apply { + this.predictedArrivalInterval = predictedArrivalInterval + } + + /** Interval for predicted departure time, if available. */ + fun predictedDepartureInterval(predictedDepartureInterval: String) = + predictedDepartureInterval(JsonField.of(predictedDepartureInterval)) + + /** + * Sets [Builder.predictedDepartureInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedDepartureInterval] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun predictedDepartureInterval(predictedDepartureInterval: JsonField) = + apply { + this.predictedDepartureInterval = predictedDepartureInterval + } + + /** Predicted occupancy status of the transit vehicle. */ + fun predictedOccupancy(predictedOccupancy: String) = + predictedOccupancy(JsonField.of(predictedOccupancy)) + + /** + * Sets [Builder.predictedOccupancy] to an arbitrary JSON value. + * + * You should usually call [Builder.predictedOccupancy] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictedOccupancy(predictedOccupancy: JsonField) = apply { + this.predictedOccupancy = predictedOccupancy + } + + /** + * Optional route long name that potentially overrides the route long name in + * the referenced route element. + */ + fun routeLongName(routeLongName: String) = + routeLongName(JsonField.of(routeLongName)) + + /** + * Sets [Builder.routeLongName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeLongName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun routeLongName(routeLongName: JsonField) = apply { + this.routeLongName = routeLongName + } + + /** + * Optional route short name that potentially overrides the route short name in + * the referenced route element. + */ + fun routeShortName(routeShortName: String) = + routeShortName(JsonField.of(routeShortName)) + + /** + * Sets [Builder.routeShortName] to an arbitrary JSON value. + * + * You should usually call [Builder.routeShortName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun routeShortName(routeShortName: JsonField) = apply { + this.routeShortName = routeShortName + } + + /** Interval for scheduled arrival time. */ + fun scheduledArrivalInterval(scheduledArrivalInterval: String) = + scheduledArrivalInterval(JsonField.of(scheduledArrivalInterval)) + + /** + * Sets [Builder.scheduledArrivalInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledArrivalInterval] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledArrivalInterval(scheduledArrivalInterval: JsonField) = + apply { + this.scheduledArrivalInterval = scheduledArrivalInterval + } + + /** Interval for scheduled departure time. */ + fun scheduledDepartureInterval(scheduledDepartureInterval: String) = + scheduledDepartureInterval(JsonField.of(scheduledDepartureInterval)) + + /** + * Sets [Builder.scheduledDepartureInterval] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledDepartureInterval] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduledDepartureInterval(scheduledDepartureInterval: JsonField) = + apply { + this.scheduledDepartureInterval = scheduledDepartureInterval + } + + /** Scheduled track information of the arriving transit vehicle. */ + fun scheduledTrack(scheduledTrack: String) = + scheduledTrack(JsonField.of(scheduledTrack)) + + /** + * Sets [Builder.scheduledTrack] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledTrack] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scheduledTrack(scheduledTrack: JsonField) = apply { + this.scheduledTrack = scheduledTrack + } + + /** References to situation elements (if any) applicable to this arrival. */ + fun situationIds(situationIds: List) = + situationIds(JsonField.of(situationIds)) + + /** + * Sets [Builder.situationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.situationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun situationIds(situationIds: JsonField>) = apply { + this.situationIds = situationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [situationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSituationId(situationId: String) = apply { + situationIds = + (situationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("situationIds", it).add(situationId) + } + } + + /** Current status of the arrival. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Trip-specific status for the arriving transit vehicle. */ + fun tripStatus(tripStatus: TripStatus) = tripStatus(JsonField.of(tripStatus)) + + /** + * Sets [Builder.tripStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.tripStatus] with a well-typed [TripStatus] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripStatus(tripStatus: JsonField) = apply { + this.tripStatus = tripStatus + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ArrivalsAndDeparture]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .blockTripSequence() + * .departureEnabled() + * .numberOfStopsAway() + * .predictedArrivalTime() + * .predictedDepartureTime() + * .routeId() + * .scheduledArrivalTime() + * .scheduledDepartureTime() + * .serviceDate() + * .stopId() + * .stopSequence() + * .totalStopsInTrip() + * .tripHeadsign() + * .tripId() + * .vehicleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArrivalsAndDeparture = + ArrivalsAndDeparture( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("blockTripSequence", blockTripSequence), + checkRequired("departureEnabled", departureEnabled), + checkRequired("numberOfStopsAway", numberOfStopsAway), + checkRequired("predictedArrivalTime", predictedArrivalTime), + checkRequired("predictedDepartureTime", predictedDepartureTime), + checkRequired("routeId", routeId), + checkRequired("scheduledArrivalTime", scheduledArrivalTime), + checkRequired("scheduledDepartureTime", scheduledDepartureTime), + checkRequired("serviceDate", serviceDate), + checkRequired("stopId", stopId), + checkRequired("stopSequence", stopSequence), + checkRequired("totalStopsInTrip", totalStopsInTrip), + checkRequired("tripHeadsign", tripHeadsign), + checkRequired("tripId", tripId), + checkRequired("vehicleId", vehicleId), + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + (situationIds ?: JsonMissing.of()).map { it.toImmutable() }, + status, + tripStatus, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ArrivalsAndDeparture = apply { + if (validated) { + return@apply + } + + arrivalEnabled() + blockTripSequence() + departureEnabled() + numberOfStopsAway() + predictedArrivalTime() + predictedDepartureTime() + routeId() + scheduledArrivalTime() + scheduledDepartureTime() + serviceDate() + stopId() + stopSequence() + totalStopsInTrip() + tripHeadsign() + tripId() + vehicleId() + actualTrack() + distanceFromStop() + frequency() + historicalOccupancy() + lastUpdateTime() + occupancyStatus() + predicted() + predictedArrivalInterval() + predictedDepartureInterval() + predictedOccupancy() + routeLongName() + routeShortName() + scheduledArrivalInterval() + scheduledDepartureInterval() + scheduledTrack() + situationIds() + status() + tripStatus().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + + (if (blockTripSequence.asKnown().isPresent) 1 else 0) + + (if (departureEnabled.asKnown().isPresent) 1 else 0) + + (if (numberOfStopsAway.asKnown().isPresent) 1 else 0) + + (if (predictedArrivalTime.asKnown().isPresent) 1 else 0) + + (if (predictedDepartureTime.asKnown().isPresent) 1 else 0) + + (if (routeId.asKnown().isPresent) 1 else 0) + + (if (scheduledArrivalTime.asKnown().isPresent) 1 else 0) + + (if (scheduledDepartureTime.asKnown().isPresent) 1 else 0) + + (if (serviceDate.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (stopSequence.asKnown().isPresent) 1 else 0) + + (if (totalStopsInTrip.asKnown().isPresent) 1 else 0) + + (if (tripHeadsign.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (vehicleId.asKnown().isPresent) 1 else 0) + + (if (actualTrack.asKnown().isPresent) 1 else 0) + + (if (distanceFromStop.asKnown().isPresent) 1 else 0) + + (if (frequency.asKnown().isPresent) 1 else 0) + + (if (historicalOccupancy.asKnown().isPresent) 1 else 0) + + (if (lastUpdateTime.asKnown().isPresent) 1 else 0) + + (if (occupancyStatus.asKnown().isPresent) 1 else 0) + + (if (predicted.asKnown().isPresent) 1 else 0) + + (if (predictedArrivalInterval.asKnown().isPresent) 1 else 0) + + (if (predictedDepartureInterval.asKnown().isPresent) 1 else 0) + + (if (predictedOccupancy.asKnown().isPresent) 1 else 0) + + (if (routeLongName.asKnown().isPresent) 1 else 0) + + (if (routeShortName.asKnown().isPresent) 1 else 0) + + (if (scheduledArrivalInterval.asKnown().isPresent) 1 else 0) + + (if (scheduledDepartureInterval.asKnown().isPresent) 1 else 0) + + (if (scheduledTrack.asKnown().isPresent) 1 else 0) + + (situationIds.asKnown().getOrNull()?.size ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (tripStatus.asKnown().getOrNull()?.validity() ?: 0) + + /** Trip-specific status for the arriving transit vehicle. */ + class TripStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun blockTripSequence(): Long = + blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active + * trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun distanceAlongTrip(): Double = + distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyCapacity(): Long = + occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for + * early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scheduleDeviation(): Long = + scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit + * vehicle (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastKnownLocation && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Position]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripStatus && + activeTripId == other.activeTripId && + blockTripSequence == other.blockTripSequence && + closestStop == other.closestStop && + distanceAlongTrip == other.distanceAlongTrip && + lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && + lastLocationUpdateTime == other.lastLocationUpdateTime && + lastUpdateTime == other.lastUpdateTime && + occupancyCapacity == other.occupancyCapacity && + occupancyCount == other.occupancyCount && + occupancyStatus == other.occupancyStatus && + phase == other.phase && + predicted == other.predicted && + scheduleDeviation == other.scheduleDeviation && + serviceDate == other.serviceDate && + status == other.status && + totalDistanceAlongTrip == other.totalDistanceAlongTrip && + closestStopTimeOffset == other.closestStopTimeOffset && + frequency == other.frequency && + lastKnownLocation == other.lastKnownLocation && + lastKnownOrientation == other.lastKnownOrientation && + nextStop == other.nextStop && + nextStopTimeOffset == other.nextStopTimeOffset && + orientation == other.orientation && + position == other.position && + scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && + situationIds == other.situationIds && + vehicleId == other.vehicleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ArrivalsAndDeparture && + arrivalEnabled == other.arrivalEnabled && + blockTripSequence == other.blockTripSequence && + departureEnabled == other.departureEnabled && + numberOfStopsAway == other.numberOfStopsAway && + predictedArrivalTime == other.predictedArrivalTime && + predictedDepartureTime == other.predictedDepartureTime && + routeId == other.routeId && + scheduledArrivalTime == other.scheduledArrivalTime && + scheduledDepartureTime == other.scheduledDepartureTime && + serviceDate == other.serviceDate && + stopId == other.stopId && + stopSequence == other.stopSequence && + totalStopsInTrip == other.totalStopsInTrip && + tripHeadsign == other.tripHeadsign && + tripId == other.tripId && + vehicleId == other.vehicleId && + actualTrack == other.actualTrack && + distanceFromStop == other.distanceFromStop && + frequency == other.frequency && + historicalOccupancy == other.historicalOccupancy && + lastUpdateTime == other.lastUpdateTime && + occupancyStatus == other.occupancyStatus && + predicted == other.predicted && + predictedArrivalInterval == other.predictedArrivalInterval && + predictedDepartureInterval == other.predictedDepartureInterval && + predictedOccupancy == other.predictedOccupancy && + routeLongName == other.routeLongName && + routeShortName == other.routeShortName && + scheduledArrivalInterval == other.scheduledArrivalInterval && + scheduledDepartureInterval == other.scheduledDepartureInterval && + scheduledTrack == other.scheduledTrack && + situationIds == other.situationIds && + status == other.status && + tripStatus == other.tripStatus && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalEnabled, + blockTripSequence, + departureEnabled, + numberOfStopsAway, + predictedArrivalTime, + predictedDepartureTime, + routeId, + scheduledArrivalTime, + scheduledDepartureTime, + serviceDate, + stopId, + stopSequence, + totalStopsInTrip, + tripHeadsign, + tripId, + vehicleId, + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + situationIds, + status, + tripStatus, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ArrivalsAndDeparture{arrivalEnabled=$arrivalEnabled, blockTripSequence=$blockTripSequence, departureEnabled=$departureEnabled, numberOfStopsAway=$numberOfStopsAway, predictedArrivalTime=$predictedArrivalTime, predictedDepartureTime=$predictedDepartureTime, routeId=$routeId, scheduledArrivalTime=$scheduledArrivalTime, scheduledDepartureTime=$scheduledDepartureTime, serviceDate=$serviceDate, stopId=$stopId, stopSequence=$stopSequence, totalStopsInTrip=$totalStopsInTrip, tripHeadsign=$tripHeadsign, tripId=$tripId, vehicleId=$vehicleId, actualTrack=$actualTrack, distanceFromStop=$distanceFromStop, frequency=$frequency, historicalOccupancy=$historicalOccupancy, lastUpdateTime=$lastUpdateTime, occupancyStatus=$occupancyStatus, predicted=$predicted, predictedArrivalInterval=$predictedArrivalInterval, predictedDepartureInterval=$predictedDepartureInterval, predictedOccupancy=$predictedOccupancy, routeLongName=$routeLongName, routeShortName=$routeShortName, scheduledArrivalInterval=$scheduledArrivalInterval, scheduledDepartureInterval=$scheduledDepartureInterval, scheduledTrack=$scheduledTrack, situationIds=$situationIds, status=$status, tripStatus=$tripStatus, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entry && + arrivalsAndDepartures == other.arrivalsAndDepartures && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(arrivalsAndDepartures, additionalProperties) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ArrivalAndDepartureListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt new file mode 100644 index 0000000..7d61e9d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParams.kt @@ -0,0 +1,299 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** arrival-and-departure-for-stop */ +class ArrivalAndDepartureRetrieveParams +private constructor( + private val stopId: String?, + private val serviceDate: Long, + private val tripId: String, + private val stopSequence: Long?, + private val time: Long?, + private val vehicleId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun stopId(): Optional = Optional.ofNullable(stopId) + + fun serviceDate(): Long = serviceDate + + fun tripId(): String = tripId + + fun stopSequence(): Optional = Optional.ofNullable(stopSequence) + + fun time(): Optional = Optional.ofNullable(time) + + fun vehicleId(): Optional = Optional.ofNullable(vehicleId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ArrivalAndDepartureRetrieveParams]. + * + * The following fields are required: + * ```java + * .serviceDate() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ArrivalAndDepartureRetrieveParams]. */ + class Builder internal constructor() { + + private var stopId: String? = null + private var serviceDate: Long? = null + private var tripId: String? = null + private var stopSequence: Long? = null + private var time: Long? = null + private var vehicleId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(arrivalAndDepartureRetrieveParams: ArrivalAndDepartureRetrieveParams) = + apply { + 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 } + + /** Alias for calling [Builder.stopId] with `stopId.orElse(null)`. */ + fun stopId(stopId: Optional) = stopId(stopId.getOrNull()) + + fun serviceDate(serviceDate: Long) = apply { this.serviceDate = serviceDate } + + fun tripId(tripId: String) = apply { this.tripId = tripId } + + 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?) + + /** 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?) + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun vehicleId(vehicleId: String?) = apply { this.vehicleId = vehicleId } + + /** Alias for calling [Builder.vehicleId] with `vehicleId.orElse(null)`. */ + fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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( + stopId, + checkRequired("serviceDate", serviceDate), + checkRequired("tripId", tripId), + stopSequence, + time, + vehicleId, + 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 { + 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 + } + + return 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 + } + + override fun hashCode(): Int = + Objects.hash( + stopId, + serviceDate, + tripId, + stopSequence, + time, + vehicleId, + additionalHeaders, + additionalQueryParams, + ) + + 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/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt new file mode 100644 index 0000000..d06b629 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveResponse.kt @@ -0,0 +1,4069 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastKnownLocation && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripStatus && + activeTripId == other.activeTripId && + blockTripSequence == other.blockTripSequence && + closestStop == other.closestStop && + distanceAlongTrip == other.distanceAlongTrip && + lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && + lastLocationUpdateTime == other.lastLocationUpdateTime && + lastUpdateTime == other.lastUpdateTime && + occupancyCapacity == other.occupancyCapacity && + occupancyCount == other.occupancyCount && + occupancyStatus == other.occupancyStatus && + phase == other.phase && + predicted == other.predicted && + scheduleDeviation == other.scheduleDeviation && + serviceDate == other.serviceDate && + status == other.status && + totalDistanceAlongTrip == other.totalDistanceAlongTrip && + closestStopTimeOffset == other.closestStopTimeOffset && + frequency == other.frequency && + lastKnownLocation == other.lastKnownLocation && + lastKnownOrientation == other.lastKnownOrientation && + nextStop == other.nextStop && + nextStopTimeOffset == other.nextStopTimeOffset && + orientation == other.orientation && + position == other.position && + scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && + situationIds == other.situationIds && + vehicleId == other.vehicleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalEnabled, + blockTripSequence, + departureEnabled, + numberOfStopsAway, + predictedArrivalTime, + predictedDepartureTime, + routeId, + scheduledArrivalTime, + scheduledDepartureTime, + serviceDate, + stopId, + stopSequence, + totalStopsInTrip, + tripHeadsign, + tripId, + vehicleId, + actualTrack, + distanceFromStop, + frequency, + historicalOccupancy, + lastUpdateTime, + occupancyStatus, + predicted, + predictedArrivalInterval, + predictedDepartureInterval, + predictedOccupancy, + routeLongName, + routeShortName, + scheduledArrivalInterval, + scheduledDepartureInterval, + scheduledTrack, + situationIds, + status, + tripStatus, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ArrivalAndDepartureRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/block/BlockRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveParams.kt new file mode 100644 index 0000000..5f0e88d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.block + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun blockId(): Optional = Optional.ofNullable(blockId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BlockRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BlockRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BlockRetrieveParams]. */ + class Builder internal constructor() { + + private var blockId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(blockRetrieveParams: BlockRetrieveParams) = apply { + blockId = blockRetrieveParams.blockId + additionalHeaders = blockRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = blockRetrieveParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BlockRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BlockRetrieveParams = + 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 + } + + return other is BlockRetrieveParams && + blockId == other.blockId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(blockId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BlockRetrieveParams{blockId=$blockId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..45310ae --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/block/BlockRetrieveResponse.kt @@ -0,0 +1,2041 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is StopTime && + arrivalTime == other.arrivalTime && + departureTime == other.departureTime && + stopId == other.stopId && + dropOffType == other.dropOffType && + pickupType == other.pickupType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalTime, + departureTime, + stopId, + dropOffType, + pickupType, + additionalProperties, + ) + } + + 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 other is BlockStopTime && + accumulatedSlackTime == other.accumulatedSlackTime && + blockSequence == other.blockSequence && + distanceAlongBlock == other.distanceAlongBlock && + stopTime == other.stopTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accumulatedSlackTime, + blockSequence, + distanceAlongBlock, + stopTime, + additionalProperties, + ) + } + + 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 other is Trip && + accumulatedSlackTime == other.accumulatedSlackTime && + blockStopTimes == other.blockStopTimes && + distanceAlongBlock == other.distanceAlongBlock && + tripId == other.tripId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accumulatedSlackTime, + blockStopTimes, + distanceAlongBlock, + tripId, + additionalProperties, + ) + } + + 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 other is Configuration && + activeServiceIds == other.activeServiceIds && + trips == other.trips && + inactiveServiceIds == other.inactiveServiceIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(activeServiceIds, trips, inactiveServiceIds, additionalProperties) + } + + 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 other is Entry && + id == other.id && + configurations == other.configurations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, configurations, additionalProperties) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BlockRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/config/ConfigRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveParams.kt new file mode 100644 index 0000000..a57ceb1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.config + +import java.util.Objects +import org.onebusaway.core.Params +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** config */ +class ConfigRetrieveParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ConfigRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ConfigRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigRetrieveParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(configRetrieveParams: ConfigRetrieveParams) = apply { + additionalHeaders = configRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = configRetrieveParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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 + } + + return other is ConfigRetrieveParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "ConfigRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..36b882a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/config/ConfigRetrieveResponse.kt @@ -0,0 +1,1798 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 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 + } + + 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, + ) + } + + 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 other is Entry && + id == other.id && + gitProperties == other.gitProperties && + name == other.name && + serviceDateFrom == other.serviceDateFrom && + serviceDateTo == other.serviceDateTo && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + gitProperties, + name, + serviceDateFrom, + serviceDateTo, + additionalProperties, + ) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/currenttime/CurrentTimeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParams.kt new file mode 100644 index 0000000..92dcc27 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.currenttime + +import java.util.Objects +import org.onebusaway.core.Params +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** current-time */ +class CurrentTimeRetrieveParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentTimeRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CurrentTimeRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentTimeRetrieveParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentTimeRetrieveParams: CurrentTimeRetrieveParams) = apply { + additionalHeaders = currentTimeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = currentTimeRetrieveParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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 + } + + return other is CurrentTimeRetrieveParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentTimeRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..7bccd50 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveResponse.kt @@ -0,0 +1,702 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 other is Entry && + readableTime == other.readableTime && + time == other.time && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(readableTime, time, additionalProperties) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentTimeRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt new file mode 100644 index 0000000..e312c7c --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParams.kt @@ -0,0 +1,467 @@ +// File generated from our OpenAPI spec by Stainless. + +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.Params +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 +private constructor( + private val stopId: String?, + private val code: Code?, + private val userComment: String?, + private val userLat: Float?, + private val userLocationAccuracy: Float?, + private val userLon: Float?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun stopId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ReportProblemWithStopRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ReportProblemWithStopRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReportProblemWithStopRetrieveParams]. */ + class Builder internal constructor() { + + private var stopId: String? = null + private var code: Code? = null + private var userComment: String? = 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() + + @JvmSynthetic + internal fun from( + reportProblemWithStopRetrieveParams: ReportProblemWithStopRetrieveParams + ) = apply { + 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 } + + /** 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 } + + /** 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 } + + /** 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: Float?) = apply { this.userLat = userLat } + + /** + * Alias for [Builder.userLat]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLat(userLat: Float) = userLat(userLat as Float?) + + /** 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: Float?) = apply { + this.userLocationAccuracy = userLocationAccuracy + } + + /** + * Alias for [Builder.userLocationAccuracy]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLocationAccuracy(userLocationAccuracy: Float) = + userLocationAccuracy(userLocationAccuracy as Float?) + + /** + * 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: Float?) = apply { this.userLon = userLon } + + /** + * Alias for [Builder.userLon]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLon(userLon: Float) = userLon(userLon as Float?) + + /** Alias for calling [Builder.userLon] with `userLon.orElse(null)`. */ + fun userLon(userLon: Optional) = userLon(userLon.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ReportProblemWithStopRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ReportProblemWithStopRetrieveParams = + ReportProblemWithStopRetrieveParams( + stopId, + code, + userComment, + userLat, + userLocationAccuracy, + userLon, + 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 { + 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 { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val STOP_NAME_WRONG = of("stop_name_wrong") + + @JvmField val STOP_NUMBER_WRONG = of("stop_number_wrong") + + @JvmField val STOP_LOCATION_WRONG = of("stop_location_wrong") + + @JvmField val ROUTE_OR_TRIP_MISSING = of("route_or_trip_missing") + + @JvmField val OTHER = of("other") + + @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, + STOP_LOCATION_WRONG, + ROUTE_OR_TRIP_MISSING, + 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 + STOP_NUMBER_WRONG -> Value.STOP_NUMBER_WRONG + STOP_LOCATION_WRONG -> Value.STOP_LOCATION_WRONG + ROUTE_OR_TRIP_MISSING -> Value.ROUTE_OR_TRIP_MISSING + OTHER -> Value.OTHER + 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 + STOP_NUMBER_WRONG -> Known.STOP_NUMBER_WRONG + STOP_LOCATION_WRONG -> Known.STOP_LOCATION_WRONG + ROUTE_OR_TRIP_MISSING -> Known.ROUTE_OR_TRIP_MISSING + OTHER -> Known.OTHER + else -> throw OnebusawaySdkInvalidDataException("Unknown Code: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OnebusawaySdkInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OnebusawaySdkInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): 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) { + return true + } + + return other is Code && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return 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 + } + + override fun hashCode(): Int = + Objects.hash( + stopId, + code, + userComment, + userLat, + userLocationAccuracy, + userLon, + additionalHeaders, + additionalQueryParams, + ) + + 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/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt new file mode 100644 index 0000000..8ced8bf --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParams.kt @@ -0,0 +1,571 @@ +// File generated from our OpenAPI spec by Stainless. + +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.Params +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 +private constructor( + private val tripId: String?, + private val code: Code?, + private val serviceDate: Long?, + private val stopId: String?, + private val userComment: String?, + private val userLat: Float?, + private val userLocationAccuracy: Float?, + private val userLon: Float?, + private val userOnVehicle: Boolean?, + private val userVehicleNumber: String?, + private val vehicleId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tripId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ReportProblemWithTripRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ReportProblemWithTripRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReportProblemWithTripRetrieveParams]. */ + class Builder internal constructor() { + + private var tripId: String? = null + private var code: Code? = null + private var serviceDate: Long? = null + private var stopId: String? = null + private var userComment: String? = 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 + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + reportProblemWithTripRetrieveParams: ReportProblemWithTripRetrieveParams + ) = apply { + 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 } + + /** 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 } + + /** 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 } + + /** + * Alias for [Builder.serviceDate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun serviceDate(serviceDate: Long) = serviceDate(serviceDate 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 } + + /** 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 } + + /** 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: Float?) = apply { this.userLat = userLat } + + /** + * Alias for [Builder.userLat]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLat(userLat: Float) = userLat(userLat as Float?) + + /** 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: Float?) = apply { + this.userLocationAccuracy = userLocationAccuracy + } + + /** + * Alias for [Builder.userLocationAccuracy]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLocationAccuracy(userLocationAccuracy: Float) = + userLocationAccuracy(userLocationAccuracy as Float?) + + /** + * 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: Float?) = apply { this.userLon = userLon } + + /** + * Alias for [Builder.userLon]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userLon(userLon: Float) = userLon(userLon as Float?) + + /** 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 } + + /** + * Alias for [Builder.userOnVehicle]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun userOnVehicle(userOnVehicle: Boolean) = userOnVehicle(userOnVehicle as Boolean?) + + /** Alias for calling [Builder.userOnVehicle] with `userOnVehicle.orElse(null)`. */ + fun userOnVehicle(userOnVehicle: Optional) = + userOnVehicle(userOnVehicle.getOrNull()) + + /** The vehicle number, as reported by the user */ + fun userVehicleNumber(userVehicleNumber: String?) = apply { + this.userVehicleNumber = userVehicleNumber + } + + /** Alias for calling [Builder.userVehicleNumber] with `userVehicleNumber.orElse(null)`. */ + fun userVehicleNumber(userVehicleNumber: Optional) = + userVehicleNumber(userVehicleNumber.getOrNull()) + + /** The vehicle actively serving the trip */ + fun vehicleId(vehicleId: String?) = apply { this.vehicleId = vehicleId } + + /** Alias for calling [Builder.vehicleId] with `vehicleId.orElse(null)`. */ + fun vehicleId(vehicleId: Optional) = vehicleId(vehicleId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ReportProblemWithTripRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ReportProblemWithTripRetrieveParams = + ReportProblemWithTripRetrieveParams( + tripId, + code, + serviceDate, + stopId, + userComment, + userLat, + userLocationAccuracy, + userLon, + userOnVehicle, + userVehicleNumber, + vehicleId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VEHICLE_NEVER_CAME = of("vehicle_never_came") + + @JvmField val VEHICLE_CAME_EARLY = of("vehicle_came_early") + + @JvmField val VEHICLE_CAME_LATE = of("vehicle_came_late") + + @JvmField val WRONG_HEADSIGN = of("wrong_headsign") + + @JvmField val VEHICLE_DOES_NOT_STOP_HERE = of("vehicle_does_not_stop_here") + + @JvmField val OTHER = of("other") + + @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, + VEHICLE_CAME_LATE, + WRONG_HEADSIGN, + VEHICLE_DOES_NOT_STOP_HERE, + 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, + VEHICLE_CAME_LATE, + 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 + VEHICLE_CAME_EARLY -> Value.VEHICLE_CAME_EARLY + VEHICLE_CAME_LATE -> Value.VEHICLE_CAME_LATE + WRONG_HEADSIGN -> Value.WRONG_HEADSIGN + VEHICLE_DOES_NOT_STOP_HERE -> Value.VEHICLE_DOES_NOT_STOP_HERE + OTHER -> Value.OTHER + 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 + VEHICLE_CAME_EARLY -> Known.VEHICLE_CAME_EARLY + VEHICLE_CAME_LATE -> Known.VEHICLE_CAME_LATE + WRONG_HEADSIGN -> Known.WRONG_HEADSIGN + VEHICLE_DOES_NOT_STOP_HERE -> Known.VEHICLE_DOES_NOT_STOP_HERE + OTHER -> Known.OTHER + else -> throw OnebusawaySdkInvalidDataException("Unknown Code: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OnebusawaySdkInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OnebusawaySdkInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): 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) { + return true + } + + return other is Code && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return 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 + } + + override fun hashCode(): Int = + Objects.hash( + tripId, + code, + serviceDate, + stopId, + userComment, + userLat, + userLocationAccuracy, + userLon, + userOnVehicle, + userVehicleNumber, + vehicleId, + additionalHeaders, + additionalQueryParams, + ) + + 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/route/RouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveParams.kt new file mode 100644 index 0000000..96f1996 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.route + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun routeId(): Optional = Optional.ofNullable(routeId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RouteRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RouteRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouteRetrieveParams]. */ + class Builder internal constructor() { + + private var routeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(routeRetrieveParams: RouteRetrieveParams) = apply { + routeId = routeRetrieveParams.routeId + additionalHeaders = routeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = routeRetrieveParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RouteRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouteRetrieveParams = + 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 + } + + return other is RouteRetrieveParams && + routeId == other.routeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(routeId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RouteRetrieveParams{routeId=$routeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..652816e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/route/RouteRetrieveResponse.kt @@ -0,0 +1,1033 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties, + ) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RouteRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/routeidsforagency/RouteIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParams.kt new file mode 100644 index 0000000..064ef6d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routeidsforagency + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agencyId(): Optional = Optional.ofNullable(agencyId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RouteIdsForAgencyListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [RouteIdsForAgencyListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RouteIdsForAgencyListParams]. */ + class Builder internal constructor() { + + private var agencyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(routeIdsForAgencyListParams: RouteIdsForAgencyListParams) = apply { + agencyId = routeIdsForAgencyListParams.agencyId + additionalHeaders = routeIdsForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = routeIdsForAgencyListParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RouteIdsForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RouteIdsForAgencyListParams = + RouteIdsForAgencyListParams( + 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 + } + + return other is RouteIdsForAgencyListParams && + agencyId == other.agencyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(agencyId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RouteIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..9da440b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListResponse.kt @@ -0,0 +1,578 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, additionalProperties) + } + + 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 other is RouteIdsForAgencyListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/routesforagency/RoutesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParams.kt new file mode 100644 index 0000000..54f2a5a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforagency + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agencyId(): Optional = Optional.ofNullable(agencyId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RoutesForAgencyListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [RoutesForAgencyListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutesForAgencyListParams]. */ + class Builder internal constructor() { + + private var agencyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(routesForAgencyListParams: RoutesForAgencyListParams) = apply { + agencyId = routesForAgencyListParams.agencyId + additionalHeaders = routesForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = routesForAgencyListParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RoutesForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoutesForAgencyListParams = + RoutesForAgencyListParams( + 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 + } + + return other is RoutesForAgencyListParams && + agencyId == other.agencyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(agencyId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RoutesForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..b072b02 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListResponse.kt @@ -0,0 +1,1092 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties, + ) + } + + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, additionalProperties) + } + + 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 other is RoutesForAgencyListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/routesforlocation/RoutesForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParams.kt new file mode 100644 index 0000000..c4b1ee9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParams.kt @@ -0,0 +1,298 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforlocation + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** routes-for-location */ +class RoutesForLocationListParams +private constructor( + private val lat: Double, + private val lon: Double, + private val latSpan: Double?, + private val lonSpan: Double?, + private val query: String?, + private val radius: Double?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun lat(): Double = lat + + fun lon(): Double = lon + + fun latSpan(): Optional = Optional.ofNullable(latSpan) + + fun lonSpan(): Optional = Optional.ofNullable(lonSpan) + + fun query(): Optional = Optional.ofNullable(query) + + fun radius(): Optional = Optional.ofNullable(radius) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RoutesForLocationListParams]. + * + * The following fields are required: + * ```java + * .lat() + * .lon() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutesForLocationListParams]. */ + class Builder internal constructor() { + + private var lat: Double? = null + private var lon: Double? = null + private var latSpan: Double? = null + private var lonSpan: Double? = null + private var query: String? = null + private var radius: Double? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(routesForLocationListParams: RoutesForLocationListParams) = apply { + 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 } + + fun lon(lon: Double) = apply { this.lon = lon } + + fun latSpan(latSpan: Double?) = apply { this.latSpan = latSpan } + + /** + * Alias for [Builder.latSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latSpan(latSpan: Double) = latSpan(latSpan as Double?) + + /** Alias for calling [Builder.latSpan] with `latSpan.orElse(null)`. */ + fun latSpan(latSpan: Optional) = latSpan(latSpan.getOrNull()) + + fun lonSpan(lonSpan: Double?) = apply { this.lonSpan = lonSpan } + + /** + * Alias for [Builder.lonSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun lonSpan(lonSpan: Double) = lonSpan(lonSpan as Double?) + + /** Alias for calling [Builder.lonSpan] with `lonSpan.orElse(null)`. */ + fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.getOrNull()) + + fun query(query: String?) = apply { this.query = query } + + /** 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?) + + /** Alias for calling [Builder.radius] with `radius.orElse(null)`. */ + fun radius(radius: Optional) = radius(radius.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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), + checkRequired("lon", lon), + latSpan, + lonSpan, + query, + radius, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 + } + + return 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 + } + + override fun hashCode(): Int = + Objects.hash( + lat, + lon, + latSpan, + lonSpan, + query, + radius, + additionalHeaders, + additionalQueryParams, + ) + + 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/routesforlocation/RoutesForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt new file mode 100644 index 0000000..62747ce --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListResponse.kt @@ -0,0 +1,1131 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val 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(): 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: 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties, + ) + } + + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + outOfRange == other.outOfRange && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) + } + + 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 other is RoutesForLocationListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/scheduleforroute/ScheduleForRouteRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParams.kt new file mode 100644 index 0000000..eafeb3d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParams.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforroute + +import java.time.LocalDate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 date: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun routeId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ScheduleForRouteRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleForRouteRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleForRouteRetrieveParams]. */ + class Builder internal constructor() { + + private var routeId: String? = null + private var date: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(scheduleForRouteRetrieveParams: ScheduleForRouteRetrieveParams) = apply { + routeId = scheduleForRouteRetrieveParams.routeId + date = scheduleForRouteRetrieveParams.date + additionalHeaders = scheduleForRouteRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = scheduleForRouteRetrieveParams.additionalQueryParams.toBuilder() + } + + 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, + * defaults to current date) + */ + fun date(date: LocalDate?) = apply { this.date = date } + + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ScheduleForRouteRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ScheduleForRouteRetrieveParams = + ScheduleForRouteRetrieveParams( + 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 + } + + return other is ScheduleForRouteRetrieveParams && + routeId == other.routeId && + date == other.date && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(routeId, date, additionalHeaders, additionalQueryParams) + + 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/scheduleforroute/ScheduleForRouteRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt new file mode 100644 index 0000000..ba49db3 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveResponse.kt @@ -0,0 +1,3216 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") + @ExcludeMissing + code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val directionId: JsonField, + private val stopIds: JsonField>, + private val tripHeadsigns: JsonField>, + private val tripIds: JsonField>, + private val tripsWithStopTimes: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val stopTimes: JsonField>, + private val tripId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("stopTimes") + @ExcludeMissing + stopTimes: JsonField> = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + ) : this(stopTimes, tripId, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun stopTimes(): List = stopTimes.getRequired("stopTimes") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * Returns the raw JSON value of [stopTimes]. + * + * Unlike [stopTimes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopTimes") + @ExcludeMissing + fun _stopTimes(): JsonField> = stopTimes + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arrivalEnabled: JsonField, + private val arrivalTime: JsonField, + private val departureEnabled: JsonField, + private val departureTime: JsonField, + private val stopId: JsonField, + private val tripId: JsonField, + private val serviceId: JsonField, + private val stopHeadsign: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("arrivalEnabled") + @ExcludeMissing + arrivalEnabled: JsonField = JsonMissing.of(), + @JsonProperty("arrivalTime") + @ExcludeMissing + arrivalTime: JsonField = JsonMissing.of(), + @JsonProperty("departureEnabled") + @ExcludeMissing + departureEnabled: JsonField = JsonMissing.of(), + @JsonProperty("departureTime") + @ExcludeMissing + departureTime: JsonField = JsonMissing.of(), + @JsonProperty("stopId") + @ExcludeMissing + stopId: JsonField = JsonMissing.of(), + @JsonProperty("tripId") + @ExcludeMissing + tripId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("stopHeadsign") + @ExcludeMissing + stopHeadsign: JsonField = JsonMissing.of(), + ) : this( + arrivalEnabled, + arrivalTime, + departureEnabled, + departureTime, + stopId, + tripId, + serviceId, + stopHeadsign, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun arrivalEnabled(): Boolean = arrivalEnabled.getRequired("arrivalEnabled") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun arrivalTime(): Long = arrivalTime.getRequired("arrivalTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun departureEnabled(): Boolean = + departureEnabled.getRequired("departureEnabled") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun departureTime(): Long = departureTime.getRequired("departureTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun stopId(): String = stopId.getRequired("stopId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ + fun tripId(): String = tripId.getRequired("tripId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun serviceId(): Optional = serviceId.getOptional("serviceId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun stopHeadsign(): Optional = + stopHeadsign.getOptional("stopHeadsign") + + /** + * Returns the raw JSON value of [arrivalEnabled]. + * + * Unlike [arrivalEnabled], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("arrivalEnabled") + @ExcludeMissing + fun _arrivalEnabled(): JsonField = arrivalEnabled + + /** + * Returns the raw JSON value of [arrivalTime]. + * + * Unlike [arrivalTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("arrivalTime") + @ExcludeMissing + fun _arrivalTime(): JsonField = arrivalTime + + /** + * Returns the raw JSON value of [departureEnabled]. + * + * Unlike [departureEnabled], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("departureEnabled") + @ExcludeMissing + fun _departureEnabled(): JsonField = departureEnabled + + /** + * Returns the raw JSON value of [departureTime]. + * + * Unlike [departureTime], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("departureTime") + @ExcludeMissing + fun _departureTime(): JsonField = departureTime + + /** + * Returns the raw JSON value of [stopId]. + * + * Unlike [stopId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopId") + @ExcludeMissing + fun _stopId(): JsonField = stopId + + /** + * Returns the raw JSON value of [tripId]. + * + * Unlike [tripId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tripId") + @ExcludeMissing + fun _tripId(): JsonField = tripId + + /** + * Returns the raw JSON value of [serviceId]. + * + * Unlike [serviceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("serviceId") + @ExcludeMissing + fun _serviceId(): JsonField = serviceId + + /** + * Returns the raw JSON value of [stopHeadsign]. + * + * Unlike [stopHeadsign], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stopHeadsign") + @ExcludeMissing + fun _stopHeadsign(): JsonField = stopHeadsign + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopTime]. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .stopId() + * .tripId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopTime]. */ + class Builder internal constructor() { + + private var arrivalEnabled: JsonField? = null + private var arrivalTime: JsonField? = null + private var departureEnabled: JsonField? = null + private var departureTime: JsonField? = null + private var stopId: JsonField? = null + private var tripId: JsonField? = null + private var serviceId: JsonField = JsonMissing.of() + private var stopHeadsign: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(stopTime: StopTime) = apply { + arrivalEnabled = stopTime.arrivalEnabled + arrivalTime = stopTime.arrivalTime + departureEnabled = stopTime.departureEnabled + departureTime = stopTime.departureTime + stopId = stopTime.stopId + tripId = stopTime.tripId + serviceId = stopTime.serviceId + stopHeadsign = stopTime.stopHeadsign + additionalProperties = stopTime.additionalProperties.toMutableMap() + } + + fun arrivalEnabled(arrivalEnabled: Boolean) = + arrivalEnabled(JsonField.of(arrivalEnabled)) + + /** + * Sets [Builder.arrivalEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun arrivalEnabled(arrivalEnabled: JsonField) = apply { + this.arrivalEnabled = arrivalEnabled + } + + fun arrivalTime(arrivalTime: Long) = + arrivalTime(JsonField.of(arrivalTime)) + + /** + * Sets [Builder.arrivalTime] to an arbitrary JSON value. + * + * You should usually call [Builder.arrivalTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun arrivalTime(arrivalTime: JsonField) = apply { + this.arrivalTime = arrivalTime + } + + fun departureEnabled(departureEnabled: Boolean) = + departureEnabled(JsonField.of(departureEnabled)) + + /** + * Sets [Builder.departureEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.departureEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun departureEnabled(departureEnabled: JsonField) = apply { + this.departureEnabled = departureEnabled + } + + fun departureTime(departureTime: Long) = + departureTime(JsonField.of(departureTime)) + + /** + * Sets [Builder.departureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.departureTime] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun departureTime(departureTime: JsonField) = apply { + this.departureTime = departureTime + } + + fun stopId(stopId: String) = stopId(JsonField.of(stopId)) + + /** + * Sets [Builder.stopId] to an arbitrary JSON value. + * + * You should usually call [Builder.stopId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun stopId(stopId: JsonField) = apply { this.stopId = stopId } + + fun tripId(tripId: String) = tripId(JsonField.of(tripId)) + + /** + * Sets [Builder.tripId] to an arbitrary JSON value. + * + * You should usually call [Builder.tripId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tripId(tripId: JsonField) = apply { this.tripId = tripId } + + fun serviceId(serviceId: String) = serviceId(JsonField.of(serviceId)) + + /** + * Sets [Builder.serviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceId] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun serviceId(serviceId: JsonField) = apply { + this.serviceId = serviceId + } + + fun stopHeadsign(stopHeadsign: String) = + stopHeadsign(JsonField.of(stopHeadsign)) + + /** + * Sets [Builder.stopHeadsign] to an arbitrary JSON value. + * + * You should usually call [Builder.stopHeadsign] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun stopHeadsign(stopHeadsign: JsonField) = apply { + this.stopHeadsign = stopHeadsign + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StopTime]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .arrivalEnabled() + * .arrivalTime() + * .departureEnabled() + * .departureTime() + * .stopId() + * .tripId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StopTime = + StopTime( + checkRequired("arrivalEnabled", arrivalEnabled), + checkRequired("arrivalTime", arrivalTime), + checkRequired("departureEnabled", departureEnabled), + checkRequired("departureTime", departureTime), + checkRequired("stopId", stopId), + checkRequired("tripId", tripId), + serviceId, + stopHeadsign, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StopTime = apply { + if (validated) { + return@apply + } + + arrivalEnabled() + arrivalTime() + departureEnabled() + departureTime() + stopId() + tripId() + serviceId() + stopHeadsign() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (arrivalEnabled.asKnown().isPresent) 1 else 0) + + (if (arrivalTime.asKnown().isPresent) 1 else 0) + + (if (departureEnabled.asKnown().isPresent) 1 else 0) + + (if (departureTime.asKnown().isPresent) 1 else 0) + + (if (stopId.asKnown().isPresent) 1 else 0) + + (if (tripId.asKnown().isPresent) 1 else 0) + + (if (serviceId.asKnown().isPresent) 1 else 0) + + (if (stopHeadsign.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StopTime && + arrivalEnabled == other.arrivalEnabled && + arrivalTime == other.arrivalTime && + departureEnabled == other.departureEnabled && + departureTime == other.departureTime && + stopId == other.stopId && + tripId == other.tripId && + serviceId == other.serviceId && + stopHeadsign == other.stopHeadsign && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalEnabled, + arrivalTime, + departureEnabled, + departureTime, + stopId, + tripId, + serviceId, + stopHeadsign, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTime{arrivalEnabled=$arrivalEnabled, arrivalTime=$arrivalTime, departureEnabled=$departureEnabled, departureTime=$departureTime, stopId=$stopId, tripId=$tripId, serviceId=$serviceId, stopHeadsign=$stopHeadsign, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripsWithStopTime && + stopTimes == other.stopTimes && + tripId == other.tripId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(stopTimes, tripId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripsWithStopTime{stopTimes=$stopTimes, tripId=$tripId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StopTripGrouping && + directionId == other.directionId && + stopIds == other.stopIds && + tripHeadsigns == other.tripHeadsigns && + tripIds == other.tripIds && + tripsWithStopTimes == other.tripsWithStopTimes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + directionId, + stopIds, + tripHeadsigns, + tripIds, + tripsWithStopTimes, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopTripGrouping{directionId=$directionId, stopIds=$stopIds, tripHeadsigns=$tripHeadsigns, tripIds=$tripIds, tripsWithStopTimes=$tripsWithStopTimes, additionalProperties=$additionalProperties}" + } + + class Trip + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val routeId: JsonField, + private val serviceId: JsonField, + private val blockId: JsonField, + private val directionId: JsonField, + private val peakOffpeak: JsonField, + private val routeShortName: JsonField, + private val shapeId: JsonField, + private val timeZone: JsonField, + private val tripHeadsign: JsonField, + private val tripShortName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("routeId") + @ExcludeMissing + routeId: JsonField = JsonMissing.of(), + @JsonProperty("serviceId") + @ExcludeMissing + serviceId: JsonField = JsonMissing.of(), + @JsonProperty("blockId") + @ExcludeMissing + blockId: JsonField = JsonMissing.of(), + @JsonProperty("directionId") + @ExcludeMissing + directionId: JsonField = JsonMissing.of(), + @JsonProperty("peakOffpeak") + @ExcludeMissing + peakOffpeak: JsonField = JsonMissing.of(), + @JsonProperty("routeShortName") + @ExcludeMissing + routeShortName: JsonField = JsonMissing.of(), + @JsonProperty("shapeId") + @ExcludeMissing + shapeId: JsonField = JsonMissing.of(), + @JsonProperty("timeZone") + @ExcludeMissing + timeZone: JsonField = JsonMissing.of(), + @JsonProperty("tripHeadsign") + @ExcludeMissing + tripHeadsign: JsonField = JsonMissing.of(), + @JsonProperty("tripShortName") + @ExcludeMissing + tripShortName: JsonField = JsonMissing.of(), + ) : this( + id, + routeId, + serviceId, + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + mutableMapOf(), + ) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun routeId(): String = routeId.getRequired("routeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceId(): String = serviceId.getRequired("serviceId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun blockId(): Optional = blockId.getOptional("blockId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun directionId(): Optional = directionId.getOptional("directionId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun peakOffpeak(): Optional = peakOffpeak.getOptional("peakOffpeak") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun routeShortName(): Optional = + routeShortName.getOptional("routeShortName") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun shapeId(): Optional = shapeId.getOptional("shapeId") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun timeZone(): Optional = timeZone.getOptional("timeZone") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tripHeadsign(): Optional = tripHeadsign.getOptional("tripHeadsign") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun tripShortName(): Optional = tripShortName.getOptional("tripShortName") + + /** + * 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + routeId, + serviceId, + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + additionalProperties, + ) + } + + 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 other is Entry && + routeId == other.routeId && + scheduleDate == other.scheduleDate && + serviceIds == other.serviceIds && + stops == other.stops && + stopTripGroupings == other.stopTripGroupings && + trips == other.trips && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + routeId, + scheduleDate, + serviceIds, + stops, + stopTripGroupings, + trips, + additionalProperties, + ) + } + + 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 other is Data && + entry == other.entry && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, additionalProperties) } + + 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 other is ScheduleForRouteRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/scheduleforstop/ScheduleForStopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParams.kt new file mode 100644 index 0000000..89b107b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParams.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.scheduleforstop + +import java.time.LocalDate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 date: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun stopId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ScheduleForStopRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ScheduleForStopRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScheduleForStopRetrieveParams]. */ + class Builder internal constructor() { + + private var stopId: String? = null + private var date: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(scheduleForStopRetrieveParams: ScheduleForStopRetrieveParams) = apply { + stopId = scheduleForStopRetrieveParams.stopId + date = scheduleForStopRetrieveParams.date + additionalHeaders = scheduleForStopRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = scheduleForStopRetrieveParams.additionalQueryParams.toBuilder() + } + + 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, + * defaults to the current date) + */ + fun date(date: LocalDate?) = apply { this.date = date } + + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ScheduleForStopRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ScheduleForStopRetrieveParams = + ScheduleForStopRetrieveParams( + 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 + } + + return other is ScheduleForStopRetrieveParams && + stopId == other.stopId && + date == other.date && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(stopId, date, additionalHeaders, additionalQueryParams) + + 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/scheduleforstop/ScheduleForStopRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt new file mode 100644 index 0000000..829a377 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveResponse.kt @@ -0,0 +1,2184 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val arrivalEnabled: JsonField, + private val arrivalTime: JsonField, + private val departureEnabled: JsonField, + private val departureTime: JsonField, + private val 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalEnabled, + arrivalTime, + departureEnabled, + departureTime, + serviceId, + tripId, + stopHeadsign, + additionalProperties, + ) + } + + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is ScheduleFrequency && + endTime == other.endTime && + headway == other.headway && + serviceDate == other.serviceDate && + serviceId == other.serviceId && + startTime == other.startTime && + tripId == other.tripId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + endTime, + headway, + serviceDate, + serviceId, + startTime, + tripId, + additionalProperties, + ) + } + + 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 other is StopRouteDirectionSchedule && + scheduleStopTimes == other.scheduleStopTimes && + tripHeadsign == other.tripHeadsign && + scheduleFrequencies == other.scheduleFrequencies && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + scheduleStopTimes, + tripHeadsign, + scheduleFrequencies, + additionalProperties, + ) + } + + 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 other is StopRouteSchedule && + routeId == other.routeId && + stopRouteDirectionSchedules == other.stopRouteDirectionSchedules && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(routeId, stopRouteDirectionSchedules, additionalProperties) + } + + 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 other is Entry && + date == other.date && + stopId == other.stopId && + stopRouteSchedules == other.stopRouteSchedules && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(date, stopId, stopRouteSchedules, additionalProperties) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScheduleForStopRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/searchforroute/SearchForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParams.kt new file mode 100644 index 0000000..be82be5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParams.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforroute + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** Search for a route based on its name. */ +class SearchForRouteListParams +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 + + /** The max number of results to return. Defaults to 20. */ + fun maxCount(): Optional = Optional.ofNullable(maxCount) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SearchForRouteListParams]. + * + * The following fields are required: + * ```java + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SearchForRouteListParams]. */ + class Builder internal constructor() { + + private var input: String? = null + private var maxCount: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(searchForRouteListParams: SearchForRouteListParams) = apply { + input = searchForRouteListParams.input + maxCount = searchForRouteListParams.maxCount + additionalHeaders = searchForRouteListParams.additionalHeaders.toBuilder() + additionalQueryParams = searchForRouteListParams.additionalQueryParams.toBuilder() + } + + /** The string to search for. */ + 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 } + + /** + * Alias for [Builder.maxCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxCount(maxCount: Long) = maxCount(maxCount as Long?) + + /** Alias for calling [Builder.maxCount] with `maxCount.orElse(null)`. */ + fun maxCount(maxCount: Optional) = maxCount(maxCount.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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), + maxCount, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 + } + + return other is SearchForRouteListParams && + input == other.input && + maxCount == other.maxCount && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) + + 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/searchforroute/SearchForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt new file mode 100644 index 0000000..bfc9edf --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListResponse.kt @@ -0,0 +1,1128 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val 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(): 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: 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + agencyId, + type, + color, + description, + longName, + nullSafeShortName, + shortName, + textColor, + url, + additionalProperties, + ) + } + + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + outOfRange == other.outOfRange && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) + } + + 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 other is SearchForRouteListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/searchforstop/SearchForStopListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParams.kt new file mode 100644 index 0000000..e0cf2ee --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParams.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforstop + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** Search for a stop based on its name. */ +class SearchForStopListParams +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 + + /** The max number of results to return. Defaults to 20. */ + fun maxCount(): Optional = Optional.ofNullable(maxCount) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SearchForStopListParams]. + * + * The following fields are required: + * ```java + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SearchForStopListParams]. */ + class Builder internal constructor() { + + private var input: String? = null + private var maxCount: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(searchForStopListParams: SearchForStopListParams) = apply { + input = searchForStopListParams.input + maxCount = searchForStopListParams.maxCount + additionalHeaders = searchForStopListParams.additionalHeaders.toBuilder() + additionalQueryParams = searchForStopListParams.additionalQueryParams.toBuilder() + } + + /** The string to search for. */ + 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 } + + /** + * Alias for [Builder.maxCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxCount(maxCount: Long) = maxCount(maxCount as Long?) + + /** Alias for calling [Builder.maxCount] with `maxCount.orElse(null)`. */ + fun maxCount(maxCount: Optional) = maxCount(maxCount.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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), + maxCount, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 + } + + return other is SearchForStopListParams && + input == other.input && + maxCount == other.maxCount && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(input, maxCount, additionalHeaders, additionalQueryParams) + + 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/searchforstop/SearchForStopListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt new file mode 100644 index 0000000..5f69ecc --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/searchforstop/SearchForStopListResponse.kt @@ -0,0 +1,1207 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type (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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val limitExceeded: JsonField, + private val list: JsonField>, + private val outOfRange: JsonField, + private val references: JsonField, + private val 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(): 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: 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + 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 [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: 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 [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is List && + id == other.id && + lat == other.lat && + locationType == other.locationType && + lon == other.lon && + name == other.name && + parent == other.parent && + routeIds == other.routeIds && + staticRouteIds == other.staticRouteIds && + code == other.code && + direction == other.direction && + wheelchairBoarding == other.wheelchairBoarding && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + outOfRange == other.outOfRange && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, outOfRange, references, additionalProperties) + } + + 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 other is SearchForStopListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/shape/ShapeRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveParams.kt new file mode 100644 index 0000000..de4c38a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.shape + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shapeId(): Optional = Optional.ofNullable(shapeId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ShapeRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ShapeRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShapeRetrieveParams]. */ + class Builder internal constructor() { + + private var shapeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(shapeRetrieveParams: ShapeRetrieveParams) = apply { + shapeId = shapeRetrieveParams.shapeId + additionalHeaders = shapeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = shapeRetrieveParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ShapeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShapeRetrieveParams = + 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 + } + + return other is ShapeRetrieveParams && + shapeId == other.shapeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(shapeId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ShapeRetrieveParams{shapeId=$shapeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..d7ac834 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/shape/ShapeRetrieveResponse.kt @@ -0,0 +1,755 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 other is Entry && + length == other.length && + points == other.points && + levels == other.levels && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(length, points, levels, additionalProperties) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShapeRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/stop/StopRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveParams.kt new file mode 100644 index 0000000..2f6cb9a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stop + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun stopId(): Optional = Optional.ofNullable(stopId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): StopRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [StopRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopRetrieveParams]. */ + class Builder internal constructor() { + + private var stopId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(stopRetrieveParams: StopRetrieveParams) = apply { + stopId = stopRetrieveParams.stopId + additionalHeaders = stopRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = stopRetrieveParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [StopRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopRetrieveParams = + 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 + } + + return other is StopRetrieveParams && + stopId == other.stopId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(stopId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "StopRetrieveParams{stopId=$stopId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..757e36b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stop/StopRetrieveResponse.kt @@ -0,0 +1,1114 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StopRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/stopidsforagency/StopIdsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParams.kt new file mode 100644 index 0000000..ff5456d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopidsforagency + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agencyId(): Optional = Optional.ofNullable(agencyId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): StopIdsForAgencyListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [StopIdsForAgencyListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopIdsForAgencyListParams]. */ + class Builder internal constructor() { + + private var agencyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(stopIdsForAgencyListParams: StopIdsForAgencyListParams) = apply { + agencyId = stopIdsForAgencyListParams.agencyId + additionalHeaders = stopIdsForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = stopIdsForAgencyListParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [StopIdsForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopIdsForAgencyListParams = + StopIdsForAgencyListParams( + 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 + } + + return other is StopIdsForAgencyListParams && + agencyId == other.agencyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(agencyId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "StopIdsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..51ec3c5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListResponse.kt @@ -0,0 +1,577 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, additionalProperties) + } + + 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 other is StopIdsForAgencyListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/stopsforagency/StopsForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParams.kt new file mode 100644 index 0000000..fbbd1c1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParams.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforagency + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agencyId(): Optional = Optional.ofNullable(agencyId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): StopsForAgencyListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [StopsForAgencyListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForAgencyListParams]. */ + class Builder internal constructor() { + + private var agencyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(stopsForAgencyListParams: StopsForAgencyListParams) = apply { + agencyId = stopsForAgencyListParams.agencyId + additionalHeaders = stopsForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = stopsForAgencyListParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [StopsForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopsForAgencyListParams = + StopsForAgencyListParams( + 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 + } + + return other is StopsForAgencyListParams && + agencyId == other.agencyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(agencyId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "StopsForAgencyListParams{agencyId=$agencyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..459d165 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListResponse.kt @@ -0,0 +1,1045 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val 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(): 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: 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") @ExcludeMissing parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + 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 [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: 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 [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is List && + id == other.id && + lat == other.lat && + locationType == other.locationType && + lon == other.lon && + name == other.name && + parent == other.parent && + routeIds == other.routeIds && + staticRouteIds == other.staticRouteIds && + code == other.code && + direction == other.direction && + wheelchairBoarding == other.wheelchairBoarding && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + code, + currentTime, + text, + version, + limitExceeded, + list, + references, + outOfRange, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StopsForAgencyListResponse{code=$code, currentTime=$currentTime, text=$text, version=$version, limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt new file mode 100644 index 0000000..d153274 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParams.kt @@ -0,0 +1,306 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforlocation + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** stops-for-location */ +class StopsForLocationListParams +private constructor( + private val lat: Double, + private val lon: Double, + private val latSpan: Double?, + private val lonSpan: Double?, + private val query: String?, + private val radius: Double?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun lat(): Double = lat + + 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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StopsForLocationListParams]. + * + * The following fields are required: + * ```java + * .lat() + * .lon() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForLocationListParams]. */ + class Builder internal constructor() { + + private var lat: Double? = null + private var lon: Double? = null + private var latSpan: Double? = null + private var lonSpan: Double? = null + private var query: String? = null + private var radius: Double? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(stopsForLocationListParams: StopsForLocationListParams) = apply { + 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 } + + 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 } + + /** + * Alias for [Builder.latSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latSpan(latSpan: Double) = latSpan(latSpan as Double?) + + /** Alias for calling [Builder.latSpan] with `latSpan.orElse(null)`. */ + fun latSpan(latSpan: Optional) = latSpan(latSpan.getOrNull()) + + /** An alternative to radius to set the search bounding box (optional) */ + fun lonSpan(lonSpan: Double?) = apply { this.lonSpan = lonSpan } + + /** + * Alias for [Builder.lonSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun lonSpan(lonSpan: Double) = lonSpan(lonSpan as Double?) + + /** Alias for calling [Builder.lonSpan] with `lonSpan.orElse(null)`. */ + fun lonSpan(lonSpan: Optional) = lonSpan(lonSpan.getOrNull()) + + /** A search query string to filter the results */ + fun query(query: String?) = apply { this.query = query } + + /** 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 } + + /** + * Alias for [Builder.radius]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun radius(radius: Double) = radius(radius as Double?) + + /** Alias for calling [Builder.radius] with `radius.orElse(null)`. */ + fun radius(radius: Optional) = radius(radius.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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), + checkRequired("lon", lon), + latSpan, + lonSpan, + query, + radius, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 + } + + return 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 + } + + override fun hashCode(): Int = + Objects.hash( + lat, + lon, + latSpan, + lonSpan, + query, + radius, + additionalHeaders, + additionalQueryParams, + ) + + 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/stopsforlocation/StopsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt new file mode 100644 index 0000000..20716fe --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListResponse.kt @@ -0,0 +1,1207 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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(): 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: 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val lat: JsonField, + private val locationType: JsonField, + private val lon: JsonField, + private val name: JsonField, + private val parent: JsonField, + private val routeIds: JsonField>, + private val staticRouteIds: JsonField>, + private val code: JsonField, + private val direction: JsonField, + private val wheelchairBoarding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("locationType") + @ExcludeMissing + locationType: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + @JsonProperty("routeIds") + @ExcludeMissing + routeIds: JsonField> = JsonMissing.of(), + @JsonProperty("staticRouteIds") + @ExcludeMissing + staticRouteIds: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("wheelchairBoarding") + @ExcludeMissing + wheelchairBoarding: JsonField = JsonMissing.of(), + ) : this( + id, + lat, + locationType, + 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 [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: 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 [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .lat() + * .locationType() + * .lon() + * .name() + * .parent() + * .routeIds() + * .staticRouteIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("lat", lat), + checkRequired("locationType", locationType), + checkRequired("lon", lon), + checkRequired("name", name), + checkRequired("parent", parent), + checkRequired("routeIds", routeIds).map { it.toImmutable() }, + checkRequired("staticRouteIds", staticRouteIds).map { it.toImmutable() }, + code, + direction, + wheelchairBoarding, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + lat() + locationType() + lon() + name() + parent() + routeIds() + staticRouteIds() + code() + direction() + wheelchairBoarding() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (locationType.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + (routeIds.asKnown().getOrNull()?.size ?: 0) + + (staticRouteIds.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (direction.asKnown().isPresent) 1 else 0) + + (if (wheelchairBoarding.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is List && + id == other.id && + lat == other.lat && + locationType == other.locationType && + lon == other.lon && + name == other.name && + parent == other.parent && + routeIds == other.routeIds && + staticRouteIds == other.staticRouteIds && + code == other.code && + direction == other.direction && + wheelchairBoarding == other.wheelchairBoarding && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + lat, + locationType, + lon, + name, + parent, + routeIds, + staticRouteIds, + code, + direction, + wheelchairBoarding, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, lat=$lat, locationType=$locationType, lon=$lon, name=$name, parent=$parent, routeIds=$routeIds, staticRouteIds=$staticRouteIds, code=$code, direction=$direction, wheelchairBoarding=$wheelchairBoarding, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + outOfRange == other.outOfRange && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StopsForLocationListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/stopsforroute/StopsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParams.kt new file mode 100644 index 0000000..482ccd5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParams.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforroute + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 includePolylines: Boolean?, + private val time: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun routeId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): StopsForRouteListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [StopsForRouteListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StopsForRouteListParams]. */ + class Builder internal constructor() { + + private var routeId: String? = null + private var includePolylines: Boolean? = null + private var time: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(stopsForRouteListParams: StopsForRouteListParams) = apply { + 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 } + + /** 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 + } + + /** + * Alias for [Builder.includePolylines]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includePolylines(includePolylines: Boolean) = + includePolylines(includePolylines as Boolean?) + + /** Alias for calling [Builder.includePolylines] with `includePolylines.orElse(null)`. */ + fun includePolylines(includePolylines: Optional) = + includePolylines(includePolylines.getOrNull()) + + /** Specify service date (YYYY-MM-DD or epoch) (default today) */ + fun time(time: String?) = apply { this.time = time } + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [StopsForRouteListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StopsForRouteListParams = + StopsForRouteListParams( + routeId, + includePolylines, + time, + 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 { + 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 + } + + return other is StopsForRouteListParams && + routeId == other.routeId && + includePolylines == other.includePolylines && + time == other.time && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(routeId, includePolylines, time, additionalHeaders, additionalQueryParams) + + 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/stopsforroute/StopsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt new file mode 100644 index 0000000..4b154f5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListResponse.kt @@ -0,0 +1,1789 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("length") + @ExcludeMissing + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun length(): Optional = length.getOptional("length") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun levels(): Optional = levels.getOptional("levels") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun points(): Optional = points.getOptional("points") + + /** + * Returns the raw JSON value of [length]. + * + * Unlike [length], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + + /** + * Returns the raw JSON value of [levels]. + * + * Unlike [levels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("levels") @ExcludeMissing fun _levels(): JsonField = levels + + /** + * Returns the raw JSON value of [points]. + * + * Unlike [points], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("points") @ExcludeMissing fun _points(): JsonField = points + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Polyline]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Polyline]. */ + class Builder internal constructor() { + + private var length: JsonField = JsonMissing.of() + private var levels: JsonField = JsonMissing.of() + private var points: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(polyline: Polyline) = apply { + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() + } + + fun length(length: Long) = length(JsonField.of(length)) + + /** + * Sets [Builder.length] to an arbitrary JSON value. + * + * You should usually call [Builder.length] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun length(length: JsonField) = apply { this.length = length } + + fun levels(levels: String) = levels(JsonField.of(levels)) + + /** + * Sets [Builder.levels] to an arbitrary JSON value. + * + * You should usually call [Builder.levels] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun levels(levels: JsonField) = apply { this.levels = levels } + + fun points(points: String) = points(JsonField.of(points)) + + /** + * Sets [Builder.points] to an arbitrary JSON value. + * + * You should usually call [Builder.points] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun points(points: JsonField) = apply { this.points = points } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Polyline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Polyline = + Polyline(length, levels, points, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Polyline = apply { + if (validated) { + return@apply + } + + length() + levels() + points() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Polyline && + length == other.length && + levels == other.levels && + points == other.points && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(length, levels, points, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + } + + class StopGrouping + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val polylines: JsonField>, + private val stopIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val names: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("names") + @ExcludeMissing + names: JsonField> = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + ) : this(name, names, type, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun names(): Optional> = names.getOptional("names") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [names]. + * + * Unlike [names], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("names") + @ExcludeMissing + fun _names(): JsonField> = names + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Name]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Name]. */ + class Builder internal constructor() { + + private var name: JsonField = JsonMissing.of() + private var names: JsonField>? = null + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(name: Name) = apply { + this.name = name.name + names = name.names.map { it.toMutableList() } + type = name.type + additionalProperties = name.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun names(names: List) = names(JsonField.of(names)) + + /** + * Sets [Builder.names] to an arbitrary JSON value. + * + * You should usually call [Builder.names] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun names(names: JsonField>) = apply { + this.names = names.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [names]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addName(name: String) = apply { + names = + (names ?: JsonField.of(mutableListOf())).also { + checkKnown("names", it).add(name) + } + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Name]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Name = + Name( + name, + (names ?: JsonMissing.of()).map { it.toImmutable() }, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + name() + names() + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (names.asKnown().getOrNull()?.size ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && + name == other.name && + names == other.names && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, names, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Name{name=$name, names=$names, type=$type, additionalProperties=$additionalProperties}" + } + + class Polyline + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val length: JsonField, + private val levels: JsonField, + private val points: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("length") + @ExcludeMissing + length: JsonField = JsonMissing.of(), + @JsonProperty("levels") + @ExcludeMissing + levels: JsonField = JsonMissing.of(), + @JsonProperty("points") + @ExcludeMissing + points: JsonField = JsonMissing.of(), + ) : this(length, levels, points, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun length(): Optional = length.getOptional("length") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun levels(): Optional = levels.getOptional("levels") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun points(): Optional = points.getOptional("points") + + /** + * Returns the raw JSON value of [length]. + * + * Unlike [length], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + + /** + * Returns the raw JSON value of [levels]. + * + * Unlike [levels], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("levels") + @ExcludeMissing + fun _levels(): JsonField = levels + + /** + * Returns the raw JSON value of [points]. + * + * Unlike [points], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("points") + @ExcludeMissing + fun _points(): JsonField = points + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Polyline]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Polyline]. */ + class Builder internal constructor() { + + private var length: JsonField = JsonMissing.of() + private var levels: JsonField = JsonMissing.of() + private var points: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(polyline: Polyline) = apply { + length = polyline.length + levels = polyline.levels + points = polyline.points + additionalProperties = polyline.additionalProperties.toMutableMap() + } + + fun length(length: Long) = length(JsonField.of(length)) + + /** + * Sets [Builder.length] to an arbitrary JSON value. + * + * You should usually call [Builder.length] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun length(length: JsonField) = apply { this.length = length } + + fun levels(levels: String) = levels(JsonField.of(levels)) + + /** + * Sets [Builder.levels] to an arbitrary JSON value. + * + * You should usually call [Builder.levels] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun levels(levels: JsonField) = apply { this.levels = levels } + + fun points(points: String) = points(JsonField.of(points)) + + /** + * Sets [Builder.points] to an arbitrary JSON value. + * + * You should usually call [Builder.points] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun points(points: JsonField) = apply { this.points = points } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Polyline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Polyline = + Polyline(length, levels, points, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Polyline = apply { + if (validated) { + return@apply + } + + length() + levels() + points() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (length.asKnown().isPresent) 1 else 0) + + (if (levels.asKnown().isPresent) 1 else 0) + + (if (points.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Polyline && + length == other.length && + levels == other.levels && + points == other.points && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(length, levels, points, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Polyline{length=$length, levels=$levels, points=$points, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StopGrouping && + id == other.id && + name == other.name && + polylines == other.polylines && + stopIds == other.stopIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, name, polylines, stopIds, additionalProperties) + } + + 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 other is Entry && + polylines == other.polylines && + routeId == other.routeId && + stopGroupings == other.stopGroupings && + stopIds == other.stopIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(polylines, routeId, stopGroupings, stopIds, additionalProperties) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StopsForRouteListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/trip/TripRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveParams.kt new file mode 100644 index 0000000..81a8519 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.trip + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tripId(): Optional = Optional.ofNullable(tripId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TripRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TripRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripRetrieveParams]. */ + class Builder internal constructor() { + + private var tripId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tripRetrieveParams: TripRetrieveParams) = apply { + tripId = tripRetrieveParams.tripId + additionalHeaders = tripRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tripRetrieveParams.additionalQueryParams.toBuilder() + } + + 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() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TripRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TripRetrieveParams = + 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 + } + + return other is TripRetrieveParams && + tripId == other.tripId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(tripId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TripRetrieveParams{tripId=$tripId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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..bafef25 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/trip/TripRetrieveResponse.kt @@ -0,0 +1,1086 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + routeId, + serviceId, + blockId, + directionId, + peakOffpeak, + routeShortName, + shapeId, + timeZone, + tripHeadsign, + tripShortName, + additionalProperties, + ) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/tripdetails/TripDetailRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParams.kt new file mode 100644 index 0000000..069b4d4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParams.kt @@ -0,0 +1,331 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripdetails + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 includeSchedule: Boolean?, + private val includeStatus: Boolean?, + private val includeTrip: Boolean?, + private val serviceDate: Long?, + private val time: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tripId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TripDetailRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TripDetailRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripDetailRetrieveParams]. */ + class Builder internal constructor() { + + private var tripId: String? = null + private var includeSchedule: Boolean? = null + private var includeStatus: Boolean? = null + private var includeTrip: Boolean? = null + private var serviceDate: Long? = null + private var time: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tripDetailRetrieveParams: TripDetailRetrieveParams) = apply { + 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 } + + /** 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 + * true). + */ + fun includeSchedule(includeSchedule: Boolean?) = apply { + this.includeSchedule = includeSchedule + } + + /** + * Alias for [Builder.includeSchedule]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) + + /** Alias for calling [Builder.includeSchedule] with `includeSchedule.orElse(null)`. */ + fun includeSchedule(includeSchedule: Optional) = + includeSchedule(includeSchedule.getOrNull()) + + /** + * Whether to include the full status element in the tripDetails section (defaults to true). + */ + fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } + + /** + * Alias for [Builder.includeStatus]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) + + /** Alias for calling [Builder.includeStatus] with `includeStatus.orElse(null)`. */ + fun includeStatus(includeStatus: Optional) = + includeStatus(includeStatus.getOrNull()) + + /** + * Whether to include the full trip element in the references section (defaults to true). + */ + fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } + + /** + * Alias for [Builder.includeTrip]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip 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 } + + /** + * Alias for [Builder.serviceDate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun serviceDate(serviceDate: Long) = serviceDate(serviceDate 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 } + + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun time(time: Long) = time(time as Long?) + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TripDetailRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TripDetailRetrieveParams = + TripDetailRetrieveParams( + tripId, + includeSchedule, + includeStatus, + includeTrip, + serviceDate, + time, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 + } + + return 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 + } + + override fun hashCode(): Int = + Objects.hash( + tripId, + includeSchedule, + includeStatus, + includeTrip, + serviceDate, + time, + additionalHeaders, + additionalQueryParams, + ) + + 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/tripdetails/TripDetailRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt new file mode 100644 index 0000000..383c4d6 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveResponse.kt @@ -0,0 +1,3438 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is StopTime && + arrivalTime == other.arrivalTime && + departureTime == other.departureTime && + distanceAlongTrip == other.distanceAlongTrip && + historicalOccupancy == other.historicalOccupancy && + stopHeadsign == other.stopHeadsign && + stopId == other.stopId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties, + ) + } + + 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 other is Schedule && + nextTripId == other.nextTripId && + previousTripId == other.previousTripId && + stopTimes == other.stopTimes && + timeZone == other.timeZone && + frequency == other.frequency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + nextTripId, + previousTripId, + stopTimes, + timeZone, + frequency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastKnownLocation && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 other is Entry && + tripId == other.tripId && + frequency == other.frequency && + schedule == other.schedule && + serviceDate == other.serviceDate && + situationIds == other.situationIds && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + tripId, + frequency, + schedule, + serviceDate, + situationIds, + status, + additionalProperties, + ) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripDetailRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/tripforvehicle/TripForVehicleRetrieveParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParams.kt new file mode 100644 index 0000000..7491319 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParams.kt @@ -0,0 +1,319 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripforvehicle + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 includeSchedule: Boolean?, + private val includeStatus: Boolean?, + private val includeTrip: Boolean?, + private val time: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun vehicleId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TripForVehicleRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [TripForVehicleRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripForVehicleRetrieveParams]. */ + class Builder internal constructor() { + + private var vehicleId: String? = null + private var includeSchedule: Boolean? = null + private var includeStatus: Boolean? = null + private var includeTrip: Boolean? = null + private var time: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tripForVehicleRetrieveParams: TripForVehicleRetrieveParams) = apply { + 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 } + + /** 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. + * Defaults to false. + */ + fun includeSchedule(includeSchedule: Boolean?) = apply { + this.includeSchedule = includeSchedule + } + + /** + * Alias for [Builder.includeSchedule]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) + + /** Alias for calling [Builder.includeSchedule] with `includeSchedule.orElse(null)`. */ + fun includeSchedule(includeSchedule: Optional) = + includeSchedule(includeSchedule.getOrNull()) + + /** + * Determines whether the full element is included in the section. + * Defaults to true. + */ + fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } + + /** + * Alias for [Builder.includeStatus]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) + + /** Alias for calling [Builder.includeStatus] with `includeStatus.orElse(null)`. */ + fun includeStatus(includeStatus: Optional) = + includeStatus(includeStatus.getOrNull()) + + /** + * Determines whether full element is included in the section. + * Defaults to false. + */ + fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } + + /** + * Alias for [Builder.includeTrip]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip 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 } + + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun time(time: Long) = time(time as Long?) + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TripForVehicleRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TripForVehicleRetrieveParams = + TripForVehicleRetrieveParams( + vehicleId, + includeSchedule, + includeStatus, + includeTrip, + time, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 + } + + return other is TripForVehicleRetrieveParams && + vehicleId == other.vehicleId && + includeSchedule == other.includeSchedule && + includeStatus == other.includeStatus && + includeTrip == other.includeTrip && + time == other.time && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + vehicleId, + includeSchedule, + includeStatus, + includeTrip, + time, + additionalHeaders, + additionalQueryParams, + ) + + 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/tripforvehicle/TripForVehicleRetrieveResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt new file mode 100644 index 0000000..7264e50 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveResponse.kt @@ -0,0 +1,3440 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entry: JsonField, + private val references: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry") @ExcludeMissing entry: JsonField = JsonMissing.of(), + @JsonProperty("references") + @ExcludeMissing + references: JsonField = JsonMissing.of(), + ) : this(entry, references, mutableMapOf()) + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entry(): Entry = entry.getRequired("entry") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun references(): References = references.getRequired("references") + + /** + * Returns the raw JSON value of [entry]. + * + * Unlike [entry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry") @ExcludeMissing fun _entry(): JsonField = entry + + /** + * Returns the raw JSON value of [references]. + * + * Unlike [references], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("references") + @ExcludeMissing + fun _references(): JsonField = references + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var entry: JsonField? = null + private var references: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + entry = data.entry + references = data.references + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun entry(entry: Entry) = entry(JsonField.of(entry)) + + /** + * Sets [Builder.entry] to an arbitrary JSON value. + * + * You should usually call [Builder.entry] with a well-typed [Entry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entry(entry: JsonField) = apply { this.entry = entry } + + fun references(references: References) = references(JsonField.of(references)) + + /** + * Sets [Builder.references] to an arbitrary JSON value. + * + * You should usually call [Builder.references] with a well-typed [References] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun references(references: JsonField) = apply { + this.references = references + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entry() + * .references() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("entry", entry), + checkRequired("references", references), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + entry().validate() + references().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entry.asKnown().getOrNull()?.validity() ?: 0) + + (references.asKnown().getOrNull()?.validity() ?: 0) + + class Entry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is StopTime && + arrivalTime == other.arrivalTime && + departureTime == other.departureTime && + distanceAlongTrip == other.distanceAlongTrip && + historicalOccupancy == other.historicalOccupancy && + stopHeadsign == other.stopHeadsign && + stopId == other.stopId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties, + ) + } + + 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 other is Schedule && + nextTripId == other.nextTripId && + previousTripId == other.previousTripId && + stopTimes == other.stopTimes && + timeZone == other.timeZone && + frequency == other.frequency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + nextTripId, + previousTripId, + stopTimes, + timeZone, + frequency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastKnownLocation && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 other is Entry && + tripId == other.tripId && + frequency == other.frequency && + schedule == other.schedule && + serviceDate == other.serviceDate && + situationIds == other.situationIds && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + tripId, + frequency, + schedule, + serviceDate, + situationIds, + status, + additionalProperties, + ) + } + + 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 other is Data && + entry == other.entry && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entry, references, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{entry=$entry, references=$references, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripForVehicleRetrieveResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/tripsforlocation/TripsForLocationListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParams.kt new file mode 100644 index 0000000..0b4a6fd --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListParams.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforlocation + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +import org.onebusaway.core.checkRequired +import org.onebusaway.core.http.Headers +import org.onebusaway.core.http.QueryParams + +/** Retrieve trips for a given location */ +class TripsForLocationListParams +private constructor( + 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?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The latitude coordinate of the search center */ + fun lat(): Float = lat + + /** Latitude span of the search bounding box */ + fun latSpan(): Float = latSpan + + /** The longitude coordinate of the search center */ + fun lon(): Float = lon + + /** Longitude span of the search bounding box */ + fun lonSpan(): Float = 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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TripsForLocationListParams]. + * + * The following fields are required: + * ```java + * .lat() + * .latSpan() + * .lon() + * .lonSpan() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripsForLocationListParams]. */ + class Builder internal constructor() { + + 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 + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tripsForLocationListParams: TripsForLocationListParams) = apply { + 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 */ + fun lat(lat: Float) = apply { this.lat = lat } + + /** Latitude span of the search bounding box */ + fun latSpan(latSpan: Float) = apply { this.latSpan = latSpan } + + /** The longitude coordinate of the search center */ + fun lon(lon: Float) = apply { this.lon = lon } + + /** Longitude span of the search bounding box */ + fun lonSpan(lonSpan: Float) = apply { this.lonSpan = lonSpan } + + /** + * Whether to include full schedule elements in the tripDetails section. Defaults to false. + */ + fun includeSchedule(includeSchedule: Boolean?) = apply { + this.includeSchedule = includeSchedule + } + + /** + * Alias for [Builder.includeSchedule]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) + + /** Alias for calling [Builder.includeSchedule] with `includeSchedule.orElse(null)`. */ + fun includeSchedule(includeSchedule: Optional) = + includeSchedule(includeSchedule.getOrNull()) + + /** Whether to include full trip elements in the references section. Defaults to false. */ + fun includeTrip(includeTrip: Boolean?) = apply { this.includeTrip = includeTrip } + + /** + * Alias for [Builder.includeTrip]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeTrip(includeTrip: Boolean) = includeTrip(includeTrip 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 } + + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun time(time: Long) = time(time as Long?) + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [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), + checkRequired("latSpan", latSpan), + checkRequired("lon", lon), + checkRequired("lonSpan", lonSpan), + includeSchedule, + includeTrip, + time, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 + } + + return 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 + } + + override fun hashCode(): Int = + Objects.hash( + lat, + latSpan, + lon, + lonSpan, + includeSchedule, + includeTrip, + time, + additionalHeaders, + additionalQueryParams, + ) + + 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/tripsforlocation/TripsForLocationListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt new file mode 100644 index 0000000..28d8b97 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforlocation/TripsForLocationListResponse.kt @@ -0,0 +1,3545 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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(): 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: 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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: 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is StopTime && + arrivalTime == other.arrivalTime && + departureTime == other.departureTime && + distanceAlongTrip == other.distanceAlongTrip && + historicalOccupancy == other.historicalOccupancy && + stopHeadsign == other.stopHeadsign && + stopId == other.stopId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties, + ) + } + + 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 other is Schedule && + nextTripId == other.nextTripId && + previousTripId == other.previousTripId && + stopTimes == other.stopTimes && + timeZone == other.timeZone && + frequency == other.frequency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + nextTripId, + previousTripId, + stopTimes, + timeZone, + frequency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastKnownLocation && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 other is List && + schedule == other.schedule && + status == other.status && + tripId == other.tripId && + frequency == other.frequency && + serviceDate == other.serviceDate && + situationIds == other.situationIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + schedule, + status, + tripId, + frequency, + serviceDate, + situationIds, + additionalProperties, + ) + } + + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + outOfRange == other.outOfRange && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, outOfRange, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{limitExceeded=$limitExceeded, list=$list, references=$references, outOfRange=$outOfRange, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripsForLocationListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/tripsforroute/TripsForRouteListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParams.kt new file mode 100644 index 0000000..c07879e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParams.kt @@ -0,0 +1,282 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforroute + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 includeSchedule: Boolean?, + private val includeStatus: Boolean?, + private val time: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun routeId(): Optional = Optional.ofNullable(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) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TripsForRouteListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TripsForRouteListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TripsForRouteListParams]. */ + class Builder internal constructor() { + + private var routeId: String? = null + private var includeSchedule: Boolean? = null + private var includeStatus: Boolean? = null + private var time: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tripsForRouteListParams: TripsForRouteListParams) = apply { + 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 } + + /** 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 + } + + /** + * Alias for [Builder.includeSchedule]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeSchedule(includeSchedule: Boolean) = includeSchedule(includeSchedule as Boolean?) + + /** Alias for calling [Builder.includeSchedule] with `includeSchedule.orElse(null)`. */ + fun includeSchedule(includeSchedule: Optional) = + includeSchedule(includeSchedule.getOrNull()) + + /** + * Determine whether full tripStatus elements with real-time information are included. + * Defaults to false. + */ + fun includeStatus(includeStatus: Boolean?) = apply { this.includeStatus = includeStatus } + + /** + * Alias for [Builder.includeStatus]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeStatus(includeStatus: Boolean) = includeStatus(includeStatus as Boolean?) + + /** Alias for calling [Builder.includeStatus] with `includeStatus.orElse(null)`. */ + fun includeStatus(includeStatus: Optional) = + includeStatus(includeStatus.getOrNull()) + + /** Query the system at a specific time. Useful for testing. */ + fun time(time: Long?) = apply { this.time = time } + + /** + * Alias for [Builder.time]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun time(time: Long) = time(time as Long?) + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TripsForRouteListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TripsForRouteListParams = + TripsForRouteListParams( + routeId, + includeSchedule, + includeStatus, + time, + 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 { + 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 + } + + return other is TripsForRouteListParams && + routeId == other.routeId && + includeSchedule == other.includeSchedule && + includeStatus == other.includeStatus && + time == other.time && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + routeId, + includeSchedule, + includeStatus, + time, + additionalHeaders, + additionalQueryParams, + ) + + 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/tripsforroute/TripsForRouteListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt new file mode 100644 index 0000000..e707682 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListResponse.kt @@ -0,0 +1,3503 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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: 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 other is StopTime && + arrivalTime == other.arrivalTime && + departureTime == other.departureTime && + distanceAlongTrip == other.distanceAlongTrip && + historicalOccupancy == other.historicalOccupancy && + stopHeadsign == other.stopHeadsign && + stopId == other.stopId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + arrivalTime, + departureTime, + distanceAlongTrip, + historicalOccupancy, + stopHeadsign, + stopId, + additionalProperties, + ) + } + + 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 other is Schedule && + nextTripId == other.nextTripId && + previousTripId == other.previousTripId && + stopTimes == other.stopTimes && + timeZone == other.timeZone && + frequency == other.frequency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + nextTripId, + previousTripId, + stopTimes, + timeZone, + frequency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{nextTripId=$nextTripId, previousTripId=$previousTripId, stopTimes=$stopTimes, timeZone=$timeZone, frequency=$frequency, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastKnownLocation && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 other is List && + schedule == other.schedule && + status == other.status && + tripId == other.tripId && + frequency == other.frequency && + serviceDate == other.serviceDate && + situationIds == other.situationIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + schedule, + status, + tripId, + frequency, + serviceDate, + situationIds, + additionalProperties, + ) + } + + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, additionalProperties) + } + + 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 other is TripsForRouteListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/vehiclesforagency/VehiclesForAgencyListParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParams.kt new file mode 100644 index 0000000..e516d46 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParams.kt @@ -0,0 +1,216 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.vehiclesforagency + +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.Params +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 time: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun agencyId(): Optional = Optional.ofNullable(agencyId) + + /** Specific time for querying the status (timestamp format) */ + fun time(): Optional = Optional.ofNullable(time) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): VehiclesForAgencyListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [VehiclesForAgencyListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VehiclesForAgencyListParams]. */ + class Builder internal constructor() { + + private var agencyId: String? = null + private var time: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(vehiclesForAgencyListParams: VehiclesForAgencyListParams) = apply { + agencyId = vehiclesForAgencyListParams.agencyId + time = vehiclesForAgencyListParams.time + additionalHeaders = vehiclesForAgencyListParams.additionalHeaders.toBuilder() + additionalQueryParams = vehiclesForAgencyListParams.additionalQueryParams.toBuilder() + } + + 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 } + + /** Alias for calling [Builder.time] with `time.orElse(null)`. */ + fun time(time: Optional) = time(time.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [VehiclesForAgencyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VehiclesForAgencyListParams = + VehiclesForAgencyListParams( + 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 + } + + return other is VehiclesForAgencyListParams && + agencyId == other.agencyId && + time == other.time && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(agencyId, time, additionalHeaders, additionalQueryParams) + + 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/vehiclesforagency/VehiclesForAgencyListResponse.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt new file mode 100644 index 0000000..b2d908b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListResponse.kt @@ -0,0 +1,3153 @@ +// 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField, + private val currentTime: JsonField, + private val text: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("currentTime") + @ExcludeMissing + currentTime: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(code, currentTime, text, version, data, mutableMapOf()) + + fun toResponseWrapper(): ResponseWrapper = + ResponseWrapper.builder() + .code(code) + .currentTime(currentTime) + .text(text) + .version(version) + .build() + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentTime(): Long = currentTime.getRequired("currentTime") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [currentTime]. + * + * Unlike [currentTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currentTime") @ExcludeMissing fun _currentTime(): JsonField = currentTime + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 [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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") @ExcludeMissing lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * @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 other is Location && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(lat, lon, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Location{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + class TripStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val activeTripId: JsonField, + private val blockTripSequence: JsonField, + private val closestStop: JsonField, + private val distanceAlongTrip: JsonField, + private val lastKnownDistanceAlongTrip: JsonField, + private val lastLocationUpdateTime: JsonField, + private val lastUpdateTime: JsonField, + private val occupancyCapacity: JsonField, + private val occupancyCount: JsonField, + private val occupancyStatus: JsonField, + private val phase: JsonField, + private val predicted: JsonField, + private val scheduleDeviation: JsonField, + private val serviceDate: JsonField, + private val status: JsonField, + private val totalDistanceAlongTrip: JsonField, + private val closestStopTimeOffset: JsonField, + private val frequency: JsonField, + private val lastKnownLocation: JsonField, + private val lastKnownOrientation: JsonField, + private val nextStop: JsonField, + private val nextStopTimeOffset: JsonField, + private val orientation: JsonField, + private val position: JsonField, + private val scheduledDistanceAlongTrip: JsonField, + private val situationIds: JsonField>, + private val vehicleId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("activeTripId") + @ExcludeMissing + activeTripId: JsonField = JsonMissing.of(), + @JsonProperty("blockTripSequence") + @ExcludeMissing + blockTripSequence: JsonField = JsonMissing.of(), + @JsonProperty("closestStop") + @ExcludeMissing + closestStop: JsonField = JsonMissing.of(), + @JsonProperty("distanceAlongTrip") + @ExcludeMissing + distanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownDistanceAlongTrip") + @ExcludeMissing + lastKnownDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("lastLocationUpdateTime") + @ExcludeMissing + lastLocationUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("lastUpdateTime") + @ExcludeMissing + lastUpdateTime: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCapacity") + @ExcludeMissing + occupancyCapacity: JsonField = JsonMissing.of(), + @JsonProperty("occupancyCount") + @ExcludeMissing + occupancyCount: JsonField = JsonMissing.of(), + @JsonProperty("occupancyStatus") + @ExcludeMissing + occupancyStatus: JsonField = JsonMissing.of(), + @JsonProperty("phase") + @ExcludeMissing + phase: JsonField = JsonMissing.of(), + @JsonProperty("predicted") + @ExcludeMissing + predicted: JsonField = JsonMissing.of(), + @JsonProperty("scheduleDeviation") + @ExcludeMissing + scheduleDeviation: JsonField = JsonMissing.of(), + @JsonProperty("serviceDate") + @ExcludeMissing + serviceDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("totalDistanceAlongTrip") + @ExcludeMissing + totalDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("closestStopTimeOffset") + @ExcludeMissing + closestStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownLocation") + @ExcludeMissing + lastKnownLocation: JsonField = JsonMissing.of(), + @JsonProperty("lastKnownOrientation") + @ExcludeMissing + lastKnownOrientation: JsonField = JsonMissing.of(), + @JsonProperty("nextStop") + @ExcludeMissing + nextStop: JsonField = JsonMissing.of(), + @JsonProperty("nextStopTimeOffset") + @ExcludeMissing + nextStopTimeOffset: JsonField = JsonMissing.of(), + @JsonProperty("orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("scheduledDistanceAlongTrip") + @ExcludeMissing + scheduledDistanceAlongTrip: JsonField = JsonMissing.of(), + @JsonProperty("situationIds") + @ExcludeMissing + situationIds: JsonField> = JsonMissing.of(), + @JsonProperty("vehicleId") + @ExcludeMissing + vehicleId: JsonField = JsonMissing.of(), + ) : this( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + mutableMapOf(), + ) + + /** + * Trip ID of the trip the vehicle is actively serving. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun activeTripId(): String = activeTripId.getRequired("activeTripId") + + /** + * Index of the active trip into the sequence of trips for the active block. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockTripSequence(): Long = blockTripSequence.getRequired("blockTripSequence") + + /** + * ID of the closest stop to the current location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun closestStop(): String = closestStop.getRequired("closestStop") + + /** + * Distance, in meters, the transit vehicle has progressed along the active trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun distanceAlongTrip(): Double = distanceAlongTrip.getRequired("distanceAlongTrip") + + /** + * Last known distance along the trip received in real-time from the transit + * vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastKnownDistanceAlongTrip(): Double = + lastKnownDistanceAlongTrip.getRequired("lastKnownDistanceAlongTrip") + + /** + * Timestamp of the last known real-time location update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastLocationUpdateTime(): Long = + lastLocationUpdateTime.getRequired("lastLocationUpdateTime") + + /** + * Timestamp of the last known real-time update from the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastUpdateTime(): Long = lastUpdateTime.getRequired("lastUpdateTime") + + /** + * Capacity of the transit vehicle in terms of occupancy. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCapacity(): Long = occupancyCapacity.getRequired("occupancyCapacity") + + /** + * Current count of occupants in the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyCount(): Long = occupancyCount.getRequired("occupancyCount") + + /** + * Current occupancy status of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun occupancyStatus(): String = occupancyStatus.getRequired("occupancyStatus") + + /** + * Current journey phase of the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun phase(): String = phase.getRequired("phase") + + /** + * Indicates if real-time arrival info is available for this trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun predicted(): Boolean = predicted.getRequired("predicted") + + /** + * Deviation from the schedule in seconds (positive for late, negative for early). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scheduleDeviation(): Long = scheduleDeviation.getRequired("scheduleDeviation") + + /** + * Time, in milliseconds since the Unix epoch, of midnight for the start of the + * service date for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceDate(): Long = serviceDate.getRequired("serviceDate") + + /** + * Current status modifiers for the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Total length of the trip, in meters. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun totalDistanceAlongTrip(): Double = + totalDistanceAlongTrip.getRequired("totalDistanceAlongTrip") + + /** + * Time offset from the closest stop to the current position of the transit vehicle + * (in seconds). + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closestStopTimeOffset(): Optional = + closestStopTimeOffset.getOptional("closestStopTimeOffset") + + /** + * Information about frequency-based scheduling, if applicable to the trip. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Last known location of the transit vehicle. + * + * @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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the last known location of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LastKnownLocation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastKnownLocation]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(lastKnownLocation: LastKnownLocation) = apply { + lat = lastKnownLocation.lat + lon = lastKnownLocation.lon + additionalProperties = + lastKnownLocation.additionalProperties.toMutableMap() + } + + /** Latitude of the last known location of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the last known location of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastKnownLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastKnownLocation = + LastKnownLocation(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LastKnownLocation = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastKnownLocation && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LastKnownLocation{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + /** Current position of the transit vehicle. */ + class Position + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lat: JsonField, + private val lon: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lat") + @ExcludeMissing + lat: JsonField = JsonMissing.of(), + @JsonProperty("lon") + @ExcludeMissing + lon: JsonField = JsonMissing.of(), + ) : this(lat, lon, mutableMapOf()) + + /** + * Latitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * Longitude of the current position of the transit vehicle. + * + * @throws OnebusawaySdkInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun lon(): Optional = lon.getOptional("lon") + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [lon]. + * + * Unlike [lon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lon") @ExcludeMissing fun _lon(): JsonField = lon + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Position]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Position]. */ + class Builder internal constructor() { + + private var lat: JsonField = JsonMissing.of() + private var lon: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(position: Position) = apply { + lat = position.lat + lon = position.lon + additionalProperties = position.additionalProperties.toMutableMap() + } + + /** Latitude of the current position of the transit vehicle. */ + fun lat(lat: Double) = lat(JsonField.of(lat)) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** Longitude of the current position of the transit vehicle. */ + fun lon(lon: Double) = lon(JsonField.of(lon)) + + /** + * Sets [Builder.lon] to an arbitrary JSON value. + * + * You should usually call [Builder.lon] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lon(lon: JsonField) = apply { this.lon = lon } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Position]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Position = + Position(lat, lon, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Position = apply { + if (validated) { + return@apply + } + + lat() + lon() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OnebusawaySdkInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lat.asKnown().isPresent) 1 else 0) + + (if (lon.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + lat == other.lat && + lon == other.lon && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lat, lon, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Position{lat=$lat, lon=$lon, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TripStatus && + activeTripId == other.activeTripId && + blockTripSequence == other.blockTripSequence && + closestStop == other.closestStop && + distanceAlongTrip == other.distanceAlongTrip && + lastKnownDistanceAlongTrip == other.lastKnownDistanceAlongTrip && + lastLocationUpdateTime == other.lastLocationUpdateTime && + lastUpdateTime == other.lastUpdateTime && + occupancyCapacity == other.occupancyCapacity && + occupancyCount == other.occupancyCount && + occupancyStatus == other.occupancyStatus && + phase == other.phase && + predicted == other.predicted && + scheduleDeviation == other.scheduleDeviation && + serviceDate == other.serviceDate && + status == other.status && + totalDistanceAlongTrip == other.totalDistanceAlongTrip && + closestStopTimeOffset == other.closestStopTimeOffset && + frequency == other.frequency && + lastKnownLocation == other.lastKnownLocation && + lastKnownOrientation == other.lastKnownOrientation && + nextStop == other.nextStop && + nextStopTimeOffset == other.nextStopTimeOffset && + orientation == other.orientation && + position == other.position && + scheduledDistanceAlongTrip == other.scheduledDistanceAlongTrip && + situationIds == other.situationIds && + vehicleId == other.vehicleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + activeTripId, + blockTripSequence, + closestStop, + distanceAlongTrip, + lastKnownDistanceAlongTrip, + lastLocationUpdateTime, + lastUpdateTime, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + predicted, + scheduleDeviation, + serviceDate, + status, + totalDistanceAlongTrip, + closestStopTimeOffset, + frequency, + lastKnownLocation, + lastKnownOrientation, + nextStop, + nextStopTimeOffset, + orientation, + position, + scheduledDistanceAlongTrip, + situationIds, + vehicleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TripStatus{activeTripId=$activeTripId, blockTripSequence=$blockTripSequence, closestStop=$closestStop, distanceAlongTrip=$distanceAlongTrip, lastKnownDistanceAlongTrip=$lastKnownDistanceAlongTrip, lastLocationUpdateTime=$lastLocationUpdateTime, lastUpdateTime=$lastUpdateTime, occupancyCapacity=$occupancyCapacity, occupancyCount=$occupancyCount, occupancyStatus=$occupancyStatus, phase=$phase, predicted=$predicted, scheduleDeviation=$scheduleDeviation, serviceDate=$serviceDate, status=$status, totalDistanceAlongTrip=$totalDistanceAlongTrip, closestStopTimeOffset=$closestStopTimeOffset, frequency=$frequency, lastKnownLocation=$lastKnownLocation, lastKnownOrientation=$lastKnownOrientation, nextStop=$nextStop, nextStopTimeOffset=$nextStopTimeOffset, orientation=$orientation, position=$position, scheduledDistanceAlongTrip=$scheduledDistanceAlongTrip, situationIds=$situationIds, vehicleId=$vehicleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + private val hashCode: Int by lazy { + Objects.hash( + lastLocationUpdateTime, + lastUpdateTime, + location, + tripId, + tripStatus, + vehicleId, + occupancyCapacity, + occupancyCount, + occupancyStatus, + phase, + status, + additionalProperties, + ) + } + + 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 other is Data && + limitExceeded == other.limitExceeded && + list == other.list && + references == other.references && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitExceeded, list, references, additionalProperties) + } + + 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 other is VehiclesForAgencyListResponse && + code == other.code && + currentTime == other.currentTime && + text == other.text && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, currentTime, text, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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 new file mode 100644 index 0000000..eb5b698 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsync.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgenciesWithCoverageServiceAsync + + /** + * Returns a list of all transit agencies currently supported by OneBusAway along with the + * center of their coverage area. + */ + fun list(): CompletableFuture = + list(AgenciesWithCoverageListParams.none()) + + /** @see list */ + fun list( + 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/agencies-with-coverage.json`, but is + * otherwise the same as [AgenciesWithCoverageServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(AgenciesWithCoverageListParams.none()) + + /** @see list */ + fun list( + 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) + } +} 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 new file mode 100644 index 0000000..537e684 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgenciesWithCoverageServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse + +class AgenciesWithCoverageServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCoverageServiceAsync { + + private val withRawResponse: AgenciesWithCoverageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AgenciesWithCoverageServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageServiceAsync = + AgenciesWithCoverageServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun list( + params: AgenciesWithCoverageListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageServiceAsync.WithRawResponse = + AgenciesWithCoverageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: AgenciesWithCoverageListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt new file mode 100644 index 0000000..ba23172 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsync.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgencyServiceAsync + + /** Retrieve information for a specific transit agency identified by its unique ID. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AgencyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/agency/{agencyID}.json`, but is otherwise + * the same as [AgencyServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..72a44e2 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/AgencyServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.agency.AgencyRetrieveParams +import org.onebusaway.models.agency.AgencyRetrieveResponse + +class AgencyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyServiceAsync { + + private val withRawResponse: AgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AgencyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AgencyServiceAsync = + AgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: AgencyRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AgencyServiceAsync.WithRawResponse = + AgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..2e8e57a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsync.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ArrivalAndDepartureServiceAsync + + /** arrival-and-departure-for-stop */ + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): CompletableFuture = + retrieve(stopId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + 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 */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureServiceAsync.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]. + */ + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + ): CompletableFuture> = + retrieve(stopId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + stopId: String, + params: ArrivalAndDepartureRetrieveParams, + 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> + + /** + * Returns a raw HTTP response for `get + * /api/where/arrivals-and-departures-for-stop/{stopID}.json`, but is otherwise the same as + * [ArrivalAndDepartureServiceAsync.list]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..b57d9a8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ArrivalAndDepartureServiceAsyncImpl.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.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 { + + private val withRawResponse: ArrivalAndDepartureServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ArrivalAndDepartureServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureServiceAsync = + ArrivalAndDepartureServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/where/arrival-and-departure-for-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ArrivalAndDepartureListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureServiceAsync.WithRawResponse = + ArrivalAndDepartureServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt new file mode 100644 index 0000000..45864a1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsync.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BlockServiceAsync + + /** Get details of a specific block by ID */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BlockServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/block/{blockID}.json`, but is otherwise + * the same as [BlockServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..33ef118 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/BlockServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.block.BlockRetrieveParams +import org.onebusaway.models.block.BlockRetrieveResponse + +class BlockServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BlockServiceAsync { + + private val withRawResponse: BlockServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BlockServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BlockServiceAsync = + BlockServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: BlockRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BlockServiceAsync.WithRawResponse = + BlockServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..d3113b9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsync.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigServiceAsync + + /** config */ + fun retrieve(): CompletableFuture = + retrieve(ConfigRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConfigServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/config.json`, but is otherwise the same + * as [ConfigServiceAsync.retrieve]. + */ + fun retrieve(): CompletableFuture> = + retrieve(ConfigRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + 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) + } +} 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 new file mode 100644 index 0000000..a78014d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ConfigServiceAsyncImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.config.ConfigRetrieveParams +import org.onebusaway.models.config.ConfigRetrieveResponse + +class ConfigServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigServiceAsync { + + private val withRawResponse: ConfigServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ConfigServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ConfigServiceAsync = + ConfigServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ConfigRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ConfigServiceAsync.WithRawResponse = + ConfigServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ConfigRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..3633b2d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsync.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CurrentTimeServiceAsync + + /** current-time */ + fun retrieve(): CompletableFuture = + retrieve(CurrentTimeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CurrentTimeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/current-time.json`, but is otherwise the + * same as [CurrentTimeServiceAsync.retrieve]. + */ + fun retrieve(): CompletableFuture> = + retrieve(CurrentTimeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + 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) + } +} 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 new file mode 100644 index 0000000..91c6bf4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/CurrentTimeServiceAsyncImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse + +class CurrentTimeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeServiceAsync { + + private val withRawResponse: CurrentTimeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CurrentTimeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CurrentTimeServiceAsync = + CurrentTimeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: CurrentTimeRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CurrentTimeServiceAsync.WithRawResponse = + CurrentTimeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CurrentTimeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..5e5e8b7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsync.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ReportProblemWithStopServiceAsync + + /** Submit a user-generated problem report for a stop */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ReportProblemWithStopServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-stop/{stopID}.json`, + * but is otherwise the same as [ReportProblemWithStopServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..a7819eb --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithStopServiceAsyncImpl.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams + +class ReportProblemWithStopServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithStopServiceAsync { + + private val withRawResponse: ReportProblemWithStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ReportProblemWithStopServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): ReportProblemWithStopServiceAsync = + ReportProblemWithStopServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun retrieve( + params: ReportProblemWithStopRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ReportProblemWithStopServiceAsync.WithRawResponse = + ReportProblemWithStopServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..45cb1d0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsync.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ReportProblemWithTripServiceAsync + + /** Submit a user-generated problem report for a particular trip. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ReportProblemWithTripServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/report-problem-with-trip/{tripID}.json`, + * but is otherwise the same as [ReportProblemWithTripServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..7fe7d3b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ReportProblemWithTripServiceAsyncImpl.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams + +class ReportProblemWithTripServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithTripServiceAsync { + + private val withRawResponse: ReportProblemWithTripServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ReportProblemWithTripServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): ReportProblemWithTripServiceAsync = + ReportProblemWithTripServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun retrieve( + params: ReportProblemWithTripRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ReportProblemWithTripServiceAsync.WithRawResponse = + ReportProblemWithTripServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..42a40e4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsync.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteIdsForAgencyServiceAsync + + /** Get route IDs for a specific agency */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/route-ids-for-agency/{agencyID}.json`, + * but is otherwise the same as [RouteIdsForAgencyServiceAsync.list]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..d00b5f0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteIdsForAgencyServiceAsyncImpl.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListResponse + +class RouteIdsForAgencyServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : RouteIdsForAgencyServiceAsync { + + private val withRawResponse: RouteIdsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RouteIdsForAgencyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyServiceAsync = + RouteIdsForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: RouteIdsForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyServiceAsync.WithRawResponse = + RouteIdsForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt new file mode 100644 index 0000000..8346897 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsync.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteServiceAsync + + /** Retrieve information for a specific route identified by its unique ID. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RouteServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/route/{routeID}.json`, but is otherwise + * the same as [RouteServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..9cc8f05 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RouteServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.route.RouteRetrieveParams +import org.onebusaway.models.route.RouteRetrieveResponse + +class RouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RouteServiceAsync { + + private val withRawResponse: RouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RouteServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RouteServiceAsync = + RouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: RouteRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RouteServiceAsync.WithRawResponse = + RouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..ff0f0a3 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsync.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RoutesForAgencyServiceAsync + + /** Retrieve the list of all routes for a particular agency by id */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RoutesForAgencyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-agency/{agencyID}.json`, but + * is otherwise the same as [RoutesForAgencyServiceAsync.list]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..cc41486 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForAgencyServiceAsyncImpl.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse + +class RoutesForAgencyServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : RoutesForAgencyServiceAsync { + + private val withRawResponse: RoutesForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RoutesForAgencyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): RoutesForAgencyServiceAsync = + RoutesForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: RoutesForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RoutesForAgencyServiceAsync.WithRawResponse = + RoutesForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt new file mode 100644 index 0000000..4139e16 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsync.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RoutesForLocationServiceAsync + + /** routes-for-location */ + fun list( + params: RoutesForLocationListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [RoutesForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RoutesForLocationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/routes-for-location.json`, but is + * otherwise the same as [RoutesForLocationServiceAsync.list]. + */ + fun list( + params: RoutesForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + 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 new file mode 100644 index 0000000..8719b18 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/RoutesForLocationServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse + +class RoutesForLocationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : RoutesForLocationServiceAsync { + + private val withRawResponse: RoutesForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RoutesForLocationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): RoutesForLocationServiceAsync = + RoutesForLocationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: RoutesForLocationListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RoutesForLocationServiceAsync.WithRawResponse = + RoutesForLocationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt new file mode 100644 index 0000000..80913ce --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsync.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ScheduleForRouteServiceAsync + + /** Retrieve the full schedule for a route on a particular day */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ScheduleForRouteServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-route/{routeID}.json`, but + * is otherwise the same as [ScheduleForRouteServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..54e4ecd --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForRouteServiceAsyncImpl.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse + +class ScheduleForRouteServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ScheduleForRouteServiceAsync { + + private val withRawResponse: ScheduleForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ScheduleForRouteServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): ScheduleForRouteServiceAsync = + ScheduleForRouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ScheduleForRouteRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ScheduleForRouteServiceAsync.WithRawResponse = + ScheduleForRouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..b38e096 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsync.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ScheduleForStopServiceAsync + + /** Get schedule for a specific stop */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ScheduleForStopServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/schedule-for-stop/{stopID}.json`, but is + * otherwise the same as [ScheduleForStopServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..fa677e4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ScheduleForStopServiceAsyncImpl.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveResponse + +class ScheduleForStopServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ScheduleForStopServiceAsync { + + private val withRawResponse: ScheduleForStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ScheduleForStopServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): ScheduleForStopServiceAsync = + ScheduleForStopServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ScheduleForStopRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ScheduleForStopServiceAsync.WithRawResponse = + ScheduleForStopServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..46045e0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsync.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SearchForRouteServiceAsync + + /** Search for a route based on its name. */ + fun list(params: SearchForRouteListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [SearchForRouteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SearchForRouteServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/search/route.json`, but is otherwise the + * same as [SearchForRouteServiceAsync.list]. + */ + fun list( + params: SearchForRouteListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + 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 new file mode 100644 index 0000000..8044e67 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForRouteServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.searchforroute.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListResponse + +class SearchForRouteServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : SearchForRouteServiceAsync { + + private val withRawResponse: SearchForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SearchForRouteServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): SearchForRouteServiceAsync = + SearchForRouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SearchForRouteListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SearchForRouteServiceAsync.WithRawResponse = + SearchForRouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt new file mode 100644 index 0000000..7b61e21 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsync.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SearchForStopServiceAsync + + /** Search for a stop based on its name. */ + fun list(params: SearchForStopListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [SearchForStopServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SearchForStopServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/search/stop.json`, but is otherwise the + * same as [SearchForStopServiceAsync.list]. + */ + fun list( + params: SearchForStopListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + 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 new file mode 100644 index 0000000..6403aef --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/SearchForStopServiceAsyncImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.searchforstop.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListResponse + +class SearchForStopServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopServiceAsync { + + private val withRawResponse: SearchForStopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SearchForStopServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SearchForStopServiceAsync = + SearchForStopServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SearchForStopListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SearchForStopServiceAsync.WithRawResponse = + SearchForStopServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt new file mode 100644 index 0000000..f5b9a84 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsync.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ShapeServiceAsync + + /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ShapeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/shape/{shapeID}.json`, but is otherwise + * the same as [ShapeServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..bad093d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/ShapeServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.shape.ShapeRetrieveParams +import org.onebusaway.models.shape.ShapeRetrieveResponse + +class ShapeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeServiceAsync { + + private val withRawResponse: ShapeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ShapeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ShapeServiceAsync = + ShapeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ShapeRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ShapeServiceAsync.WithRawResponse = + ShapeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..dcfafa8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsync.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopIdsForAgencyServiceAsync + + /** Get stop IDs for a specific agency */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopIdsForAgencyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/stop-ids-for-agency/{agencyID}.json`, but + * is otherwise the same as [StopIdsForAgencyServiceAsync.list]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..aa48bc5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopIdsForAgencyServiceAsyncImpl.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse + +class StopIdsForAgencyServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : StopIdsForAgencyServiceAsync { + + private val withRawResponse: StopIdsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopIdsForAgencyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): StopIdsForAgencyServiceAsync = + StopIdsForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: StopIdsForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopIdsForAgencyServiceAsync.WithRawResponse = + StopIdsForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt new file mode 100644 index 0000000..b45a36a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsync.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopServiceAsync + + /** Get details of a specific stop */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/stop/{stopID}.json`, but is otherwise the + * same as [StopServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..12d550b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.stop.StopRetrieveParams +import org.onebusaway.models.stop.StopRetrieveResponse + +class StopServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + StopServiceAsync { + + private val withRawResponse: StopServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): StopServiceAsync = + StopServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: StopRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopServiceAsync.WithRawResponse = + StopServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..495b475 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsync.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForAgencyServiceAsync + + /** Get stops for a specific agency */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForAgencyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-agency/{agencyID}.json`, but is + * otherwise the same as [StopsForAgencyServiceAsync.list]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..1a73b1b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForAgencyServiceAsyncImpl.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.stopsforagency.StopsForAgencyListParams +import org.onebusaway.models.stopsforagency.StopsForAgencyListResponse + +class StopsForAgencyServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : StopsForAgencyServiceAsync { + + private val withRawResponse: StopsForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopsForAgencyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): StopsForAgencyServiceAsync = + StopsForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: StopsForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopsForAgencyServiceAsync.WithRawResponse = + StopsForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt new file mode 100644 index 0000000..678d52a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsync.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForLocationServiceAsync + + /** stops-for-location */ + fun list(params: StopsForLocationListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [StopsForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForLocationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-location.json`, but is + * otherwise the same as [StopsForLocationServiceAsync.list]. + */ + fun list( + params: StopsForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + 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 new file mode 100644 index 0000000..54f5fbd --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForLocationServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse + +class StopsForLocationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : StopsForLocationServiceAsync { + + private val withRawResponse: StopsForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopsForLocationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): StopsForLocationServiceAsync = + StopsForLocationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: StopsForLocationListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopsForLocationServiceAsync.WithRawResponse = + StopsForLocationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt new file mode 100644 index 0000000..b87c79e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsync.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForRouteServiceAsync + + /** Get stops for a specific route */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForRouteServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/stops-for-route/{routeID}.json`, but is + * otherwise the same as [StopsForRouteServiceAsync.list]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..00f5ebf --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/StopsForRouteServiceAsyncImpl.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.stopsforroute.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse + +class StopsForRouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteServiceAsync { + + private val withRawResponse: StopsForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopsForRouteServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): StopsForRouteServiceAsync = + StopsForRouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: StopsForRouteListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopsForRouteServiceAsync.WithRawResponse = + StopsForRouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt new file mode 100644 index 0000000..f029939 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsync.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripDetailServiceAsync + + /** Retrieve Trip Details */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripDetailServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/trip-details/{tripID}.json`, but is + * otherwise the same as [TripDetailServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..c17230e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripDetailServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse + +class TripDetailServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailServiceAsync { + + private val withRawResponse: TripDetailServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripDetailServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TripDetailServiceAsync = + TripDetailServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TripDetailRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripDetailServiceAsync.WithRawResponse = + TripDetailServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..2ae50a4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsync.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripForVehicleServiceAsync + + /** Retrieve trip for a specific vehicle */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripForVehicleServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/trip-for-vehicle/{vehicleID}.json`, but + * is otherwise the same as [TripForVehicleServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..2261407 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripForVehicleServiceAsyncImpl.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse + +class TripForVehicleServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : TripForVehicleServiceAsync { + + private val withRawResponse: TripForVehicleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripForVehicleServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): TripForVehicleServiceAsync = + TripForVehicleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TripForVehicleRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripForVehicleServiceAsync.WithRawResponse = + TripForVehicleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..9e01a86 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsync.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripServiceAsync + + /** Get details of a specific trip */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/trip/{tripID}.json`, but is otherwise the + * same as [TripServiceAsync.retrieve]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..961c393 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.trip.TripRetrieveParams +import org.onebusaway.models.trip.TripRetrieveResponse + +class TripServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripServiceAsync { + + private val withRawResponse: TripServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TripServiceAsync = + TripServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TripRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripServiceAsync.WithRawResponse = + TripServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(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 new file mode 100644 index 0000000..ffbce1b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsync.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripsForLocationServiceAsync + + /** Retrieve trips for a given location */ + fun list(params: TripsForLocationListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [TripsForLocationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripsForLocationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-location.json`, but is + * otherwise the same as [TripsForLocationServiceAsync.list]. + */ + fun list( + params: TripsForLocationListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + 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 new file mode 100644 index 0000000..29759f1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForLocationServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListResponse + +class TripsForLocationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : TripsForLocationServiceAsync { + + private val withRawResponse: TripsForLocationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripsForLocationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): TripsForLocationServiceAsync = + TripsForLocationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: TripsForLocationListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripsForLocationServiceAsync.WithRawResponse = + TripsForLocationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt new file mode 100644 index 0000000..0e58166 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsync.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripsForRouteServiceAsync + + /** Search for active trips for a specific route. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripsForRouteServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/trips-for-route/{routeID}.json`, but is + * otherwise the same as [TripsForRouteServiceAsync.list]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..79c7025 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/TripsForRouteServiceAsyncImpl.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.tripsforroute.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse + +class TripsForRouteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteServiceAsync { + + private val withRawResponse: TripsForRouteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripsForRouteServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TripsForRouteServiceAsync = + TripsForRouteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: TripsForRouteListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripsForRouteServiceAsync.WithRawResponse = + TripsForRouteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt new file mode 100644 index 0000000..0f1b642 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsync.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VehiclesForAgencyServiceAsync + + /** Get vehicles for a specific agency */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VehiclesForAgencyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/where/vehicles-for-agency/{agencyID}.json`, but + * is otherwise the same as [VehiclesForAgencyServiceAsync.list]. + */ + 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(), + ): 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) + } +} 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 new file mode 100644 index 0000000..b04c71b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/async/VehiclesForAgencyServiceAsyncImpl.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.async + +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepareAsync +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse + +class VehiclesForAgencyServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : VehiclesForAgencyServiceAsync { + + private val withRawResponse: VehiclesForAgencyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VehiclesForAgencyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): VehiclesForAgencyServiceAsync = + VehiclesForAgencyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: VehiclesForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VehiclesForAgencyServiceAsync.WithRawResponse = + VehiclesForAgencyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt new file mode 100644 index 0000000..1b40ebd --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageService.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgenciesWithCoverageService + + /** + * Returns a list of all transit agencies currently supported by OneBusAway along with the + * center of their coverage area. + */ + fun list(): AgenciesWithCoverageListResponse = list(AgenciesWithCoverageListParams.none()) + + /** @see list */ + fun list( + 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageService.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 new file mode 100644 index 0000000..ad0748b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListParams +import org.onebusaway.models.agencieswithcoverage.AgenciesWithCoverageListResponse + +class AgenciesWithCoverageServiceImpl +internal constructor(private val clientOptions: ClientOptions) : AgenciesWithCoverageService { + + private val withRawResponse: AgenciesWithCoverageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AgenciesWithCoverageService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageService = + AgenciesWithCoverageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: AgenciesWithCoverageListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AgenciesWithCoverageService.WithRawResponse = + AgenciesWithCoverageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: AgenciesWithCoverageListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt new file mode 100644 index 0000000..cc455d8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyService.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgencyService + + /** Retrieve information for a specific transit agency identified by its unique ID. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AgencyService.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 new file mode 100644 index 0000000..932c3e8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/AgencyServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.agency.AgencyRetrieveParams +import org.onebusaway.models.agency.AgencyRetrieveResponse + +class AgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AgencyService { + + private val withRawResponse: AgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AgencyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AgencyService = + AgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: AgencyRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AgencyService.WithRawResponse = + AgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..b0e8b2f --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureService.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ArrivalAndDepartureService + + /** arrival-and-departure-for-stop */ + 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(), + ): ArrivalAndDepartureRetrieveResponse + + /** arrivals-and-departures-for-stop */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureService.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 new file mode 100644 index 0000000..03cd862 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceImpl.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.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 { + + private val withRawResponse: ArrivalAndDepartureService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ArrivalAndDepartureService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureService = + ArrivalAndDepartureServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ArrivalAndDepartureRetrieveParams, + requestOptions: RequestOptions, + ): ArrivalAndDepartureRetrieveResponse = + // get /api/where/arrival-and-departure-for-stop/{stopID}.json + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: ArrivalAndDepartureListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ArrivalAndDepartureService.WithRawResponse = + ArrivalAndDepartureServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt new file mode 100644 index 0000000..91e4b23 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockService.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BlockService + + /** Get details of a specific block by ID */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BlockService.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 new file mode 100644 index 0000000..f18d378 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/BlockServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.block.BlockRetrieveParams +import org.onebusaway.models.block.BlockRetrieveResponse + +class BlockServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BlockService { + + private val withRawResponse: BlockService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BlockService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BlockService = + BlockServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: BlockRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BlockService.WithRawResponse = + BlockServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..69cae27 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigService.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigService + + /** config */ + fun retrieve(): ConfigRetrieveResponse = retrieve(ConfigRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigService.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 new file mode 100644 index 0000000..8382f69 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ConfigServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.config.ConfigRetrieveParams +import org.onebusaway.models.config.ConfigRetrieveResponse + +class ConfigServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigService { + + private val withRawResponse: ConfigService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ConfigService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ConfigService = + ConfigServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ConfigRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ConfigService.WithRawResponse = + ConfigServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ConfigRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "where", "config.json") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { 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 new file mode 100644 index 0000000..d6a68df --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeService.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CurrentTimeService + + /** current-time */ + fun retrieve(): CurrentTimeRetrieveResponse = retrieve(CurrentTimeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CurrentTimeService.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 new file mode 100644 index 0000000..c72c164 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams +import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse + +class CurrentTimeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentTimeService { + + private val withRawResponse: CurrentTimeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CurrentTimeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CurrentTimeService = + CurrentTimeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: CurrentTimeRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CurrentTimeService.WithRawResponse = + CurrentTimeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CurrentTimeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..04978b0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopService.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ReportProblemWithStopService + + /** Submit a user-generated problem report for a stop */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ReportProblemWithStopService.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 new file mode 100644 index 0000000..bda8791 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceImpl.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams + +class ReportProblemWithStopServiceImpl +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithStopService { + + private val withRawResponse: ReportProblemWithStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ReportProblemWithStopService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): ReportProblemWithStopService = + ReportProblemWithStopServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ReportProblemWithStopRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ReportProblemWithStopService.WithRawResponse = + ReportProblemWithStopServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..af1cc33 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripService.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ReportProblemWithTripService + + /** Submit a user-generated problem report for a particular trip. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ReportProblemWithTripService.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 new file mode 100644 index 0000000..722954e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceImpl.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.ResponseWrapper +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams + +class ReportProblemWithTripServiceImpl +internal constructor(private val clientOptions: ClientOptions) : ReportProblemWithTripService { + + private val withRawResponse: ReportProblemWithTripService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ReportProblemWithTripService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): ReportProblemWithTripService = + ReportProblemWithTripServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ReportProblemWithTripRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ReportProblemWithTripService.WithRawResponse = + ReportProblemWithTripServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..2e52fcf --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyService.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteIdsForAgencyService + + /** Get route IDs for a specific agency */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyService.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 new file mode 100644 index 0000000..f912346 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListParams +import org.onebusaway.models.routeidsforagency.RouteIdsForAgencyListResponse + +class RouteIdsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RouteIdsForAgencyService { + + private val withRawResponse: RouteIdsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RouteIdsForAgencyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RouteIdsForAgencyService = + RouteIdsForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: RouteIdsForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RouteIdsForAgencyService.WithRawResponse = + RouteIdsForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt new file mode 100644 index 0000000..e2b00f0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteService.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteService + + /** Retrieve information for a specific route identified by its unique ID. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RouteService.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 new file mode 100644 index 0000000..9e1147b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RouteServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.route.RouteRetrieveParams +import org.onebusaway.models.route.RouteRetrieveResponse + +class RouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RouteService { + + private val withRawResponse: RouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RouteService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RouteService = + RouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: RouteRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RouteService.WithRawResponse = + RouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..c27448a --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyService.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RoutesForAgencyService + + /** Retrieve the list of all routes for a particular agency by id */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RoutesForAgencyService.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 new file mode 100644 index 0000000..4052295 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.routesforagency.RoutesForAgencyListParams +import org.onebusaway.models.routesforagency.RoutesForAgencyListResponse + +class RoutesForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForAgencyService { + + private val withRawResponse: RoutesForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RoutesForAgencyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RoutesForAgencyService = + RoutesForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: RoutesForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RoutesForAgencyService.WithRawResponse = + RoutesForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt new file mode 100644 index 0000000..2500877 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationService.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RoutesForLocationService + + /** routes-for-location */ + fun list(params: RoutesForLocationListParams): RoutesForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RoutesForLocationListResponse + + /** + * A view of [RoutesForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RoutesForLocationService.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 new file mode 100644 index 0000000..0fecfaf --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams +import org.onebusaway.models.routesforlocation.RoutesForLocationListResponse + +class RoutesForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RoutesForLocationService { + + private val withRawResponse: RoutesForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RoutesForLocationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RoutesForLocationService = + RoutesForLocationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: RoutesForLocationListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RoutesForLocationService.WithRawResponse = + RoutesForLocationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: RoutesForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt new file mode 100644 index 0000000..1bddcea --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteService.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ScheduleForRouteService + + /** Retrieve the full schedule for a route on a particular day */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ScheduleForRouteService.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 new file mode 100644 index 0000000..62eeb4f --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveResponse + +class ScheduleForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForRouteService { + + private val withRawResponse: ScheduleForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ScheduleForRouteService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ScheduleForRouteService = + ScheduleForRouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ScheduleForRouteRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ScheduleForRouteService.WithRawResponse = + ScheduleForRouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..a04105d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopService.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ScheduleForStopService + + /** Get schedule for a specific stop */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ScheduleForStopService.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 new file mode 100644 index 0000000..a9650ba --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveResponse + +class ScheduleForStopServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ScheduleForStopService { + + private val withRawResponse: ScheduleForStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ScheduleForStopService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ScheduleForStopService = + ScheduleForStopServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ScheduleForStopRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ScheduleForStopService.WithRawResponse = + ScheduleForStopServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..9d2a691 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteService.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SearchForRouteService + + /** Search for a route based on its name. */ + fun list(params: SearchForRouteListParams): SearchForRouteListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SearchForRouteListResponse + + /** + * A view of [SearchForRouteService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SearchForRouteService.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 new file mode 100644 index 0000000..c573701 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.searchforroute.SearchForRouteListParams +import org.onebusaway.models.searchforroute.SearchForRouteListResponse + +class SearchForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForRouteService { + + private val withRawResponse: SearchForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SearchForRouteService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SearchForRouteService = + SearchForRouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SearchForRouteListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SearchForRouteService.WithRawResponse = + SearchForRouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SearchForRouteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt new file mode 100644 index 0000000..0af6320 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopService.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SearchForStopService + + /** Search for a stop based on its name. */ + fun list(params: SearchForStopListParams): SearchForStopListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SearchForStopListResponse + + /** + * A view of [SearchForStopService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SearchForStopService.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 new file mode 100644 index 0000000..7369386 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/SearchForStopServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.searchforstop.SearchForStopListParams +import org.onebusaway.models.searchforstop.SearchForStopListResponse + +class SearchForStopServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SearchForStopService { + + private val withRawResponse: SearchForStopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SearchForStopService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SearchForStopService = + SearchForStopServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SearchForStopListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SearchForStopService.WithRawResponse = + SearchForStopServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SearchForStopListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt new file mode 100644 index 0000000..7e6ef9d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeService.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ShapeService + + /** Retrieve a shape (the path traveled by a transit vehicle) by ID. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ShapeService.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 new file mode 100644 index 0000000..d3baa4e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/ShapeServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.shape.ShapeRetrieveParams +import org.onebusaway.models.shape.ShapeRetrieveResponse + +class ShapeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ShapeService { + + private val withRawResponse: ShapeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ShapeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ShapeService = + ShapeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ShapeRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ShapeService.WithRawResponse = + ShapeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..03ebd49 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyService.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopIdsForAgencyService + + /** Get stop IDs for a specific agency */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopIdsForAgencyService.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 new file mode 100644 index 0000000..15e1ef2 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListParams +import org.onebusaway.models.stopidsforagency.StopIdsForAgencyListResponse + +class StopIdsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopIdsForAgencyService { + + private val withRawResponse: StopIdsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopIdsForAgencyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): StopIdsForAgencyService = + StopIdsForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: StopIdsForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopIdsForAgencyService.WithRawResponse = + StopIdsForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt new file mode 100644 index 0000000..e8db5ad --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopService.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopService + + /** Get details of a specific stop */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopService.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 new file mode 100644 index 0000000..b319d01 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopServiceImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.stop.StopRetrieveParams +import org.onebusaway.models.stop.StopRetrieveResponse + +class StopServiceImpl internal constructor(private val clientOptions: ClientOptions) : StopService { + + private val withRawResponse: StopService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): StopService = + StopServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: StopRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopService.WithRawResponse = + StopServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..75caf05 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyService.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForAgencyService + + /** Get stops for a specific agency */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForAgencyService.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 new file mode 100644 index 0000000..cb02a72 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.stopsforagency.StopsForAgencyListParams +import org.onebusaway.models.stopsforagency.StopsForAgencyListResponse + +class StopsForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForAgencyService { + + private val withRawResponse: StopsForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopsForAgencyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): StopsForAgencyService = + StopsForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: StopsForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopsForAgencyService.WithRawResponse = + StopsForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt new file mode 100644 index 0000000..ab1b432 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationService.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForLocationService + + /** stops-for-location */ + fun list(params: StopsForLocationListParams): StopsForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): StopsForLocationListResponse + + /** + * A view of [StopsForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForLocationService.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 new file mode 100644 index 0000000..9b6d455 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams +import org.onebusaway.models.stopsforlocation.StopsForLocationListResponse + +class StopsForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForLocationService { + + private val withRawResponse: StopsForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopsForLocationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): StopsForLocationService = + StopsForLocationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: StopsForLocationListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopsForLocationService.WithRawResponse = + StopsForLocationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: StopsForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt new file mode 100644 index 0000000..4b034ae --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteService.kt @@ -0,0 +1,116 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): StopsForRouteService + + /** Get stops for a specific route */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): StopsForRouteService.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 new file mode 100644 index 0000000..89bccf8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.stopsforroute.StopsForRouteListParams +import org.onebusaway.models.stopsforroute.StopsForRouteListResponse + +class StopsForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StopsForRouteService { + + private val withRawResponse: StopsForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): StopsForRouteService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): StopsForRouteService = + StopsForRouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: StopsForRouteListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): StopsForRouteService.WithRawResponse = + StopsForRouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt new file mode 100644 index 0000000..c1440a4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailService.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripDetailService + + /** Retrieve Trip Details */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripDetailService.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 new file mode 100644 index 0000000..7f98b3c --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripDetailServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams +import org.onebusaway.models.tripdetails.TripDetailRetrieveResponse + +class TripDetailServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripDetailService { + + private val withRawResponse: TripDetailService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripDetailService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TripDetailService = + TripDetailServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TripDetailRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripDetailService.WithRawResponse = + TripDetailServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..ea9412b --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleService.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripForVehicleService + + /** Retrieve trip for a specific vehicle */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripForVehicleService.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 new file mode 100644 index 0000000..21ebfa2 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveResponse + +class TripForVehicleServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripForVehicleService { + + private val withRawResponse: TripForVehicleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripForVehicleService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TripForVehicleService = + TripForVehicleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TripForVehicleRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripForVehicleService.WithRawResponse = + TripForVehicleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..b45580d --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripService.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripService + + /** Get details of a specific trip */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripService.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 new file mode 100644 index 0000000..0b85b81 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripServiceImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.trip.TripRetrieveParams +import org.onebusaway.models.trip.TripRetrieveResponse + +class TripServiceImpl internal constructor(private val clientOptions: ClientOptions) : TripService { + + private val withRawResponse: TripService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TripService = + TripServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TripRetrieveParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripService.WithRawResponse = + TripServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(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 new file mode 100644 index 0000000..9d5f98e --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationService.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripsForLocationService + + /** Retrieve trips for a given location */ + fun list(params: TripsForLocationListParams): TripsForLocationListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TripsForLocationListResponse + + /** + * A view of [TripsForLocationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripsForLocationService.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 new file mode 100644 index 0000000..23fe639 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams +import org.onebusaway.models.tripsforlocation.TripsForLocationListResponse + +class TripsForLocationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForLocationService { + + private val withRawResponse: TripsForLocationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripsForLocationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TripsForLocationService = + TripsForLocationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: TripsForLocationListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripsForLocationService.WithRawResponse = + TripsForLocationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: TripsForLocationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt new file mode 100644 index 0000000..2b319a0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteService.kt @@ -0,0 +1,116 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TripsForRouteService + + /** Search for active trips for a specific route. */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TripsForRouteService.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 new file mode 100644 index 0000000..6dc7bf1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.tripsforroute.TripsForRouteListParams +import org.onebusaway.models.tripsforroute.TripsForRouteListResponse + +class TripsForRouteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TripsForRouteService { + + private val withRawResponse: TripsForRouteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TripsForRouteService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TripsForRouteService = + TripsForRouteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: TripsForRouteListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TripsForRouteService.WithRawResponse = + TripsForRouteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt new file mode 100644 index 0000000..cea5486 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyService.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.models.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 + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VehiclesForAgencyService + + /** Get vehicles for a specific agency */ + 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(), + ): 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 view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VehiclesForAgencyService.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 new file mode 100644 index 0000000..c3e6e45 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceImpl.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull +import org.onebusaway.core.ClientOptions +import org.onebusaway.core.RequestOptions +import org.onebusaway.core.checkRequired +import org.onebusaway.core.handlers.errorBodyHandler +import org.onebusaway.core.handlers.errorHandler +import org.onebusaway.core.handlers.jsonHandler +import org.onebusaway.core.http.HttpMethod +import org.onebusaway.core.http.HttpRequest +import org.onebusaway.core.http.HttpResponse +import org.onebusaway.core.http.HttpResponse.Handler +import org.onebusaway.core.http.HttpResponseFor +import org.onebusaway.core.http.parseable +import org.onebusaway.core.prepare +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListResponse + +class VehiclesForAgencyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + VehiclesForAgencyService { + + private val withRawResponse: VehiclesForAgencyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VehiclesForAgencyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VehiclesForAgencyService = + VehiclesForAgencyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: VehiclesForAgencyListParams, + 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(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VehiclesForAgencyService.WithRawResponse = + VehiclesForAgencyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + 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) + .baseUrl(clientOptions.baseUrl()) + .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 errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/onebusaway-sdk-java-core/src/main/resources/META-INF/proguard/onebusaway-sdk-java-core.pro b/onebusaway-sdk-java-core/src/main/resources/META-INF/proguard/onebusaway-sdk-java-core.pro new file mode 100644 index 0000000..8c798f7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/main/resources/META-INF/proguard/onebusaway-sdk-java-core.pro @@ -0,0 +1,32 @@ +# Jackson uses reflection and depends heavily on runtime attributes. +-keepattributes Exceptions,InnerClasses,Signature,Deprecated,*Annotation* + +# Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. +-keep class kotlin.reflect.** { *; } +-keep class kotlin.Metadata { *; } + +# Jackson uses reflection to access enum members (e.g. via `java.lang.Class.getEnumConstants()`). +-keepclassmembers class com.fasterxml.jackson.** extends java.lang.Enum { + ; + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Jackson uses reflection to access annotation members. +-keepclassmembers @interface com.fasterxml.jackson.annotation.** { + *; +} + +# Jackson uses reified type information to serialize and deserialize our classes (via `TypeReference`). +-keep class com.fasterxml.jackson.core.type.TypeReference { *; } +-keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } + +# Jackson uses reflection to access our class serializers and deserializers. +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class org.onebusaway.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class org.onebusaway.** { *; } + +# Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. +-keepclassmembers class org.onebusaway.** { + (...); + @com.fasterxml.jackson.annotation.* *; +} \ No newline at end of file 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 new file mode 100644 index 0000000..ce4f7d3 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/TestServerExtension.kt @@ -0,0 +1,62 @@ +package org.onebusaway + +import java.lang.RuntimeException +import java.net.URL +import org.junit.jupiter.api.extension.BeforeAllCallback +import org.junit.jupiter.api.extension.ConditionEvaluationResult +import org.junit.jupiter.api.extension.ExecutionCondition +import org.junit.jupiter.api.extension.ExtensionContext + +class TestServerExtension : BeforeAllCallback, ExecutionCondition { + + override fun beforeAll(context: ExtensionContext?) { + try { + URL(BASE_URL).openConnection().connect() + } catch (e: Exception) { + throw RuntimeException( + """ + The test suite will not run without a mock Prism server running against your OpenAPI spec. + + You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests + that require the mock server. + + To fix: + + 1. Install Prism (requires Node 16+): + + With npm: + $ npm install -g @stoplight/prism-cli + + With yarn: + $ yarn global add @stoplight/prism-cli + + 2. Run the mock server + + To run the server, pass in the path of your OpenAPI spec to the prism command: + $ prism mock path/to/your.openapi.yml + """ + .trimIndent(), + e, + ) + } + } + + override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { + return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { + ConditionEvaluationResult.disabled( + "Environment variable $SKIP_TESTS_ENV is set to true" + ) + } else { + ConditionEvaluationResult.enabled( + "Environment variable $SKIP_TESTS_ENV is not set to true" + ) + } + } + + companion object { + + val BASE_URL = System.getenv("TEST_API_BASE_URL") ?: "http://localhost:4010" + + const val SKIP_TESTS_ENV: String = "SKIP_MOCK_TESTS" + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt new file mode 100644 index 0000000..356afe7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/ClientOptionsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify +import org.onebusaway.core.http.HttpClient + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + private val httpClient = mock() + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + var clientOptions = + ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} 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 new file mode 100644 index 0000000..8fc02c7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/PhantomReachableTest.kt @@ -0,0 +1,27 @@ +package org.onebusaway.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PhantomReachableTest { + + @Test + fun closeWhenPhantomReachable_whenObservedIsGarbageCollected_closesCloseable() { + var closed = false + val closeable = AutoCloseable { closed = true } + + closeWhenPhantomReachable( + // Pass an inline object for the object to observe so that it becomes immediately + // unreachable. + Any(), + closeable, + ) + + assertThat(closed).isFalse() + + System.gc() + 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 new file mode 100644 index 0000000..3f4ec78 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HeadersTest.kt @@ -0,0 +1,242 @@ +package org.onebusaway.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HeadersTest { + + enum class TestCase( + val headers: Headers, + val expectedMap: Map>, + 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, + ), + PUT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + 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, + ), + MULTIPLE_PUT_SAME_NAME( + Headers.builder().put("name", "value1").put("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .put("name", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4, + ), + PUT_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .put("NAME", "value2") + .put("nAmE", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3, + ), + PUT_ALL_MAP( + Headers.builder() + .putAll( + mapOf( + "name1" to listOf("value1", "value2"), + "name2" to listOf("value1", "value2"), + ) + ) + .build(), + expectedMap = + mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_HEADERS( + Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + PUT_ALL_CASE_INSENSITIVE( + Headers.builder() + .putAll( + mapOf( + "name" to listOf("value1"), + "NAME" to listOf("value2"), + "nAmE" to listOf("value3"), + ) + ) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3, + ), + REMOVE_ABSENT( + Headers.builder().remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_ONE( + Headers.builder().put("name", "value").remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_CASE_INSENSITIVE( + Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("name1", "name2", "name3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("NAME1", "nAmE3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + CLEAR( + Headers.builder().put("name1", "value").put("name2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REPLACE_ONE_ABSENT( + Headers.builder().replace("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_ONE( + Headers.builder().put("name", "value1").replace("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value2")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value3")), + expectedSize = 1, + ), + REPLACE_MULTIPLE_ABSENT( + Headers.builder().replace("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_ONE( + Headers.builder() + .put("name", "value1") + .replace("name", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("name" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("name" to listOf("value3", "value4")), + expectedSize = 2, + ), + REPLACE_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .replace("NAME", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("NAME" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_ALL_MAP( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(mapOf("name1" to listOf("value2"), "name3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_HEADERS( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(Headers.builder().put("name1", "value2").put("name3", "value2").build()) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) + .build(), + expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), + expectedSize = 2, + ), + } + + @ParameterizedTest + @EnumSource + fun namesAndValues(testCase: TestCase) { + val map = mutableMapOf>() + val headers = testCase.headers + headers.names().forEach { name -> map[name] = headers.values(name) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun caseInsensitiveNames(testCase: TestCase) { + val headers = testCase.headers + + for (name in headers.names()) { + assertThat(headers.values(name)).isEqualTo(headers.values(name.lowercase())) + assertThat(headers.values(name)).isEqualTo(headers.values(name.uppercase())) + } + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.headers.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } +} 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 new file mode 100644 index 0000000..b848b8d --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/HttpRequestTest.kt @@ -0,0 +1,110 @@ +package org.onebusaway.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HttpRequestTest { + + enum class UrlTestCase(val request: HttpRequest, val expectedUrl: String) { + BASE_URL_ONLY( + HttpRequest.builder().method(HttpMethod.GET).baseUrl("https://api.example.com").build(), + expectedUrl = "https://api.example.com", + ), + BASE_URL_WITH_TRAILING_SLASH( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com/") + .build(), + expectedUrl = "https://api.example.com/", + ), + SINGLE_PATH_SEGMENT( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .build(), + expectedUrl = "https://api.example.com/users", + ), + MULTIPLE_PATH_SEGMENTS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegments("users", "123", "profile") + .build(), + expectedUrl = "https://api.example.com/users/123/profile", + ), + PATH_SEGMENT_WITH_SPECIAL_CHARS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("user name") + .build(), + expectedUrl = "https://api.example.com/user+name", + ), + SINGLE_QUERY_PARAM( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParam("limit", "10") + .build(), + expectedUrl = "https://api.example.com/users?limit=10", + ), + MULTIPLE_QUERY_PARAMS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParam("limit", "10") + .putQueryParam("offset", "20") + .build(), + expectedUrl = "https://api.example.com/users?limit=10&offset=20", + ), + QUERY_PARAM_WITH_SPECIAL_CHARS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("search") + .putQueryParam("q", "hello world") + .build(), + expectedUrl = "https://api.example.com/search?q=hello+world", + ), + MULTIPLE_VALUES_SAME_PARAM( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParams("tags", listOf("admin", "user")) + .build(), + expectedUrl = "https://api.example.com/users?tags=admin&tags=user", + ), + BASE_URL_WITH_TRAILING_SLASH_AND_PATH( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com/") + .addPathSegment("users") + .build(), + expectedUrl = "https://api.example.com/users", + ), + COMPLEX_URL( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl("https://api.example.com") + .addPathSegments("v1", "users", "123") + .putQueryParams("include", listOf("profile", "settings")) + .putQueryParam("format", "json") + .build(), + expectedUrl = + "https://api.example.com/v1/users/123?include=profile&include=settings&format=json", + ), + } + + @ParameterizedTest + @EnumSource + fun url(testCase: UrlTestCase) { + val actualUrl = testCase.request.url() + + assertThat(actualUrl).isEqualTo(testCase.expectedUrl) + } +} 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 new file mode 100644 index 0000000..d145396 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/QueryParamsTest.kt @@ -0,0 +1,180 @@ +package org.onebusaway.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class QueryParamsTest { + + enum class TestCase( + val queryParams: QueryParams, + val expectedMap: Map>, + 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, + ), + PUT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + 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, + ), + MULTIPLE_PUT_SAME_NAME( + QueryParams.builder().put("key", "value1").put("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .put("key", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_MAP( + QueryParams.builder() + .putAll( + mapOf( + "key1" to listOf("value1", "value2"), + "key2" to listOf("value1", "value2"), + ) + ) + .build(), + expectedMap = + mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_HEADERS( + QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + REMOVE_ABSENT( + QueryParams.builder().remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_ONE( + QueryParams.builder().put("key", "value").remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL( + QueryParams.builder() + .put("key1", "value") + .put("key3", "value") + .removeAll(setOf("key1", "key2", "key3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + CLEAR( + QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REPLACE_ONE_ABSENT( + QueryParams.builder().replace("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_ONE( + QueryParams.builder().put("key", "value1").replace("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value2")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", "value3") + .build(), + expectedMap = mapOf("key" to listOf("value3")), + expectedSize = 1, + ), + REPLACE_MULTIPLE_ABSENT( + QueryParams.builder().replace("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_ONE( + QueryParams.builder() + .put("key", "value1") + .replace("key", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("key" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("key" to listOf("value3", "value4")), + expectedSize = 2, + ), + REPLACE_ALL_MAP( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll(mapOf("key1" to listOf("value2"), "key3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_HEADERS( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll( + QueryParams.builder().put("key1", "value2").put("key3", "value2").build() + ) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2"), + ), + expectedSize = 3, + ), + } + + @ParameterizedTest + @EnumSource + fun keysAndValues(testCase: TestCase) { + val map = mutableMapOf>() + val queryParams = testCase.queryParams + queryParams.keys().forEach { key -> map[key] = queryParams.values(key) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.queryParams.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } +} 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 new file mode 100644 index 0000000..4a396ec --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/core/http/RetryingHttpClientTest.kt @@ -0,0 +1,356 @@ +package org.onebusaway.core.http + +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.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 +import org.onebusaway.core.Sleeper +import org.onebusaway.errors.OnebusawaySdkRetryableException + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class RetryingHttpClientTest { + + private var openResponseCount = 0 + private lateinit var baseUrl: String + private lateinit var httpClient: HttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().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() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val retryingClient = retryingHttpClientBuilder().build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) + .willReturn(ok()) + ) + val retryingClient = + retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + // First we fail with a retry after header given as a date + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + // 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")) + // Then we return a success + .inScenario("foo") + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("2")), + ) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // first we fail with a retry after header given as a date + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DATE") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 2, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("42")), + ) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After-Ms", "10")) + .willSetStateTo("RETRY_AFTER_DELAY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryableException(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + + var callCount = 0 + val failingHttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + callCount++ + if (callCount == 1) { + throw OnebusawaySdkRetryableException("Simulated retryable failure") + } + return httpClient.execute(request, requestOptions) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + callCount++ + if (callCount == 1) { + val future = CompletableFuture() + future.completeExceptionally( + OnebusawaySdkRetryableException("Simulated retryable failure") + ) + return future + } + return httpClient.executeAsync(request, requestOptions) + } + + override fun close() = httpClient.close() + } + + val retryingClient = + RetryingHttpClient.builder() + .httpClient(failingHttpClient) + .maxRetries(2) + .sleeper( + object : Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + + override fun close() {} + } + ) + .build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 0, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder() = + RetryingHttpClient.builder() + .httpClient(httpClient) + // Use a no-op `Sleeper` to make the test fast. + .sleeper( + object : Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + + override fun close() {} + } + ) + + 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/models/ReferencesTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt new file mode 100644 index 0000000..f237544 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ReferencesTest.kt @@ -0,0 +1,413 @@ +// File generated from our OpenAPI spec by Stainless. + +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 + +internal class ReferencesTest { + + @Test + fun create() { + 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() + + assertThat(references.agencies()) + .containsExactly( + References.Agency.builder() + .id("id") + .name("name") + .timezone("timezone") + .url("url") + .disclaimer("disclaimer") + .email("email") + .fareUrl("fareUrl") + .lang("lang") + .phone("phone") + .privateService(true) + .build() + ) + assertThat(references.routes()) + .containsExactly( + References.Route.builder() + .id("id") + .agencyId("agencyId") + .type(0L) + .color("color") + .description("description") + .longName("longName") + .nullSafeShortName("nullSafeShortName") + .shortName("shortName") + .textColor("textColor") + .url("url") + .build() + ) + assertThat(references.situations()) + .containsExactly( + 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() + ) + assertThat(references.stops()) + .containsExactly( + 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() + ) + assertThat(references.stopTimes()) + .containsExactly( + References.StopTime.builder() + .arrivalTime(0L) + .departureTime(0L) + .distanceAlongTrip(0.0) + .historicalOccupancy("historicalOccupancy") + .stopHeadsign("stopHeadsign") + .stopId("stopId") + .build() + ) + assertThat(references.trips()) + .containsExactly( + 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() + ) + } + + @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 new file mode 100644 index 0000000..dbf3ef5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/ResponseWrapperTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +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 + +internal class ResponseWrapperTest { + + @Test + fun create() { + val responseWrapper = + ResponseWrapper.builder().code(0L).currentTime(0L).text("text").version(0L).build() + + 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/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt new file mode 100644 index 0000000..7879547 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agencieswithcoverage/AgenciesWithCoverageListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agencieswithcoverage + +import org.junit.jupiter.api.Test + +internal class AgenciesWithCoverageListParamsTest { + + @Test + fun create() { + AgenciesWithCoverageListParams.builder().build() + } +} 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/agency/AgencyRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveParamsTest.kt new file mode 100644 index 0000000..f3b777c --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/agency/AgencyRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.agency + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AgencyRetrieveParamsTest { + + @Test + fun create() { + AgencyRetrieveParams.builder().agencyId("agencyID").build() + } + + @Test + fun pathParams() { + val params = AgencyRetrieveParams.builder().agencyId("agencyID").build() + + assertThat(params._pathParam(0)).isEqualTo("agencyID") + // out-of-bound path param + 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/arrivalanddeparture/ArrivalAndDepartureListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParamsTest.kt new file mode 100644 index 0000000..9b5b4a1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureListParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +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 + +internal class ArrivalAndDepartureListParamsTest { + + @Test + fun create() { + ArrivalAndDepartureListParams.builder() + .stopId("1_75403") + .minutesAfter(0L) + .minutesBefore(0L) + .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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 = + ArrivalAndDepartureListParams.builder() + .stopId("1_75403") + .minutesAfter(0L) + .minutesBefore(0L) + .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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 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/arrivalanddeparture/ArrivalAndDepartureRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParamsTest.kt new file mode 100644 index 0000000..170c28b --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/arrivalanddeparture/ArrivalAndDepartureRetrieveParamsTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.arrivalanddeparture + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class ArrivalAndDepartureRetrieveParamsTest { + + @Test + fun create() { + ArrivalAndDepartureRetrieveParams.builder() + .stopId("1_75403") + .serviceDate(0L) + .tripId("tripId") + .stopSequence(0L) + .time(0L) + .vehicleId("vehicleId") + .build() + } + + @Test + fun pathParams() { + val params = + ArrivalAndDepartureRetrieveParams.builder() + .stopId("1_75403") + .serviceDate(0L) + .tripId("tripId") + .build() + + assertThat(params._pathParam(0)).isEqualTo("1_75403") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ArrivalAndDepartureRetrieveParams.builder() + .stopId("1_75403") + .serviceDate(0L) + .tripId("tripId") + .stopSequence(0L) + .time(0L) + .vehicleId("vehicleId") + .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 queryParamsWithoutOptionalFields() { + val params = + ArrivalAndDepartureRetrieveParams.builder() + .stopId("1_75403") + .serviceDate(0L) + .tripId("tripId") + .build() + + 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/block/BlockRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveParamsTest.kt new file mode 100644 index 0000000..f9bbb90 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/block/BlockRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.block + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BlockRetrieveParamsTest { + + @Test + fun create() { + BlockRetrieveParams.builder().blockId("blockID").build() + } + + @Test + fun pathParams() { + val params = BlockRetrieveParams.builder().blockId("blockID").build() + + assertThat(params._pathParam(0)).isEqualTo("blockID") + // out-of-bound path param + 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/config/ConfigRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveParamsTest.kt new file mode 100644 index 0000000..e0e0be4 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/config/ConfigRetrieveParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.config + +import org.junit.jupiter.api.Test + +internal class ConfigRetrieveParamsTest { + + @Test + fun create() { + ConfigRetrieveParams.builder().build() + } +} 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/currenttime/CurrentTimeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParamsTest.kt new file mode 100644 index 0000000..23e4299 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/currenttime/CurrentTimeRetrieveParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.currenttime + +import org.junit.jupiter.api.Test + +internal class CurrentTimeRetrieveParamsTest { + + @Test + fun create() { + CurrentTimeRetrieveParams.builder().build() + } +} 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/reportproblemwithstop/ReportProblemWithStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParamsTest.kt new file mode 100644 index 0000000..6bfa62e --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithstop/ReportProblemWithStopRetrieveParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.reportproblemwithstop + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class ReportProblemWithStopRetrieveParamsTest { + + @Test + fun create() { + ReportProblemWithStopRetrieveParams.builder() + .stopId("stopID") + .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) + .userComment("userComment") + .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 = + ReportProblemWithStopRetrieveParams.builder() + .stopId("stopID") + .code(ReportProblemWithStopRetrieveParams.Code.STOP_NAME_WRONG) + .userComment("userComment") + .userLat(0.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) + .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 queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParamsTest.kt new file mode 100644 index 0000000..86b9156 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/reportproblemwithtrip/ReportProblemWithTripRetrieveParamsTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.reportproblemwithtrip + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class ReportProblemWithTripRetrieveParamsTest { + + @Test + fun create() { + 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() + } + + @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 = + 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 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 queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt new file mode 100644 index 0000000..bbd2166 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/route/RouteRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.route + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RouteRetrieveParamsTest { + + @Test + fun create() { + RouteRetrieveParams.builder().routeId("routeID").build() + } + + @Test + fun pathParams() { + val params = RouteRetrieveParams.builder().routeId("routeID").build() + + assertThat(params._pathParam(0)).isEqualTo("routeID") + // out-of-bound path param + 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/routeidsforagency/RouteIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParamsTest.kt new file mode 100644 index 0000000..190f192 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routeidsforagency/RouteIdsForAgencyListParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routeidsforagency + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RouteIdsForAgencyListParamsTest { + + @Test + fun create() { + RouteIdsForAgencyListParams.builder().agencyId("agencyID").build() + } + + @Test + fun pathParams() { + val params = RouteIdsForAgencyListParams.builder().agencyId("agencyID").build() + + assertThat(params._pathParam(0)).isEqualTo("agencyID") + // out-of-bound path param + 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/routesforagency/RoutesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParamsTest.kt new file mode 100644 index 0000000..c4bea65 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforagency/RoutesForAgencyListParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforagency + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RoutesForAgencyListParamsTest { + + @Test + fun create() { + RoutesForAgencyListParams.builder().agencyId("40").build() + } + + @Test + fun pathParams() { + val params = RoutesForAgencyListParams.builder().agencyId("40").build() + + assertThat(params._pathParam(0)).isEqualTo("40") + // out-of-bound path param + 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/routesforlocation/RoutesForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParamsTest.kt new file mode 100644 index 0000000..f5bbb0c --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/routesforlocation/RoutesForLocationListParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.routesforlocation + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class RoutesForLocationListParamsTest { + + @Test + fun create() { + RoutesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .build() + } + + @Test + fun queryParams() { + val params = + RoutesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .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 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/scheduleforroute/ScheduleForRouteRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParamsTest.kt new file mode 100644 index 0000000..62d37ac --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforroute/ScheduleForRouteRetrieveParamsTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +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 + +internal class ScheduleForRouteRetrieveParamsTest { + + @Test + fun create() { + ScheduleForRouteRetrieveParams.builder() + .routeId("1_100223") + .date(LocalDate.parse("2019-12-27")) + .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 = + ScheduleForRouteRetrieveParams.builder() + .routeId("1_100223") + .date(LocalDate.parse("2019-12-27")) + .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 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/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt new file mode 100644 index 0000000..2be4584 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/scheduleforstop/ScheduleForStopRetrieveParamsTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +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 + +internal class ScheduleForStopRetrieveParamsTest { + + @Test + fun create() { + ScheduleForStopRetrieveParams.builder() + .stopId("stopID") + .date(LocalDate.parse("2019-12-27")) + .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 = + ScheduleForStopRetrieveParams.builder() + .stopId("stopID") + .date(LocalDate.parse("2019-12-27")) + .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 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/searchforroute/SearchForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParamsTest.kt new file mode 100644 index 0000000..f72eb3f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforroute/SearchForRouteListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforroute + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class SearchForRouteListParamsTest { + + @Test + fun create() { + SearchForRouteListParams.builder().input("input").maxCount(0L).build() + } + + @Test + fun queryParams() { + val params = SearchForRouteListParams.builder().input("input").maxCount(0L).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 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/searchforstop/SearchForStopListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParamsTest.kt new file mode 100644 index 0000000..aca21f5 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/searchforstop/SearchForStopListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.searchforstop + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class SearchForStopListParamsTest { + + @Test + fun create() { + SearchForStopListParams.builder().input("input").maxCount(0L).build() + } + + @Test + fun queryParams() { + val params = SearchForStopListParams.builder().input("input").maxCount(0L).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 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/shape/ShapeRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveParamsTest.kt new file mode 100644 index 0000000..2300caf --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/shape/ShapeRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.shape + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShapeRetrieveParamsTest { + + @Test + fun create() { + ShapeRetrieveParams.builder().shapeId("shapeID").build() + } + + @Test + fun pathParams() { + val params = ShapeRetrieveParams.builder().shapeId("shapeID").build() + + assertThat(params._pathParam(0)).isEqualTo("shapeID") + // out-of-bound path param + 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/stop/StopRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveParamsTest.kt new file mode 100644 index 0000000..60c24a1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stop/StopRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stop + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class StopRetrieveParamsTest { + + @Test + fun create() { + StopRetrieveParams.builder().stopId("stopID").build() + } + + @Test + fun pathParams() { + val params = StopRetrieveParams.builder().stopId("stopID").build() + + assertThat(params._pathParam(0)).isEqualTo("stopID") + // out-of-bound path param + 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/stopidsforagency/StopIdsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParamsTest.kt new file mode 100644 index 0000000..c0f8cfc --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopidsforagency/StopIdsForAgencyListParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopidsforagency + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class StopIdsForAgencyListParamsTest { + + @Test + fun create() { + StopIdsForAgencyListParams.builder().agencyId("agencyID").build() + } + + @Test + fun pathParams() { + val params = StopIdsForAgencyListParams.builder().agencyId("agencyID").build() + + assertThat(params._pathParam(0)).isEqualTo("agencyID") + // out-of-bound path param + 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/stopsforagency/StopsForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParamsTest.kt new file mode 100644 index 0000000..aa6e543 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforagency/StopsForAgencyListParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforagency + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class StopsForAgencyListParamsTest { + + @Test + fun create() { + StopsForAgencyListParams.builder().agencyId("agencyID").build() + } + + @Test + fun pathParams() { + val params = StopsForAgencyListParams.builder().agencyId("agencyID").build() + + assertThat(params._pathParam(0)).isEqualTo("agencyID") + // out-of-bound path param + 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/stopsforlocation/StopsForLocationListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParamsTest.kt new file mode 100644 index 0000000..768453e --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforlocation/StopsForLocationListParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforlocation + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class StopsForLocationListParamsTest { + + @Test + fun create() { + StopsForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .build() + } + + @Test + fun queryParams() { + val params = + StopsForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .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 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/stopsforroute/StopsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParamsTest.kt new file mode 100644 index 0000000..a40d30a --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/stopsforroute/StopsForRouteListParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.stopsforroute + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class StopsForRouteListParamsTest { + + @Test + fun create() { + StopsForRouteListParams.builder() + .routeId("routeID") + .includePolylines(true) + .time("time") + .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 = + StopsForRouteListParams.builder() + .routeId("routeID") + .includePolylines(true) + .time("time") + .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 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/trip/TripRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveParamsTest.kt new file mode 100644 index 0000000..fc93c04 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/trip/TripRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.trip + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TripRetrieveParamsTest { + + @Test + fun create() { + TripRetrieveParams.builder().tripId("tripID").build() + } + + @Test + fun pathParams() { + val params = TripRetrieveParams.builder().tripId("tripID").build() + + assertThat(params._pathParam(0)).isEqualTo("tripID") + // out-of-bound path param + 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/tripdetails/TripDetailRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParamsTest.kt new file mode 100644 index 0000000..8e7aade --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripdetails/TripDetailRetrieveParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripdetails + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class TripDetailRetrieveParamsTest { + + @Test + fun create() { + TripDetailRetrieveParams.builder() + .tripId("tripID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .serviceDate(0L) + .time(0L) + .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 = + TripDetailRetrieveParams.builder() + .tripId("tripID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .serviceDate(0L) + .time(0L) + .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 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/tripforvehicle/TripForVehicleRetrieveParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParamsTest.kt new file mode 100644 index 0000000..d1b8d5d --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripforvehicle/TripForVehicleRetrieveParamsTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripforvehicle + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class TripForVehicleRetrieveParamsTest { + + @Test + fun create() { + TripForVehicleRetrieveParams.builder() + .vehicleId("vehicleID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .time(0L) + .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 = + TripForVehicleRetrieveParams.builder() + .vehicleId("vehicleID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .time(0L) + .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 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/tripsforroute/TripsForRouteListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParamsTest.kt new file mode 100644 index 0000000..87926b8 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/tripsforroute/TripsForRouteListParamsTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.tripsforroute + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +internal class TripsForRouteListParamsTest { + + @Test + fun create() { + TripsForRouteListParams.builder() + .routeId("routeID") + .includeSchedule(true) + .includeStatus(true) + .time(0L) + .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 = + TripsForRouteListParams.builder() + .routeId("routeID") + .includeSchedule(true) + .includeStatus(true) + .time(0L) + .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 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/vehiclesforagency/VehiclesForAgencyListParamsTest.kt b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParamsTest.kt new file mode 100644 index 0000000..d71fee1 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/models/vehiclesforagency/VehiclesForAgencyListParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.models.vehiclesforagency + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.core.http.QueryParams + +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 queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("time", "time").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = VehiclesForAgencyListParams.builder().agencyId("agencyID").build() + + 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 new file mode 100644 index 0000000..ce1d09d --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ErrorHandlingTest.kt @@ -0,0 +1,349 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.get +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.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 +import org.onebusaway.core.http.Headers +import org.onebusaway.core.jsonMapper +import org.onebusaway.errors.BadRequestException +import org.onebusaway.errors.InternalServerException +import org.onebusaway.errors.NotFoundException +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 + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ErrorHandlingTest { + + companion object { + + 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 + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() + } + + @Test + fun currentTimeRetrieve400() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve400WithRawResponse() { + val currentTimeService = client.currentTime().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve401() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve401WithRawResponse() { + val currentTimeService = client.currentTime().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve403() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve403WithRawResponse() { + val currentTimeService = client.currentTime().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve404() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve404WithRawResponse() { + val currentTimeService = client.currentTime().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve422() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve422WithRawResponse() { + val currentTimeService = client.currentTime().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve429() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve429WithRawResponse() { + val currentTimeService = client.currentTime().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve500() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve500WithRawResponse() { + val currentTimeService = client.currentTime().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + 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 currentTimeRetrieve999() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun currentTimeRetrieve999WithRawResponse() { + val currentTimeService = client.currentTime().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun currentTimeRetrieveInvalidJsonBody() { + val currentTimeService = client.currentTime() + stubFor( + get(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) + + val e = assertThrows { currentTimeService.retrieve() } + + assertThat(e).hasMessage("Error reading response") + } + + private fun Headers.toMap(): Map> = + mutableMapOf>().also { map -> + names().forEach { map[it] = values(it) } + } +} 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 new file mode 100644 index 0000000..3b0ccc7 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/ServiceParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +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.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.verify +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.models.currenttime.CurrentTimeRetrieveParams + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ServiceParamsTest { + + private lateinit var client: OnebusawaySdkClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() + } + + @Test + fun retrieve() { + val currentTimeService = client.currentTime() + stubFor(get(anyUrl()).willReturn(ok("{}"))) + + currentTimeService.retrieve( + CurrentTimeRetrieveParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .build() + ) + + 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 new file mode 100644 index 0000000..2970c2b --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgenciesWithCoverageServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class AgenciesWithCoverageServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val agenciesWithCoverageService = client.agenciesWithCoverage() + + 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 new file mode 100644 index 0000000..3d53110 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/AgencyServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class AgencyServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val agencyService = client.agency() + + 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 new file mode 100644 index 0000000..3aac305 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ArrivalAndDepartureServiceTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +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.OnebusawaySdkOkHttpClient +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureListParams +import org.onebusaway.models.arrivalanddeparture.ArrivalAndDepartureRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ArrivalAndDepartureServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val arrivalAndDepartureService = client.arrivalAndDeparture() + + val arrivalAndDeparture = + arrivalAndDepartureService.retrieve( + ArrivalAndDepartureRetrieveParams.builder() + .stopId("1_75403") + .serviceDate(0L) + .tripId("tripId") + .stopSequence(0L) + .time(0L) + .vehicleId("vehicleId") + .build() + ) + + arrivalAndDeparture.validate() + } + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val arrivalAndDepartureService = client.arrivalAndDeparture() + + val arrivalAndDepartures = + arrivalAndDepartureService.list( + ArrivalAndDepartureListParams.builder() + .stopId("1_75403") + .minutesAfter(0L) + .minutesBefore(0L) + .time(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + 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 new file mode 100644 index 0000000..0d6577c --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/BlockServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class BlockServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val blockService = client.block() + + 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 new file mode 100644 index 0000000..44a28ec --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ConfigServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class ConfigServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val configService = client.config() + + 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 new file mode 100644 index 0000000..65d5853 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/CurrentTimeServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class CurrentTimeServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val currentTimeService = client.currentTime() + + 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 new file mode 100644 index 0000000..b4e46ca --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithStopServiceTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.reportproblemwithstop.ReportProblemWithStopRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ReportProblemWithStopServiceTest { + + @Test + 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.0f) + .userLocationAccuracy(0.0f) + .userLon(0.0f) + .build() + ) + + 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 new file mode 100644 index 0000000..057847d --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ReportProblemWithTripServiceTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.reportproblemwithtrip.ReportProblemWithTripRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ReportProblemWithTripServiceTest { + + @Test + 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() + .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() + ) + + 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 new file mode 100644 index 0000000..bafe347 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteIdsForAgencyServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class RouteIdsForAgencyServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routeIdsForAgencyService = client.routeIdsForAgency() + + 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 new file mode 100644 index 0000000..38e8475 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RouteServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class RouteServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routeService = client.route() + + 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 new file mode 100644 index 0000000..2972560 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForAgencyServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class RoutesForAgencyServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routesForAgencyService = client.routesForAgency() + + 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 new file mode 100644 index 0000000..376eeee --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/RoutesForLocationServiceTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.routesforlocation.RoutesForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class RoutesForLocationServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val routesForLocationService = client.routesForLocation() + + val routesForLocations = + routesForLocationService.list( + RoutesForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .build() + ) + + 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 new file mode 100644 index 0000000..f9bc244 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForRouteServiceTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +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.OnebusawaySdkOkHttpClient +import org.onebusaway.models.scheduleforroute.ScheduleForRouteRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ScheduleForRouteServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val scheduleForRouteService = client.scheduleForRoute() + + val scheduleForRoute = + scheduleForRouteService.retrieve( + ScheduleForRouteRetrieveParams.builder() + .routeId("1_100223") + .date(LocalDate.parse("2019-12-27")) + .build() + ) + + 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 new file mode 100644 index 0000000..caf1b82 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ScheduleForStopServiceTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +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.OnebusawaySdkOkHttpClient +import org.onebusaway.models.scheduleforstop.ScheduleForStopRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class ScheduleForStopServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val scheduleForStopService = client.scheduleForStop() + + val scheduleForStop = + scheduleForStopService.retrieve( + ScheduleForStopRetrieveParams.builder() + .stopId("stopID") + .date(LocalDate.parse("2019-12-27")) + .build() + ) + + 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 new file mode 100644 index 0000000..712475d --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForRouteServiceTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.searchforroute.SearchForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class SearchForRouteServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val searchForRouteService = client.searchForRoute() + + val searchForRoutes = + searchForRouteService.list( + SearchForRouteListParams.builder().input("input").maxCount(0L).build() + ) + + 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 new file mode 100644 index 0000000..1ce37be --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/SearchForStopServiceTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.searchforstop.SearchForStopListParams + +@ExtendWith(TestServerExtension::class) +internal class SearchForStopServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val searchForStopService = client.searchForStop() + + val searchForStops = + searchForStopService.list( + SearchForStopListParams.builder().input("input").maxCount(0L).build() + ) + + 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 new file mode 100644 index 0000000..c2a6daf --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/ShapeServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class ShapeServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val shapeService = client.shape() + + 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 new file mode 100644 index 0000000..a1aa457 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopIdsForAgencyServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class StopIdsForAgencyServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopIdsForAgencyService = client.stopIdsForAgency() + + 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 new file mode 100644 index 0000000..de4e314 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class StopServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopService = client.stop() + + 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 new file mode 100644 index 0000000..8be4373 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForAgencyServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class StopsForAgencyServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForAgencyService = client.stopsForAgency() + + 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 new file mode 100644 index 0000000..be4b08c --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForLocationServiceTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.stopsforlocation.StopsForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class StopsForLocationServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForLocationService = client.stopsForLocation() + + val stopsForLocations = + stopsForLocationService.list( + StopsForLocationListParams.builder() + .lat(0.0) + .lon(0.0) + .latSpan(0.0) + .lonSpan(0.0) + .query("query") + .radius(0.0) + .build() + ) + + 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 new file mode 100644 index 0000000..4622d42 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/StopsForRouteServiceTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.stopsforroute.StopsForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class StopsForRouteServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val stopsForRouteService = client.stopsForRoute() + + val stopsForRoutes = + stopsForRouteService.list( + StopsForRouteListParams.builder() + .routeId("routeID") + .includePolylines(true) + .time("time") + .build() + ) + + 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 new file mode 100644 index 0000000..1f41a5c --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripDetailServiceTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.tripdetails.TripDetailRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class TripDetailServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripDetailService = client.tripDetails() + + val tripDetail = + tripDetailService.retrieve( + TripDetailRetrieveParams.builder() + .tripId("tripID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .serviceDate(0L) + .time(0L) + .build() + ) + + 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 new file mode 100644 index 0000000..b44b32f --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripForVehicleServiceTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.tripforvehicle.TripForVehicleRetrieveParams + +@ExtendWith(TestServerExtension::class) +internal class TripForVehicleServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripForVehicleService = client.tripForVehicle() + + val tripForVehicle = + tripForVehicleService.retrieve( + TripForVehicleRetrieveParams.builder() + .vehicleId("vehicleID") + .includeSchedule(true) + .includeStatus(true) + .includeTrip(true) + .time(0L) + .build() + ) + + 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 new file mode 100644 index 0000000..597d6c9 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient + +@ExtendWith(TestServerExtension::class) +internal class TripServiceTest { + + @Test + fun retrieve() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripService = client.trip() + + 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 new file mode 100644 index 0000000..1042ce0 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForLocationServiceTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.tripsforlocation.TripsForLocationListParams + +@ExtendWith(TestServerExtension::class) +internal class TripsForLocationServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripsForLocationService = client.tripsForLocation() + + val tripsForLocations = + tripsForLocationService.list( + TripsForLocationListParams.builder() + .lat(0.0f) + .latSpan(0.0f) + .lon(0.0f) + .lonSpan(0.0f) + .includeSchedule(true) + .includeTrip(true) + .time(0L) + .build() + ) + + 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 new file mode 100644 index 0000000..01f0580 --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/TripsForRouteServiceTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.tripsforroute.TripsForRouteListParams + +@ExtendWith(TestServerExtension::class) +internal class TripsForRouteServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tripsForRouteService = client.tripsForRoute() + + val tripsForRoutes = + tripsForRouteService.list( + TripsForRouteListParams.builder() + .routeId("routeID") + .includeSchedule(true) + .includeStatus(true) + .time(0L) + .build() + ) + + 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 new file mode 100644 index 0000000..1bb2a0b --- /dev/null +++ b/onebusaway-sdk-java-core/src/test/kotlin/org/onebusaway/services/blocking/VehiclesForAgencyServiceTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.onebusaway.TestServerExtension +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.models.vehiclesforagency.VehiclesForAgencyListParams + +@ExtendWith(TestServerExtension::class) +internal class VehiclesForAgencyServiceTest { + + @Test + fun list() { + val client = + OnebusawaySdkOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val vehiclesForAgencyService = client.vehiclesForAgency() + + val vehiclesForAgencies = + vehiclesForAgencyService.list( + VehiclesForAgencyListParams.builder().agencyId("agencyID").time("time").build() + ) + + vehiclesForAgencies.validate() + } +} diff --git a/onebusaway-sdk-java-example/build.gradle.kts b/onebusaway-sdk-java-example/build.gradle.kts new file mode 100644 index 0000000..36c7844 --- /dev/null +++ b/onebusaway-sdk-java-example/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + id("onebusaway-sdk.java") + application +} + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":onebusaway-sdk-java")) +} + +tasks.withType().configureEach { + // Allow using more modern APIs, like `List.of` and `Map.of`, in examples. + options.release.set(9) +} + +application { + // Use `./gradlew :onebusaway-sdk-java-example:run` to run `Main` + // Use `./gradlew :onebusaway-sdk-java-example:run -Pexample=Something` to run `SomethingExample` + mainClass = "org.onebusaway.example.${ + if (project.hasProperty("example")) + "${project.property("example")}Example" + else + "Main" + }" +} diff --git a/onebusaway-sdk-java-lib/.keep b/onebusaway-sdk-java-lib/.keep new file mode 100644 index 0000000..5e2c99f --- /dev/null +++ b/onebusaway-sdk-java-lib/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store custom files to expand the SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/onebusaway-sdk-java-proguard-test/build.gradle.kts b/onebusaway-sdk-java-proguard-test/build.gradle.kts new file mode 100644 index 0000000..8d4f83f --- /dev/null +++ b/onebusaway-sdk-java-proguard-test/build.gradle.kts @@ -0,0 +1,101 @@ +plugins { + id("onebusaway-sdk.kotlin") + id("com.gradleup.shadow") version "8.3.8" +} + +buildscript { + repositories { + google() + } + + dependencies { + classpath("com.guardsquare:proguard-gradle:7.4.2") + classpath("com.android.tools:r8:8.3.37") + } +} + +dependencies { + testImplementation(project(":onebusaway-sdk-java")) + testImplementation(kotlin("test")) + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") +} + +tasks.shadowJar { + from(sourceSets.test.get().output) + configurations = listOf(project.configurations.testRuntimeClasspath.get()) +} + +val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar" +val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("ProGuard") + + injars(tasks.shadowJar) + outjars(proguardJarPath) + printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") + + val javaHome = System.getProperty("java.home") + if (System.getProperty("java.version").startsWith("1.")) { + // Before Java 9, the runtime classes were packaged in a single jar file. + libraryjars("$javaHome/lib/rt.jar") + } else { + // As of Java 9, the runtime classes are packaged in modular jmod files. + libraryjars( + // Filters must be specified first, as a map. + mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"), + "$javaHome/jmods/java.base.jmod" + ) + } + + configuration("./test.pro") + configuration("../onebusaway-sdk-java-core/src/main/resources/META-INF/proguard/onebusaway-sdk-java-core.pro") +} + +val testProGuard by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(proguardJar) + notCompatibleWithConfigurationCache("ProGuard") + + mainClass.set("org.onebusaway.proguard.ProGuardCompatibilityTest") + classpath = files(proguardJarPath) +} + +val r8JarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-r8.jar" +val r8Jar by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.android.tools.r8.R8") + classpath = buildscript.configurations["classpath"] + + args = listOf( + "--release", + "--classfile", + "--output", r8JarPath, + "--lib", System.getProperty("java.home"), + "--pg-conf", "./test.pro", + "--pg-conf", "../onebusaway-sdk-java-core/src/main/resources/META-INF/proguard/onebusaway-sdk-java-core.pro", + "--pg-map-output", "${layout.buildDirectory.get()}/r8-mapping.txt", + tasks.shadowJar.get().archiveFile.get().asFile.absolutePath, + ) +} + +val testR8 by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(r8Jar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("org.onebusaway.proguard.ProGuardCompatibilityTest") + classpath = files(r8JarPath) +} + +tasks.test { + dependsOn(testProGuard) + dependsOn(testR8) + // We defer to the tests run via the ProGuard JAR. + enabled = false +} diff --git a/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt b/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt new file mode 100644 index 0000000..385085c --- /dev/null +++ b/onebusaway-sdk-java-proguard-test/src/test/kotlin/org/onebusaway/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.onebusaway.proguard + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.reflect.full.memberFunctions +import kotlin.reflect.jvm.javaMethod +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient +import org.onebusaway.core.jsonMapper +import org.onebusaway.models.References + +internal class ProGuardCompatibilityTest { + + companion object { + + @JvmStatic + fun main(args: Array) { + // To debug that we're using the right JAR. + val jarPath = this::class.java.getProtectionDomain().codeSource.location + println("JAR being used: $jarPath") + + // We have to manually run the test methods instead of using the JUnit runner because it + // seems impossible to get working with R8. + val test = ProGuardCompatibilityTest() + test::class + .memberFunctions + .asSequence() + .filter { function -> + function.javaMethod?.isAnnotationPresent(Test::class.java) == true + } + .forEach { it.call(test) } + } + } + + @Test + fun proguardRules() { + val rulesFile = + javaClass.classLoader.getResourceAsStream( + "META-INF/proguard/onebusaway-sdk-java-core.pro" + ) + + assertThat(rulesFile).isNotNull() + } + + @Test + fun client() { + val client = OnebusawaySdkOkHttpClient.builder().apiKey("My API Key").build() + + assertThat(client).isNotNull() + assertThat(client.agenciesWithCoverage()).isNotNull() + assertThat(client.agency()).isNotNull() + assertThat(client.vehiclesForAgency()).isNotNull() + assertThat(client.config()).isNotNull() + assertThat(client.currentTime()).isNotNull() + assertThat(client.stopsForLocation()).isNotNull() + assertThat(client.stopsForRoute()).isNotNull() + assertThat(client.stopsForAgency()).isNotNull() + assertThat(client.stop()).isNotNull() + assertThat(client.stopIdsForAgency()).isNotNull() + assertThat(client.scheduleForStop()).isNotNull() + assertThat(client.route()).isNotNull() + assertThat(client.routeIdsForAgency()).isNotNull() + assertThat(client.routesForLocation()).isNotNull() + assertThat(client.routesForAgency()).isNotNull() + assertThat(client.scheduleForRoute()).isNotNull() + assertThat(client.arrivalAndDeparture()).isNotNull() + assertThat(client.trip()).isNotNull() + assertThat(client.tripsForLocation()).isNotNull() + assertThat(client.tripDetails()).isNotNull() + assertThat(client.tripForVehicle()).isNotNull() + assertThat(client.tripsForRoute()).isNotNull() + assertThat(client.reportProblemWithStop()).isNotNull() + assertThat(client.reportProblemWithTrip()).isNotNull() + assertThat(client.searchForStop()).isNotNull() + assertThat(client.searchForRoute()).isNotNull() + assertThat(client.block()).isNotNull() + assertThat(client.shape()).isNotNull() + } + + @Test + fun referencesRoundtrip() { + 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-proguard-test/test.pro b/onebusaway-sdk-java-proguard-test/test.pro new file mode 100644 index 0000000..2ad38fe --- /dev/null +++ b/onebusaway-sdk-java-proguard-test/test.pro @@ -0,0 +1,9 @@ +# Specify the entrypoint where ProGuard starts to determine what's reachable. +-keep class org.onebusaway.proguard.** { *; } + +# For the testing framework. +-keep class org.junit.** { *; } + +# Many warnings don't apply for our testing purposes. +-dontnote +-dontwarn \ No newline at end of file diff --git a/onebusaway-sdk-java/build.gradle.kts b/onebusaway-sdk-java/build.gradle.kts new file mode 100644 index 0000000..0e3ac39 --- /dev/null +++ b/onebusaway-sdk-java/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + id("onebusaway-sdk.kotlin") + id("onebusaway-sdk.publish") +} + +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/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..8f98719 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + "README.md", + "build.gradle.kts" + ] +} \ No newline at end of file diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..f406348 --- /dev/null +++ b/scripts/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Building classes" +./gradlew build testClasses -x test diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 0000000..1b3bc47 --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + +cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +echo "Looking for file: $FILE_LIST" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +if ! command -v ktfmt-fast-format &> /dev/null; then + echo "Error: ktfmt-fast-format not found" + exit 1 +fi + +# Process Kotlin files +echo "==> Looking for Kotlin files" +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/' || true) +echo "==> Done looking for Kotlin files" + +if [[ -n "$kt_files" ]]; then + echo "==> will format Kotlin files" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" +else + echo "No Kotlin files to format -- expected outcome during incremental formatting" +fi + +# TODO(mbudayr): support palantir-java-format +# Process Java files +# grep -E '\.java$' "$FILE_LIST" | grep -v './buildSrc/build/' | tr '\n' '\0' | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/format b/scripts/format new file mode 100755 index 0000000..65db176 --- /dev/null +++ b/scripts/format @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if command -v ktfmt &> /dev/null; then + echo "==> Running ktfmt" + ./scripts/kotlin-format +else + echo "==> Running gradlew formatKotlin" + ./gradlew formatKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Running palantir-java-format" + ./scripts/java-format +else + echo "==> Running gradlew formatJava" + ./gradlew formatJava +fi diff --git a/scripts/java-format b/scripts/java-format new file mode 100755 index 0000000..ad5febc --- /dev/null +++ b/scripts/java-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.java" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/kotlin-format b/scripts/kotlin-format new file mode 100755 index 0000000..3b8be9e --- /dev/null +++ b/scripts/kotlin-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@" diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 0000000..dbc8f77 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running lints" + +if command -v ktfmt &> /dev/null; then + echo "==> Checking ktfmt" + ./scripts/kotlin-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintKotlin" + ./gradlew lintKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Checking palantir-java-format" + ./scripts/java-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintJava" + ./gradlew lintJava +fi diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 0000000..0b28f6e --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 0000000..047bc1d --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +./gradlew test "$@" diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts new file mode 100755 index 0000000..729e6f2 --- /dev/null +++ b/scripts/upload-artifacts @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# ANSI Color Codes +GREEN='\033[32m' +RED='\033[31m' +NC='\033[0m' # No Color + +log_error() { + local msg="$1" + local headers="$2" + local body="$3" + echo -e "${RED}${msg}${NC}" + [[ -f "$headers" ]] && echo -e "${RED}Headers:$(cat "$headers")${NC}" + echo -e "${RED}Body: ${body}${NC}" + exit 1 +} + +upload_file() { + local file_name="$1" + local tmp_headers + tmp_headers=$(mktemp) + + if [ -f "$file_name" ]; then + echo -e "${GREEN}Processing file: $file_name${NC}" + pkg_file_name="mvn${file_name#./build/local-maven-repo}" + + # Get signed URL for uploading artifact file + signed_url_response=$(curl -X POST -G "$URL" \ + -sS --retry 5 \ + -D "$tmp_headers" \ + --data-urlencode "filename=$pkg_file_name" \ + -H "Authorization: Bearer $AUTH" \ + -H "Content-Type: application/json") + + # Validate JSON and extract URL + if ! signed_url=$(echo "$signed_url_response" | jq -e -r '.url' 2>/dev/null) || [[ "$signed_url" == "null" ]]; then + log_error "Failed to get valid signed URL" "$tmp_headers" "$signed_url_response" + fi + + # Set content-type based on file extension + local extension="${file_name##*.}" + local content_type + case "$extension" in + jar) content_type="application/java-archive" ;; + md5|sha1|sha256|sha512) content_type="text/plain" ;; + module) content_type="application/json" ;; + pom|xml) content_type="application/xml" ;; + *) content_type="application/octet-stream" ;; + esac + + # Upload file + upload_response=$(curl -v -X PUT \ + --retry 5 \ + -D "$tmp_headers" \ + -H "Content-Type: $content_type" \ + --data-binary "@${file_name}" "$signed_url" 2>&1) + + if ! echo "$upload_response" | grep -q "HTTP/[0-9.]* 200"; then + log_error "Failed upload artifact file" "$tmp_headers" "$upload_response" + fi + + # Insert small throttle to reduce rate limiting risk + sleep 0.1 + fi +} + +walk_tree() { + local current_dir="$1" + + for entry in "$current_dir"/*; do + # Check that entry is valid + [ -e "$entry" ] || [ -h "$entry" ] || continue + + if [ -d "$entry" ]; then + walk_tree "$entry" + else + upload_file "$entry" + fi + done +} + +cd "$(dirname "$0")/.." + +echo "::group::Creating local Maven content" +./gradlew publishMavenPublicationToLocalFileSystemRepository -PpublishLocal +echo "::endgroup::" + +echo "::group::Uploading to pkg.stainless.com" +walk_tree "./build/local-maven-repo" +echo "::endgroup::" + +echo "::group::Generating instructions" +echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'" +echo "::endgroup::" diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..dbf4d3e --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,14 @@ +rootProject.name = "onebusaway-sdk-java-root" + +val projectNames = rootDir.listFiles() + ?.asSequence() + .orEmpty() + .filter { file -> + file.isDirectory && + file.name.startsWith("onebusaway-sdk-java") && + file.listFiles()?.asSequence().orEmpty().any { it.name == "build.gradle.kts" } + } + .map { it.name } + .toList() +println("projects: $projectNames") +projectNames.forEach { include(it) }